Skipping tests during Maven phases

If you’re running a Maven phase/goal and need to skip the execution of tests (because they’re temporarily failing), add one of the following options:

mvn -DskipTests phasename
mvn -Dmaven.test.skip=true phasename

Normally you’d only continue with the build if the tests are passing, but sometimes you may have a valid reason to force the build to continue regardless.

These options are covered in the Maven docs here.

Maven vs Gradle equivalent commands

I’ve seen Gradle becoming more popular in recent years, but it wasn’t too long ago that Maven was the tool for managing dependencies and building/packaging apps.

From my own experience with both, here’s the commonly used equivalent commands:

MavenGradle
mvn compileNo equivalent as gradle build compiles and packages?
mvn packagegradle build
mvn install (see note below)gradle build
mvn testgradle test

There is no direct equivalent to ‘mvn install’ in gradle, but if you depend on a local Maven repo, there is a Gradle plugin to publish packaged artifacts to a Maven repo – see here.

Installing Maven tool support in vanilla Eclipse IDE

If you download an Eclipse bundle like the Eclipse IDE for Java EE developers, you’ll get Maven support built in, but if you download a vanilla Eclipse install (like from using from of the daily builds), you’ll need to install many pllugins yourself.

Eclipse support for Maven is provided via the m2Eclipse plugin, there are installation instructions here:

I’ve had luck using these installer buttons before, but on this daily build for M1 they don’t seem to do anything. Instead I used the manual approach by adding a new ‘site’ in ‘Add New Software, ‘ adding https://download.eclipse.org/technology/m2e/releases/latest/ and then selecting ‘Maven Integration for Eclipse’ :

Done!

Serverless framework deploy for Java AWS Lambdas

The Serverless framework ‘serverless deploy’ deploys whatever .jar you have packaged and ready to go within your source project.

If you make local code changes but don’t re-build your .jar, serverless thinks you don’t have any changes to deploy:

$ serverless deploy
...
Serverless: Packaging service...
Serverless: Service files not changed. Skipping deployment...

If you’re building a maven-based project, ‘mvn clean package’ first, then run your ‘serverless deploy’.