传递依赖和条件简档

时间:2014-10-16 18:21:26

标签: java maven-3 maven-plugin

我在不同的git存储库和不同的反应器中创建了两个maven插件。 为了确保两者都使用相同的插件和依赖版本,两者都使用我们的公司pom作为其父级。

在那个父pom中我创建了一个新的条件配置文件(专用于maven插件),它由文件的存在激活。在那里我添加了dependencyManagement标签:

<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>
... 

在插件中,我有一个依赖标签,如下所示:

 <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>
 ....

两个插件都正在构建,因为它们都包含所需的激活文件。

但是我在其他项目中使用这些插件时遇到错误:

[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]

似乎没有激活配置文件,并且根本没有考虑dependencyManagement。

有没有办法指示maven考虑在父项目的条件配置文件中设置的依赖项?

0 个答案:

没有答案
相关问题