2013-09-06 7 views
13

コンパイラの引数をMavenに渡す方法はありますか?私はcompiler-pluginに指定することができますが、コマンドラインからXlintを実行したいと思います。だから、私は何かを試しましたXlintでMavenプロジェクトをコンパイルする方法

mvn clean install -DskipTests=true -DcompilerArgument=-Xlint:deprecation 

しかし成功しませんでした。

答えて

18

あなたはこのようなコンパイラプラグイン定義することができます:あなたは-DcompilerArgumentを渡さない場合、それが原因でビルドを壊さない

mvn -DcompilerArgument=-Xlint:deprecation compile 

:コマンドラインからパラメータを渡すその後

<plugin> 
    <artifactId>maven-compiler-plugin</artifactId> 
    <configuration> 
     <compilerArgument>${compilerArgument}</compilerArgument> 
    </configuration> 
</plugin> 

をコンパイラプラグイン引数の 'compilerArgument'は空で無視されます。この具体的な場合(非推奨の警告)について

+0

私は 'pom.xml'をそのままにしておきたいので、デフォルトのパラメータがあることを期待していました。しかし、素晴らしい回避策、ありがとう –

+0

残念なことに、追加の引数のための['compile:compile'パラメータ](http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#Parameter_Details)にはデフォルトのユーザープロパティ – Joe

22

は、実際property which can be used from the command lineある:

mvn clean install -Dmaven.compiler.showDeprecation=true 

compilerArgument溶液に反していない場合にのみ、Mavenのプロセス内コンパイラを使用する場合、これも動作しますfork = trueを使用します。

同様に有用な特性は、maven.compiler.showWarningsです。

+0

ありがとう、本当にいいね –

関連する問題