如何在 pom.xml 中配置 mvn dependency:analyze
How to configure mvn dependency:analyze in the pom.xml
我想从命令行使用 mvn dependency:analyze
手动检查依赖项问题。问题是我找不到在 pom.xml
中配置行为的方法。必须在命令行中提供所有参数。
所以我必须一直使用
mvn dependency:analyze -DignoreNonCompile
我缺少的是在插件配置的 pom.xml
中设置 ignoreNonCompile
的方法。
像这样:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze</goal>
</goals>
<configuration>
<ignoreNonCompile>true</ignoreNonCompile>
</configuration>
</execution>
</executions>
</plugin>
但这行不通。
如果我使用
<goal>analyze-only</goal>
然后构建时插件是运行,使用配置。但我不想在构建中包含它 运行,只能手动请求。并且 运行ning 手动不会接受该参数。
我可以在名为 ignoreNonCompile
的 pom.xml
中设置一个 属性,但这将在构建中设置此参数并手动 运行ning。
有没有办法只配置 mvn dependency:analyze
的行为?
问题是您在 <execution>
块中设置配置。这意味着配置将仅绑定到该特定执行;但是,在命令行 mvn dependency:analyze
上调用时,它不会调用该执行。相反,它将使用默认全局配置以默认执行调用插件。
ignoreNonCompile
是该插件的有效配置元素。您必须使用
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoreNonCompile>true</ignoreNonCompile>
</configuration>
</plugin>
如果你不想像上面那样为所有执行定义全局配置,你可以保留你的执行特定配置,但你需要告诉 Maven to explicitely run that execution :
mvn dependency:analyze@analyze
其中analyze
是执行id:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id> <!-- execution id used in Maven command -->
<goals>
<goal>analyze</goal>
</goals>
<configuration>
<ignoreNonCompile>true</ignoreNonCompile>
</configuration>
</execution>
</executions>
</plugin>
我想从命令行使用 mvn dependency:analyze
手动检查依赖项问题。问题是我找不到在 pom.xml
中配置行为的方法。必须在命令行中提供所有参数。
所以我必须一直使用
mvn dependency:analyze -DignoreNonCompile
我缺少的是在插件配置的 pom.xml
中设置 ignoreNonCompile
的方法。
像这样:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze</goal>
</goals>
<configuration>
<ignoreNonCompile>true</ignoreNonCompile>
</configuration>
</execution>
</executions>
</plugin>
但这行不通。
如果我使用
<goal>analyze-only</goal>
然后构建时插件是运行,使用配置。但我不想在构建中包含它 运行,只能手动请求。并且 运行ning 手动不会接受该参数。
我可以在名为 ignoreNonCompile
的 pom.xml
中设置一个 属性,但这将在构建中设置此参数并手动 运行ning。
有没有办法只配置 mvn dependency:analyze
的行为?
问题是您在 <execution>
块中设置配置。这意味着配置将仅绑定到该特定执行;但是,在命令行 mvn dependency:analyze
上调用时,它不会调用该执行。相反,它将使用默认全局配置以默认执行调用插件。
ignoreNonCompile
是该插件的有效配置元素。您必须使用
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<ignoreNonCompile>true</ignoreNonCompile>
</configuration>
</plugin>
如果你不想像上面那样为所有执行定义全局配置,你可以保留你的执行特定配置,但你需要告诉 Maven to explicitely run that execution :
mvn dependency:analyze@analyze
其中analyze
是执行id:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id> <!-- execution id used in Maven command -->
<goals>
<goal>analyze</goal>
</goals>
<configuration>
<ignoreNonCompile>true</ignoreNonCompile>
</configuration>
</execution>
</executions>
</plugin>