We have a Java Project for AWS Lambda that executes different evaluations on request. This works good so far, but for some evaluations we would like the option to start them manually on our local computer.
For this we would like to have 2 maven build targets:
The current maven build configurations looks like this (we build the deployable jar with shade):
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
How would i add a second target for a specified main function?
I would just add the exec-maven-plugin to your build. Something like:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<mainClass>your.package.MainClass</mainClass>
</configuration>
</plugin>
</plugins>
In this case, you can run a public static void main(String[] argv)
in your code with mvn exec:java -Dexec.args="some set of args"
. I would have a common "work" object/class that does what you ultimately want. Your Lambda handler can call this worker class or your main()
can.
This is not exactly what you're looking for in that the main class is bundled with your Lambda and the Lambda is bundled with your main. But if the majority of your code is in the worker class then the rest is minimal.