6
我使用的是Maven 3.0.3。我對Maven配置文件激活中的「activeByDefault」標誌感到困惑。我想要的是擁有一個默認配置文件,但如果某人指定了另一個配置文件(例如-P其他配置文件),則默認配置文件的內部版本中的任何插件都不會運行。而且,如果有人規定:如何在我的Maven默認配置文件中運行插件,但是如果指定了其他配置文件,請阻止這些插件運行?
mvn clean install
從默認的配置文件就會運行該插件,但在其他配置文件的插件將無法運行。但是,即使我在命令行上指定了不同的配置文件(通過「-P other」),默認配置文件中的插件也會始終運行。這裏是我有什麼,如果另一個配置文件中指定,但只能是其他配置文件在同一POM指定
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<!-- Prepare liquibase scripts to run against the test db. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<dependencies>
<dependency>
<groupId>org.mainco.subco</groupId>
<artifactId>database</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>unzip-liquibase-archive</id>
<phase>process-test-resources</phase>
<configuration>
<target>
<echo message="unzipping liquibase archive" />
<unzip
src="${user.home}/.m2/repository/org/mainco/subco/database/${project.version}/database-${project.version}.jar"
dest="${project.build.directory}" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<!-- Replace relative references in liquibase file with absolute ones. -->
<execution>
<id>format-liquibase-files</id>
<phase>process-test-resources</phase>
<configuration>
<target>
<replace token='include file="'
value="include file="${project.build.directory}/" file="target/db.changelog-master.xml" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Run the liquibase scripts -->
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>2.0.1</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>build-database</id>
<phase>process-test-resources</phase>
<configuration>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://${test.mysql.db.host}:${test.mysql.db.port}/${test.mysql.db.sid}</url>
<username>${test.mysql.db.user}</username>
<password>${test.mysql.db.password}</password>
<changeLogFile>${project.build.directory}/db.changelog-master.xml</changeLogFile>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
...
</profiles>
奇怪的是,有了maven我覺得像使用cmd.exe,你可以做的東西,但不希望任何一致性或常識:/ – akostadinov 2014-01-25 09:16:11