SoftwareEntwicklung Beratung Schulung

A coders, hackers heaven.....Hm...I do not think so...

Apache Maven Invoker Plugin Version 3.0.0 Released

| Comments

The Apache Maven team is pleased to announce the release of the Apache Maven Invoker Plugin, version 3.0.0.

The Invoker Plugin is used to run a set of Maven projects. The plugin can determine whether each project execution is successful, and optionally can verify the output generated from a given project execution.

This plugin is in particular handy to perform integration tests for other Maven plugins. The Invoker Plugin can be employed to run a set of test projects that have been designed to assert certain features of the plugin under test.

You should specify the version in your project’s plugin configuration:

1
2
3
4
5
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-invoker-plugin</artifactId>
  <version>3.0.0</version>
</plugin>

You can download the appropriate sources etc. from the download page:

https://maven.apache.org/plugins/maven-invoker-plugin/download.cgi

Apache Maven Dependency Plugin Version 3.0.1 Released

| Comments

The Apache Maven team is pleased to announce the release of the Apache Maven Dependecy Plugin, version 3.0.1.

The dependency plugin provides the capability to manipulate artifacts. It can copy and/or unpack artifacts from local or remote repositories to a specified location.

https://maven.apache.org/plugins/maven-dependency-plugin/

You should specify the version in your project’s plugin configuration:

1
2
3
4
5
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>3.0.1</version>
</plugin>

You can download the appropriate sources etc. from the download page:

https://maven.apache.org/plugins/maven-dependency-plugin/download.cgi

Apache Maven Shared Dependency Analyzer Version 1.7 Released

| Comments

The Apache Maven team is pleased to announce the release of the Apache Maven Shared Component: Maven Dependency Analyzer Version 1.7

Analyzes the dependencies of a project for undeclared or unused artifacts.

You should specify the version in your project’s dependency list:

1
2
3
4
5
<dependency>
  <groupId>org.apache.maven.shared</groupId>
  <artifactId>maven-dependency-analyzer</artifactId>
  <version>1.7</version>
</dependency>

Apache Maven WAR Plugin Version 3.1.0 Released

| Comments

The Apache Maven team is pleased to announce the release of the Apache Maven WAR Plugin, version 3.1.0.

The WAR Plugin is responsible for collecting all artifact dependencies, classes and resources of the web application and packaging them into a web application archive.

You should specify the version in your project’s plugin configuration:

1
2
3
4
5
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>3.1.0</version>
</plugin>

You can download the appropriate sources etc. from the download page.

Important Note:

  • Maven 3.X only
  • JDK 6 minimum requirement

Apache Maven Surefire Plugin Version 2.20 Released

| Comments

The Apache Maven team is pleased to announce the release of the Apache Maven Surefire Plugin, version 2.20.

The release contains 70 bug fixes. Again we received contributions from the community in form of bug reports and bug fixes.

Thank you and keep them coming!

You should specify the version in your project’s plugin configuration:

1
2
3
4
5
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.20</version>
</plugin>

or for failsafe:

1
2
3
4
5
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-failsafe-plugin</artifactId>
  <version>2.20</version>
</plugin>

or for surefire-report:

1
2
3
4
5
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-report-plugin</artifactId>
  <version>2.20</version>
</plugin>

Apache Maven Archetype Plugin 3.0.1 Released

| Comments

The Apache Maven team is pleased to announce the release of the Apache Maven Archetype Plugin, version 3.0.1.

In short, Archetype is a Maven project templating toolkit. An archetype is defined as an original pattern or model from which all other things of the same kind are made. The names fits as we are trying to provide a system that provides a consistent means of generating Maven projects. Archetype will help authors create Maven project templates for users, and provides users with the means to generate parameterized versions of those project templates.

http://maven.apache.org/archetype/maven-archetype-plugin/index.html

You should specify the version in your project’s plugin configuration:

1
2
3
4
5
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-archetype-plugin</artifactId>
  <version>3.0.1</version>
</plugin>

You can download the appropriate sources etc. from the download page.

Apache Maven 3.5.0 Release

| Comments

The Apache Maven team would like to announce the release of Apache Maven 3.5.0.

You can download the appropriate sources etc. from the download page.

Notable changes

  • ANSI colors added to the console output
  • Fix various bugs in mvn scripts regarding spaces, quotations, special characters, etc. also in combination with .mvn/ -files
  • Switch from Eclipse Aether to Maven Artifact Resolver

What happened to Maven 3.4.0?

After Maven 3.3.9 was released, the Eclipse Aether project was retired and the code base was migrated to the Apache Maven project.

The original goal for the 3.4.0 release was to replace Aether with the exact same code after migration to the Apache Maven project and then proceed with bug fixes to the resolver code as well as other areas of Maven.

The migration of the code between the two foundations took longer than expected and as a result there were other changes committed to Maven core that were outside the scope of intent for 3.4.0.

In order to refocus on the original intent for 3.4.0, the decision was taken to revert the Maven core history to the point of the 3.3.9 release and merge in the desired changes one at a time.

Because there had been a lot of communication about different features being delivered and bugs fixed in Maven 3.4.0 and the new history may not contain them in the first release, the decision was taken to forever burn the 3.4.x release line.

More detail on this decision can be read in the mailing list archive1.

Maven: POM Files Without a Version in It?

| Comments

In Maven 3.2.5 a feature has been introduced to be able to define a version of a Maven project via properties ${revision}, ${sha1} and ${changelist} which unfortuantely had some issues. Those issues have been fixed with Maven 3.5.0-beta-1 and now you can define the version of a project by using the following properties: ${revision}, ${sha1} and ${changelist}. The example below will show one usage of this:

1
2
3
4
5
6
7
8
9
10
11
12
  ..
  <parent>
    <groupId>com.soebes.smpp</groupId>
    <artifactId>smpp</artifactId>
    <version>2.2.1</version>
  </parent>

  <groupId>com.soebes.examples.j2ee</groupId>
  <artifactId>parent</artifactId>
  <version>${revision}</version>
  <packaging>pom</packaging>
  ..

For the simplicity of this example I use only ${revision} but in practice you could combine the different properties.

The above is a parent of a larger multi module build which contains serveral childs which look like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.soebes.examples.j2ee</groupId>
    <artifactId>parent</artifactId>
    <version>${revision}</version>
  </parent>

  <artifactId>service</artifactId>
  <dependencies>
    <dependency>
      <groupId>com.soebes.examples.j2ee</groupId>
      <artifactId>service-client</artifactId>
      <version>${project.version}</version>
    </dependency>
    ...

   ..

Based on the above you can now build your project simply by using the following:

1
mvn -Drevision=1.0.0-SNAPSHOT clean package

So there is no need to change the pom files and check them in. But there exists a drawback. You need to define the -Drevision=... for each call of Maven which is not very convenient.

Starting with Maven 3.3.1 you can configure Maven command line parameters in a .mvn/maven.config file which could contain the version definition like this:

1
-Drevision=1.0.0-SNAPSHOT

So with Maven 3.3.1+ you can now simply call Maven via:

1
mvn clean package

More convenient?

Hm… wait a second. What if i like to create a different version? Yes you need to change the .mvn/maven.config file and you should of course checkin the change into your vcs.

No. This is not really needed, but recommended. You can overwrite the version which is defined in the .mvn/maven.config via command line like this:

1
mvn clean package -Drevision=2.0.0-SNAPSHOT

What kind of alternatives exist? You can of course define your version of your project as a property within your pom file itself.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  ..
  <parent>
    <groupId>com.soebes.smpp</groupId>
    <artifactId>smpp</artifactId>
    <version>2.2.1</version>
  </parent>

  <groupId>com.soebes.examples.j2ee</groupId>
  <artifactId>parent</artifactId>
  <version>${revision}</version>
  <packaging>pom</packaging>
  ..
  <properties>
    ...
    <revision>2.5.0-SNAPSHOT</revision>
  </properties>

So this means you do not need to have a supplemental file in your project (like .mvn/maven.config) if you not already have. Also for this property means you can overwrite it via command like this:

1
mvn clean package -Drevision=1.8.67-SNAPSHOT

Deployment

But now let us come to an important point of this whole story. What happens if you do an deploy of such things via:

1
mvn clean deploy -Drevision=1.8.67-SNAPSHOT

The result in your repository will be having pom files which contain ${revision} which is simply not correct and can cause other issues.

How to solve this problem? This can simply being achieved by using the flatten-maven-plugin and adding the following part to your pom file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>flatten-maven-plugin</artifactId>
      <version>1.0.0</version>
      <configuration>
        <updatePomFile>true</updatePomFile>
      </configuration>
      <executions>
        <execution>
          <id>flatten</id>
          <phase>process-resources</phase>
          <goals>
            <goal>flatten</goal>
          </goals>
        </execution>
        <execution>
          <id>flatten.clean</id>
          <phase>clean</phase>
          <goals>
            <goal>clean</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

By using the above you can now simply do a deploy via:

1
mvn clean deploy -Drevision=1.8.67-SNAPSHOT

and the resulting pom file within the repository will correctly contain the resolved version 1.8.67-SNASPHOT.

This makes it easy to change the version from within a CI/CD tool. For example in Jenkins you can add a parameter like this:

1
mvn clean package -Drevision=1.0-${BUILD_NUMBER}-SNAPSHOT

Or make more sophisticated combinations of the properties ${revision}, ${sha1} and ${changelist}.

Conclusion

In the end you are not able to completely ban the versions from your pom file but nearly 100% which means you do not need to repeat it in each of your parent entries in a multi module build.

Furthermore you have saved a lot of issues related to merge conflicts within branches in Maven builds caused by the different version number for the different branches, cause the version can simply being defined by the CI/CD solution or manually from command line.