How do I execute a set of goals before my Maven plugin runs?

You can do this by defining a custom lifecycle and invoking that lifecycle before your Mojo is executed via the execute annotation. In your Mojo, declare in the Javadoc the lifecycle to be executed: /** * Invoke the custom lifecycle before executing this goal. * * @goal my-goal * @execute lifecycle=”my-custom-lifecycle” phase=”process-resources” */ public class … Read more

Using Maven for C/C++ projects

I highly recommend the maven-nar-plugin. I find it superior in many ways to the alternatives. It doesn’t require listing out source files, handles multiple OSes and architectures, handles unit and integration tests, and generally follows “the maven way”. It introduces a new kind of packaging – the NAR, or “native archive”, that contains the artifact … Read more

Maven 3 warnings about build.plugins.plugin.version

Add a <version> element after the <plugin> <artifactId> in your pom.xml file. Find the following text: <plugin> <artifactId>maven-compiler-plugin</artifactId> Add the version tag to it: <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> The warning should be resolved. Regarding this: ‘build.plugins.plugin.version’ for org.apache.maven.plugins:maven-compiler-plugin is missing Many people have mentioned why the issue is happening, but fail to suggest a fix. All … Read more

Unsupported major.minor version 52.0 in my app

I face this problem too when making new project from android studio. I’ve been able to resolve this by downgrading buildToolsVersion in app gradle setting: change {module-name}/build.gradle line buildToolsVersion “24.0.0 rc1” to buildToolsVersion “23.0.3” @Edit: In Android Studio 2.1 Go to File-> Project Structure->App -> Build Tool Version. Change it to 23.0.3 Do the method … Read more

How do I create a new packaging type for Maven?

To do as you described, create a Maven project with packaging jar (as stated here, as there won’t be mojo definitions). In the src/main/resources/META-INF/plexus sub-folder create a components.xml with the following contents (assuming you want the packaging type to be “my-custom-type”, change it to “foobar” if you wish). <component-set> <components> <component> <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role> <role-hint>my-custom-type</role-hint> <implementation> org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping … Read more

Maven assembly : add different version of the same artifact

I found a solution by using maven-dependency-plugin to copy resolved pom dependencies and additional jar. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.1</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> <overWriteReleases>false</overWriteReleases> <overWriteSnapshots>false</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> <includeScope>runtime</includeScope> </configuration> </execution> <execution> <id>copy-model</id> <phase>package</phase> <goals> <goal>copy</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>my.test.pkg</groupId> <artifactId>my-model</artifactId> <classifier>server</classifier> <version>1.0.3</version> <type>jar</type> </artifactItem> <artifactItem> <groupId>my.test.pkg</groupId> <artifactId>my-model</artifactId> <classifier>server</classifier> <version>1.1.0</version> <type>jar</type> … Read more

How to get access to Maven’s dependency hierarchy within a plugin

The dependency plugin has the tree goal that does most of this work. It processes a MavenProject using the DependencyTreeBuilder, this returns a DependencyNode with hierarchical information about the resolved dependencies (and their transitive dependencies). You can copy much of the code directly from the TreeMojo. It uses the CollectingDependencyNodeVisitor to traverse the tree and … Read more