如果文件不存在,如何激活Maven配置文件? [英] How do I activate a Maven profile if a file does NOT exist?

查看:107
本文介绍了如果文件不存在,如何激活Maven配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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>

推荐答案

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

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

这篇关于如果文件不存在,如何激活Maven配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆