my test name
src/main/resources true
org.apache.maven.plugins maven-resources-plugin 3.0.1
\\
指定\\, 说明\\${}的è${},其它照样替换
Hello\\${name}jest.urls=${name}
(1) 执⾏mvn resources:resourcesè
Hello ${name}jest.urls=my testname
(2) 执⾏mvn installè
Hello ${name}jest.urls=my testname
根据id在不同环境下打对应参数
src/main/resources true
org.apache.maven.plugins maven-resources-plugin 3.0.1
\\
dev http://n2:9200,http://n4:9200
true
production http://192.168.3.241:9200,http://192.168.3.242:9200
mvn clean package-DskipTests -Pdevè
Hello\\${jest.urls}
jest.urls=http://n2:9200,http://n4:9200
mvn clean package-DskipTests -Pproductionè
Hello\\${jest.urls}
jest.urls=http://192.168.3.241:9200,http://192.168.3.242:9200
⾃定义过滤器 Custom resources filters
With version 2.5 you are now able to build your own customresources filter(s).Your custom resources filter classes must implements .CustomResources Filter Implementation
Your custom resources filter classes must be marked as aPlexus Component. Below a sample with a roleHint itFilter.
1. /**
2. * @plexus.component role=\"org.apache.maven.shared.filtering.MavenResourcesFiltering\" 3. * role-hint=\"itFilter\"4. */
5. public class ItFilter
6. implements MavenResourcesFiltering
Then you must activate in your build the mojo which willscan javadoc annotations to transform thoses to plexus component metadata.
1. 2. org.codehaus.plexus3. plexus-maven-plugin4. 1.3.45. 6. 7. 8. descriptor9.
10. 11. 12.
Dependencydeclaration
Your classes must be available in the maven-resources-pluginclasspath, this can be done with adding your artifact to theplugindependencies.
1. 2. ...3. 4. 5. 6. org.apache.maven.plugins7. maven-resources-plugin8. 3.1.09. 10. ...11.
12. 13. 14. custom resources filters artifact groupId15. custom resources filters artifact artifactId16. custom resources filters artifact version17.
18.
19.
20. 21. ...22. 23. ...24.
Useof your Custom Resource Filter with the maven-resources-plugin
You must now declare you custom filter in the plugin.mavenFilteringHint must respect same syntax as your Plexus Component roleHint.
1. 2. org.apache.maven.plugins3. maven-resources-plugin4. 3.1.05. 6. ...7. 8. itFilter9.
10.
11. ...
12. 13.