我以为我是一位经验丰富的Maven用户,但我对如何做到这一点有心理障碍!
我已经能够使用Maven插件SQL通过我已经定义并绑定插件处决下降,创建和安装一个架构在一个数据库pre-integration-test阶段.
不过,现在我想使用相同的SQL插件插入一些示例数据,每当我在命令行想要的 - 也就是说,没有绑定到任何生命周期的目标.有几组不同的样本数据,所以我想定义一些不同的执行.
但有没有办法通过使用执行ID从命令行运行其中一个执行?
我想使用maven enforcer插件检查我的路径上是否有重复的类.我从这里试过这个例子.
但当我这样运行时:
mvn enforcer:enforce
我明白了:
无法在项目datapopulator上执行目标org.apache.maven.plugins:maven-enforcer-plugin:1.0.1:enforce(default-cli):目标org.apache.maven.plugins的参数'rules':maven-enforcer -plugin:1.0.1:强制执行缺失或无效
有没有办法正确使用它?
编辑#1
如果将我的配置更改为:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<AlwaysPass />
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
产生相同的错误.
在Maven <plugin>元素中,有一个<executions>包含多个<execution>元素的元素.每个<execution>元素都可以包含一个<id>包含字符串的元素.什么参考这些<id>...</id>元素?省略该元素意味着什么?<id>元素的语义是什么?
例如:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar-execution</id>
<configuration>
<finalName>mainjar</finalName>
</configuration>
</execution>
<execution>
<id>extra-jar-execution</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<finalName>anotherjar</finalName>
</configuration>
</execution>
</exectutions>
</plugin>
[...]
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
什么引用了这些<id>default-jar-execution</id>和<id>extra-jar-execution</id>价值观?改变这些字符串的行为差异是什么?删除这些元素意味着什么?
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<id>generate-sei</id>
<configuration>
<sourceDestDir>${project.basedir}/src/main/java</sourceDestDir>
</configuration>
</execution>
</executions>
<dependencies>...</dependencies>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
上面的XML代码段来自Java项目中的POM文件。在此代码段中,我定义了jaxws-maven-plugin以使用wsdl文件生成SEI代码并将其放置在src / main / java目录中。此插件绑定到generate-sources阶段,并且工作正常。
我想这样做,以便如果我直接发布插件,请使用:
mvn jaxws:wsimport
Run Code Online (Sandbox Code Playgroud)
它应将文件放在上述文件夹中。从插件参考站点(https://jax-ws-commons.java.net/jaxws-maven-plugin/wsimport-mojo.html),我不知道如何将参数(sourceDestDir)作为命令传递行参数。有办法我可以做到吗?
我想用我的主要Java项目及其所有依赖项创建一个jar文件。所以我在pom文件中创建了以下插件定义:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- exclude junit, we need runtime dependency only -->
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
所以我执行mvn dependency:copy-dependencies,将所有的依赖复制到target/dependency而不是复制上很好dependency-jars。有任何想法吗?
我有一个Maven项目,其中包含一个Maven插件(Liquibase Maven插件),它暴露了不同的目标.其中两个目标(update和diff)需要不同的参数,它们之间存在冲突(因为两者的语义不同),所以我需要在两个目标执行中给Maven不同的属性.
这就是我所做的
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.4.1</version>
<!-- This configuration is used for every goal except "diff" -->
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>diff</goal>
</goals>
<!-- This configuration is used for the "diff" goal -->
<configuration>
<propertyFile>src/main/resources/liquibaseDiff.properties</propertyFile>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但是,此配置是错误的,因为对于每个目标(diff,更新其他目标),仅使用该liquibaseDiff.properties文件.
有没有办法在Maven中为不同的目标传递不同的配置?