maven profile

1、执行:mvn -P[profile_id]
2、激活activation

<project>
  
  
<profiles>
    
<profile>
      
<id>dev</id>
      
<activation>
        
<activeByDefault>false</activeByDefault>
        
<jdk>1.5</jdk>
        
<os>
          
<name>Windows XP</name>
          
<family>Windows</family>
          
<arch>x86</arch>
          
<version>5.1.2600</version>
        
</os>
        
<property>
          
<name>mavenVersion</name>
          
<value>2.0.5</value>
        
</property>
        
<file>
          
<exists>file2.properties</exists>
          
<missing>file1.properties</missing>
        
</file>
      
</activation>
      
    
</profile>
  
</profiles>
</project>

3.当使用属性激活的时候
<profiles>
        
<profile>
            
<id>test</id>
            
<activation>
                
<property>
                    
<name>test.bingo</name>
                    
<value>kkk</value>
                
</property>
            
</activation>
</profile>
</profiles>

可以在命令行中mvn -Dtest.bingo=kkk或者mvn -Ptest这两种方式激活该profile对pom设置的进行覆盖。

4.当使用变量替换的时候
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation
="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    
    
<build>
        
<resources>
            
<resource>
              
<directory>src/main/filter-resources</directory>
              
<filtering>true</filtering>
            
</resource>
        
</resources>

    
</build>
    
<profiles>
        
<profile>
            
<id>test</id>
            
<activation>
                
<property>
                    
<name>test.bingo</name>
                    
<value>kkk</value>
                
</property>
            
</activation>
            
<properties>
                
<env.dir>222</env.dir>
            
</properties>
            
<build>
                        
</profile>
    
</profiles>
</project>

过滤指定的目录下文件,如果该文件中有${env.dir}的变量,就会被222给覆盖掉。

posted on 2009-07-13 13:15 andy.kong 阅读(1534) 评论(2)  编辑  收藏 所属分类: maven

评论

# re: maven profile 2009-11-16 18:02 Shouling

是bingo吗?  回复  更多评论   

# re: maven profile[未登录] 2009-11-16 18:22 andy

@Shouling
这里的bingo只是一个字符串命名,没有其他含义  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 

公告

师者,所以传道授业解惑也!

导航

<2009年11月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

统计

常用链接

留言簿

随笔分类

随笔档案

文章档案

搜索

最新评论

阅读排行榜

评论排行榜