Maven动态插件配置
我在POM中有这样的内容:Maven动态插件配置,maven,maven-profiles,Maven,Maven Profiles,我在POM中有这样的内容: <profile> <id>profile1</id> <build> <resources> .... </resources> <plugins> <plugin>
<profile>
<id>profile1</id>
<build>
<resources>
....
</resources>
<plugins>
<plugin>
<configuration>
....plugin1 configuration.....
</configuration>
</plugin>
<plugin>
<configuration>
....plugin2 configuration.....
<configEntry1></configEntry1>
<configEntry2></configEntry1>
</configuration>
</plugin>
</plugins>
</build>
</profile>
和简介2:
<profile>
<id>profile2</id>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<identifier>fxApplication</identifier>
<appName>AppName</appName>
<mainClass>package.Main</mainClass>
<nativeReleaseVersion>${jfx.version}</nativeReleaseVersion>
<jfxMainAppJarName>jarName.jar</jfxMainAppJarName>
<deployDir>${basedir}/deploy</deployDir>
<updateExistingJar>true</updateExistingJar>
<manifestAttributes>
<JavaFX-Feature-Proxy>None</JavaFX-Feature-Proxy>
<Implementation-Vendor>vendor</Implementation-Vendor>
<Implementation-Title>Title</Implementation-Title>
<Main-Class>package.Main</Main-Class>
<JavaFX-Version>2.0</JavaFX-Version>
<JavaFX-Application-Class>package.Main</JavaFX-Application-Class>
<Created-By>Company</Created-By>
</manifestAttributes>
<additionalAppResources>${basedir}/target/jfx/externalResources</additionalAppResources>
</configuration>
<executions>
<execution>
<id>create-jfxjar</id>
<phase>package</phase>
<goals>
<goal>build-jar</goal>
</goals>
</execution>
<execution>
<id>create-native</id>
<phase>package</phase>
<goals>
<goal>build-native</goal>
</goals>
</execution>
</executions>
</plugin>
</profile>
简介2
com.zenjava
javafxmaven插件
8.8.3
FX应用程序
AppName
包.主
${jfx.version}
jarName.jar
${basedir}/deploy
真的
没有一个
小贩
标题
包.主
2
包.主
单位
${basedir}/target/jfx/externalResources
创建jfxjar
包裹
构建jar
创建本地
包裹
构建本地
区别在于profile2没有
如何重用99%的xml脚本?当然,您可以声明,但也可以同时激活多个配置文件。创建一个包含所有通用声明的
all
,以及扩展此声明的其他声明,例如WinUnix
,其中包含
然后,对于Mac构建:
mvn ... -P all ...
对于Windows/Unix版本:
mvn ... -P all,WinUnix ...
您还可以使用反向逻辑,或将其与.结合使用,以解决您的具体示例—我建议对jvmargs使用a。例如,这里有一个简单的POM,它在构建期间打印一条消息:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>maven-profiles</groupId>
<artifactId>maven-profile-artifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<specialMessage>This is the default value</specialMessage>
</properties>
<profiles>
<profile>
<id>profile1</id>
<properties>
<specialMessage>This comes from profile1</specialMessage>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>${specialMessage}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
4.0.0
maven剖面图
同样,如果您有一个更复杂的场景,比如说您需要为一个构建指定不同的插件,那么您可以创建多个概要文件并激活多个概要文件。这样,您的通用插件和配置可以放在一个概要文件中,而特定于特定环境/场景的元素可以放在另一个概要文件中
希望这有帮助 您知道某个配置文件可以由特定的操作系统激活吗?请参阅“感谢您的评论”,但我对配置文件激活不感兴趣,我对配置重用或配置对属性的依赖感兴趣问题是真正需要配置的目的是什么,哪些配置部分是不同的…或者换句话说,哪些配置部分是所有配置的一部分,哪些是特殊的。。。这里是jvm参数-->在一种情况下我需要指定参数在另一种情况下不应指定参数
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>maven-profiles</groupId>
<artifactId>maven-profile-artifact</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<specialMessage>This is the default value</specialMessage>
</properties>
<profiles>
<profile>
<id>profile1</id>
<properties>
<specialMessage>This comes from profile1</specialMessage>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>${specialMessage}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>