How do I activate a Maven profile if a file does NOT exist?

安稳与你 提交于 2020-02-25 10:16:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!