【问题标题】:How do I activate a Maven profile if a file does NOT exist?如果文件不存在,如何激活 Maven 配置文件?
【发布时间】:2015-08-19 08:55:32
【问题描述】:

我使用的是 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>

【问题讨论】:

    标签: maven maven-3 profile file-exists


    【解决方案1】:

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

    <missing>${basedir}/src/main/myfile</missing>
    

    【讨论】:

      猜你喜欢
      • 2011-11-12
      • 2014-10-29
      • 2019-11-02
      • 2018-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-04
      • 1970-01-01
      相关资源
      最近更新 更多