2016-07-05 3 views
2

私は2つのMavenプロファイルP1とP2を持っています。私がしたいのは、自分のプロジェクトをビルドするために使用するプロファイルによっては、特定のリソースを除外する必要があるということです。例えばMavenでプロファイルごとにクラスやリソースを除外(またはインクルード)することはできますか?

<profiles> 
    <profile> 
     <id>P1</id> 
     <properties> 
      <app.home>Path to project home</app.home> 
      <exclude>src/main/java/foo/*.*</exclude> <!-- need to exclude all files in src/main/java/foo in this profile --> 
     </properties> 
    </profile> 
    <profile> 
     <id>P2</id> 
     <properties> 
      <app.home>Path to project home</app.home> 
      <exclude>src/main/java/bar/*.*</exclude> <!-- need to exclude all files in src/main/java/bar in this profile--> 
     </properties> 
    </profile> 
</profiles> 

だから、ここで私が何をしたいのか、私はP1プロファイルを使用して構築し、SRC /メイン内のすべてのファイルを除外するときのsrc /メイン/ javaの/ fooの/内のすべてのファイルを除外することです私はP2のプロファイルを使用してビルド/ java/bar。

これは可能ですか?そうでない場合は何もありませんか?

+0

あなたはマルチモジュールのビルドを有することを意味する二つの別々のモジュールを使用する必要がありますを参照してください。これは懸念の分離に違反しているためです。 – khmarbaise

答えて

2

あなたのプロフィールにMaven Compiler Pluginbuildを追加して、例えばそこに

excludeを追加することができます

<profile> 
    <id>P1</id> 
    <properties> 
     <app.home>Path to project home</app.home> 
    </properties> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
       <excludes> 
        <exclude>**src/main/java/foo/*.*</exclude> 
       </excludes> 
      </configuration> 
     </plugin> 
    </plugins> 
</profile> 

は、追加情報Maven: excluding java files in compilation

関連する問題