Java 条件替换maven
在使用com.google.code.maven-replacer-plugin编译工件时,我曾经将log4j.properties文件中的日志级别从“DEBUG”替换为“WARN”,如下所示:Java 条件替换maven,java,maven,replace,conditional,Java,Maven,Replace,Conditional,在使用com.google.code.maven-replacer-plugin编译工件时,我曾经将log4j.properties文件中的日志级别从“DEBUG”替换为“WARN”,如下所示: <plugin> <groupId>com.google.code.maven-replacer-plugin</groupId> <artifactId>replacer</artifactId>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${project.build.outputDirectory}/com/myCompany/MyApp/app/log4j.properties</file>
<replacements>
<replacement>
<token>DEBUG</token>
<value>WARN</value>
</replacement>
</replacements>
</configuration>
</plugin>
com.google.code.maven-replacer-plugin
替代者
1.5.3
准备包装
代替
${project.build.outputDirectory}/com/myCompany/MyApp/app/log4j.properties
调试
警告
我现在想做的是根据工件是版本还是快照来替换日志级别。类似于“如果${version}以RELEASE replace结尾,则保持调试级别”。
有办法做到这一点吗?有
maven release plugin
启用release配置文件
配置文件。因此,您可以在该配置文件中禁用执行maven replacer plugin
以防你不熟悉配置文件的工作原理
当然,如果您没有使用
maven release插件
或者不喜欢这个解决方案,您可以设置一个自定义配置文件,做您想做的事情。我想把关键字“SNAPSHOT”/“release”放进去“在属性中,将其附加到我的版本号。这将使我能够检查类似以下内容的属性:。但不知何故,我真的不太想进入ant,也不想为这样一个“小”任务获得更多插件。@Wingiw你的问题不清楚,请你描述清楚。@SubodhJoshi编辑了我的原始问题。希望这有帮助。谢谢你的快速回复,我会调查一下你的解决方案,如果我能让它工作,我会接受你的答案。