Deploying individual functions in java

Hi All,
I wonder if I’m doing something wrong here. I’ve successfully created a sample java project from the template and deployed it and it all looks good.
But when I try to deploy only one function with “serverless deploy function --function hello”, rather taking the jar file from the target folder it tries to zip up the whole folder and uploads (I’ve checked it by downloading the package with “export function”)
When I deploy the whole project with “serverless deploy” it takes the jar and deploys it and works fine, but when I use “deploy function” it fails with class not found.

Thanks,

Have you also updated your service definition to include the relevant packaging options? Because Serverless works with many languages, it doesn’t currently automatically work-out language-specific dependencies, packages, etc. It will be a difficult problem to solve consistently, especially if (when!) more languages are supported.

Once you specify individually: true in your serverless.yml and the various specific includes/excludes for your funciton, I think your targeted deploy command will work as you expect. As I haven’t personally tested it with Java, please report back and let us know if it does or doesn’t work.

Hi, thanks for quick reply.
It worked when I moved the artefact property to function definition rather than global and set individually to true. So this is working

service: helloWorld
provider:
  name: aws
  runtime: java8
  region: eu-west-1

package:
  individually: true

functions:
  hello:
    handler: hello.Handler::handleRequest
    package:
      artifact: target/hello-dev.jar
    events:
      - http:
          path: hello/world
          method: get

But I was expecting this to work as well which isn’t:

service: helloWorld

provider:
  name: aws
  runtime: java8
  region: eu-west-1

package:
  artifact: target/hello-dev.jar

functions:
  hello:
    handler: hello.Handler::handleRequest
    events:
      - http:
          path: hello/world
          method: get

I don’t want to define the package in each of my function definitions. But I would still love to deploy individual function from my local in the development phase.