Hi.
I'm using a pretty large maven tree, and I ran into two problems when
trying to configure plugins at the top level project.
These two problems are related to the fact that I wanted the plugins to
be executed only on "jar" packaging projects, and not on "pom" packaging
projects, but didn't know how to do it (or if it is possible at all).
The problems are:
(1) I tried to configure a jar obfuscation plugin at top-level
project. Here is what I did:
<project ...>
...
<artifactId>project</artifactId>
<name>project</name>
<packaging>pom</packaging>
<modules>
*LOTS* of modules goes here...
</modules>
<build>
<plugins>
<plugin>
<groupId>some.group</groupId>
<artifactId>some-obfuscation-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>obfuscate</goal>
</goals>
</execution>
</executions>
<configuration>
<injar>${project.build.finalName}.jar</injar>
<outjar>${project.build.finalName}-obf.jar</outjar>
*LOTS* of additional configurations goes here...
</configuration>
...
I wanted to use this single plugin configuration for all my projects.
The problem was that I got an IO Exception since the top-level
project.jar didn't exist (obviously...).
What I really wanted was to execute this plugin only on
<packaging>jar</packaging> poms, and not on
<packaging>pom</packaging> poms.
To have this plugin working, I sadly moved this configuration to the
pluginmanagement section, and added:
<plugin>
<groupId>some.group</groupId>
<artifactId>some-obfuscation-plugin</artifactId>
</plugin>
To each one of my leaf jar projects.
(2) Now, I wanted to install and deploy the obfuscated jars. I had
the same problem, so I wanted to use the same solution. So I put the
following lines in the pluginmanagement section:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>install-obf</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>target/${project.build.finalName}-obf.jar</file>
<classifier>obf</classifier>
<version>${project.version}</version>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<packaging>jar</packaging>
</configuration>
</execution>
</executions>
</plugin>
But this solution didn't work for me this time, since the
"maven-install-plugin" was executed on my top-level pom project anyway,
and the result was:
Error installing artifact: File
C:\development\java\branches\2.8.4\project\target\project-2.8.4-obf.jar
does not exist
I wouldn't want to copy this plugin long definition to each one of my
leaf "jar" projects, but I don't see how I can use the inheritance on
such cases.
* Is there a way I can specify that I want to execute these
plugins only on "jar" projects, and not on "pom" projects?
* Is there a different elegant solution to this problem?
Thanks,
Michal.