问题
I’m using Maven 3.2.3. How do I activate a profile if a file does NOT exist on the file system? I have tried the below, but discovered that the <not>
syntax isn’t supported:
<profile>
<id>create-test-mysql-props-file</id>
<activation>
<file>
<not><exists>${basedir}/src/main/myfile</exists></not>
</file>
</activation>
<build>
<plugins>
<!-- Generate mysql datasource properties -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>write-project-properties</goal>
</goals>
<configuration>
<outputFile>
${project.build.outputDirectory}/mysql_datasource.properties
</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
回答1:
See http://maven.apache.org/ref/3.3.3//maven-model/maven.html#class_file
<missing>${basedir}/src/main/myfile</missing>
来源:https://stackoverflow.com/questions/30649044/how-do-i-activate-a-maven-profile-if-a-file-does-not-exist