0

I'm creating two maven plugins in different git repositories and different reactors. in order to ensure both are using same plugins and dependencies versions both are using our corporate pom as its parent.

in that parent pom I created a new conditional profile (exclusive for maven plugins) that is activated by the presence of a file. there I added a dependencyManagement tag:

<profile>
            <id>whenIsMavenPluginProject</id>
            <activation>
                <file>
                    <exists>.releng.mplugin</exists>
                </file>
            </activation>
            ....
            <dependencyManagement>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven</groupId>
                        <artifactId>maven-plugin-api</artifactId>
                        <version>3.2.3</version>
                    </dependency>
... 

In the plugins I have a dependency tag like the below:

 <dependencies>
    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-plugin-api</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.maven.plugin-tools</groupId>
        <artifactId>maven-plugin-annotations</artifactId>
        <scope>provided</scope>
    </dependency>
 ....

Both plugins are being built properly since both contains the needed activation file.

But I'm getting an error when using these plugins in other projects:

[ERROR] Internal error: java.lang.RuntimeException: org.apache.maven.MavenExecutionException: Could not setup plugin ClassRealm: Plugin org.c4biz.tools.maven.indexer:org.c4biz.tools.maven.indexer.plugin:0.2.1-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.c4biz.tools.maven.indexer:org.c4biz.tools.maven.indexer.plugin:jar:0.2.1-SNAPSHOT: 6 problems were encountered while building the effective model for org.c4biz.tools.maven.indexer:org.c4biz.tools.maven.indexer.plugin:0.2.1-SNAPSHOT
[ERROR] [ERROR] 'dependencies.dependency.version' for org.apache.maven:maven-plugin-api:jar is missing. @
[ERROR] [ERROR] 'dependencies.dependency.version' for org.apache.maven.plugin-tools:maven-plugin-annotations:jar is missing. @
[ERROR] [ERROR] 'dependencies.dependency.version' for org.apache.maven:maven-core:jar is missing. @
[ERROR] [ERROR] 'dependencies.dependency.version' for org.codehaus.plexus:plexus-utils:jar is missing. @
[ERROR] [ERROR] 'dependencies.dependency.version' for org.codehaus.plexus:plexus-interpolation:jar is missing. @
[ERROR] [ERROR] 'dependencies.dependency.version' for org.apache.maven:maven-archiver:jar is missing. @
[ERROR] -> [Help 1]

seems that the profile is not being activated and dependencyManagement is not being considered at all.

is there any way to instruct maven to consider the dependencies set inside a conditional profile of a parent project?

Cristiano
  • 1,414
  • 15
  • 22
  • @Brian, it was a composed paste. I fix it. thanks – Cristiano Oct 16 '14 at 18:29
  • Just saw your edit. My answer doesn't apply with your edit so I deleted it. Sorry, not sure how to fix it. – Brian Oct 16 '14 at 18:37
  • I don't understand why you need a profile for dependencyManagement? dependencyManagement is intended to define versions of dependencies **BUT** it does not define those dependencies as real dependencies. This happens at the time you use `dependencies´. – khmarbaise Oct 16 '14 at 21:54
  • @khmarbaise, the profile doesn't has only dependencyManagement. it contains common dependencies and also some common plugins used only for our plugins. I'm mention only it because the issue seems to be related to it and profiles. – Cristiano Oct 16 '14 at 22:28
  • why don't you take the depenencyManagement out of the profile and define only the common plugins and dependencies in the profile? – coderplus Oct 19 '14 at 06:58

0 Answers0