NetBeans 7.2 では、Maven プロジェクトで -Xlint:unchecked を使用してコンパイルする方法を見つけるのに苦労しています。Ant プロジェクトでは、[プロジェクト プロパティ] -> [コンパイル] に移動してコンパイラ フラグを変更できますが、Maven プロジェクトにはそのようなオプションがないようです。
Maven を使用してそのようなフラグでコンパイルするように IDE を構成する方法はありますか?
pom.xml でコンパイラ引数を設定できると思います。これを参照してください http://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html
<compilerArgument>-Xlint:unchecked</compilerArgument>
@Nishantの回答について詳しく説明したいと思います。タグはcompilerArgument
タグ内に配置する必要がありますplugin/configuration
。完全な例を次に示します。
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<testSource>1.8</testSource>
<testTarget>1.8</testTarget>
<compilerArgument>-Xlint:unchecked</compilerArgument>
</configuration>
</plugin>
</plugins>
pomファイルの情報は正確です。Jenkins で他の誰かの Maven プロジェクトをビルドし、pom ファイル リポジトリにアクセスできないという追加の課題がありました。
たとえば、gitからダウンロードした後、コンパイラーパラメーターをpomファイルに挿入するビルド前のステップを作成しました
sed -i 's|/target> *$|/target>\n<compilerArgument>\n-Xlint:deprecation\n</compilerArgument>|' $WORKSPACE/pom.xml