1

私は自分のpomにこの構成を持っています

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <excludes>                      
            <exclude>**/logging/*</exclude>
            <exclude>**/config/*</exclude>
        </excludes>
    </configuration>
</plugin>

プロファイルを使用して、ローカル環境から実稼働環境までのさまざまな動作を処理します。ローカル プロファイルで mvn install を実行するときに、除外をアクティブにしないことはできますか? このようにローカル環境で空白のプロパティを設定しようとしましたが、プラグインが文句を言います。

4

3 に答える 3

1

これは回避策であり、より良い解決策が存在する可能性があります。最も簡単な方法は、DEV 環境を jar プラグインの構成から解放することだと思います。次に、PROD 構成を専用のプロファイルに配置します。

<profiles>                                                         
    <profile>                                                      
        <id>PROD</id>                                              
        <build>                                                    
            <plugins>                                              
                <plugin>                                           
                    <groupId>org.apache.maven.plugins</groupId>    
                    <artifactId>maven-jar-plugin</artifactId>      
                    <version>2.2</version>                         
                    <configuration>                                
                        <excludes>                                 
                            <exclude>**/logging/*</exclude>        
                            <exclude>**/config/*</exclude>         
                        </excludes>                                
                    </configuration>                               
                </plugin>                                          
            </plugins>                                             
        </build>                                                   
    </profile>                                                     
</profiles>  

プロダクション jar をビルドする必要がある場合は、次を起動します。

mvn clean install -PPROD
于 2012-09-07T12:19:26.060 に答える
0

私が見つけた最善の回避策は、DEV環境で実行するときに無効な値を使用してフィルタリングすることです。

<profiles>
    <profile>
        <id>env-local</id>
        <activation>
            <property>
                <name>env</name>
                <value>local</value>
            </property>
        </activation>
        <properties>
            <jndi.iban0>cont0Data</jndi.iban0>
            <config.file.path>classpath:config</config.file.path>
            <logging.file.path>classpath:logging</logging.file.path>
            <exclude.logging>none</exclude.logging>
            <exclude.config>none</exclude.config>
        </properties>
    </profile>
</profiles>
于 2012-09-14T15:00:17.617 に答える
0

ロギングおよび構成ファイルのリソースはテスト専用ですか? はいの場合は、 に入れます${basedir}/src/test/resources。それらはテストのクラスパスにありますが、最終的な jar にはなりません。また、特定の jar プラグイン構成は必要ありません。

于 2012-09-07T13:21:43.130 に答える