如果文件不存在,如何激活 Maven 配置文件?

2024-01-13

我使用的是 Maven 3.2.3。如果文件系统上不存在文件,如何激活配置文件?我尝试过以下方法,但发现<not>不支持语法:

            <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>

See http://maven.apache.org/ref/3.3.3//maven-model/maven.html#class_file http://maven.apache.org/ref/3.3.3//maven-model/maven.html#class_file

<missing>${basedir}/src/main/myfile</missing>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如果文件不存在,如何激活 Maven 配置文件? 的相关文章

随机推荐