Java: Using Maven from the console for running classes, unit tests, checking dependencies

In this short article, I’ll provide some Maven commands that I’ve found helpful.

 

Run single class from src/main/java

mvn exec:java -Dexec.mainClass=this.is.MyClass -Dexec.args="myarg1 'my second arg' myarg3"

Run unit test from src/test/java, all methods decorated with @Test

mvn test -Dtest=this.is.MyTestClass

Run unit test from src/test/java, only methods decorated with @Test and that start with ‘testDatabase’

mvn test -Dtest=this.is.MyTestClass#testDatabase*

Continue reading “Java: Using Maven from the console for running classes, unit tests, checking dependencies”

Maven: Installing a 3rd party jar to a local or remote repository

Especially in enterprise application development, there can be 3rd party dependencies that are not available in public Maven repositories.  These may be internal, business specific libraries or licensed libraries that have limitations on usage.

When this is the case, you can either publish to a private Maven repository that controls authorization or you can put them into your local cached maven repository.

Continue reading “Maven: Installing a 3rd party jar to a local or remote repository”

Maven: Installing a private Maven repository on Ubuntu using Artifactory

An essential part of the standard build process for Java applications is having a set of repositories where project artifacts are stored.

Artifact curation provides the ability to manage dependencies, quickly rollback releases, support compatibility of downstream projects, do QA promotion from test to production, support a continuous build pipeline, and provides auditability.

JFrog puts out an open-source Maven server called Artifactory that is perfect for setting up a private Maven repository for internal applications.

Continue reading “Maven: Installing a private Maven repository on Ubuntu using Artifactory”