2017-10-06 4 views
0

Mavenコンパイラプラグインを使用してすべての警告を表示しようとしています。 Mavenのコンパイラプラグのための私のpom.xmlファイルの設定である - 廃止、未チェック、rawtypes - 私のプロジェクトでMavenコンパイラプラグインWerror引数でビルド失敗し、現在の警告がスキップされているとマークされました

  <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.5.1</version> 
      <configuration> 
       <forceJavacCompilerUse>true</forceJavacCompilerUse> 
       <source>1.7</source> 
       <target>1.7</target> 
       <compilerArgs> 
     <arg>-Xlint:all</arg> 
     <arg>-Xlint:-deprecation</arg> 
     <arg>-Xlint:-unchecked</arg> 
     <arg>-Xlint:-rawtypes</arg> 
     <arg>-g</arg> 
     <arg>Werror</arg> 
       </compilerArgs> 
       <verbose>true</verbose> 
       <showWarnings>true</showWarnings> 
      </configuration> 
     </plugin> 

、私はこれらの3回の警告を持っています。 これらの引数を削除すると、ビルドに失敗しますが、これは問題ありません。 -

<arg>-Xlint:-deprecation</arg> 
    <arg>-Xlint:-unchecked</arg> 
    <arg>-Xlint:-rawtypes</arg> 

しかし、これらの引数を追加すると、コンパイラはこれらの警告を無視してビルドを成功させる必要があります。 しかし、まだビルドに失敗しており、特定のエラーは表示されません。 この引数を削除した場合、ビルドは成功します。

<arg>Werror</arg> 

は、だから私たちは、プロジェクト内に存在している警告の一部を省略した場合は成功したビルドを実行することはできませんよ。同じことを達成する方法はありますか?

[INFO] Error stacktraces are turned on. 
    [INFO] Scanning for projects... 
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.abcd:project:war:1.0 
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.abcd.xyz:common:jar -> duplicate declaration of version 1.3 @ line 87, column 21 
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. 
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects. 
[WARNING] 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building PROJECT 1.0 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ vsmvam --- 
[INFO] Deleting /home/ess/p4-sources/abcd/xyz/project/target 
[INFO] 
[INFO] --- jacoco-maven-plugin:0.6.1.201212231917:prepare-agent (default) @ vsmvam --- 
[INFO] argLine set to -javaagent:/home/ess/.m2/repository/org/jacoco/org.jacoco.agent/0.6.1.201212231917/org.jacoco.agent-0.6.1.201212231917-runtime.jar=destfile=/home/ess/p4-sources/mgmtplatform/vshield-main/vsmvam/target/jacoco.exec,excludes=com/vmware/vshield/vsm/** 
[INFO] 
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ vsmvam --- 
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 
[INFO] Copying 13 resources 
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ vsmvam --- 
[INFO] Changes detected - recompiling the module! 
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 
[INFO] Compiling 330 source files to /home/ess/p4-sources/abcd/xyz/project/target/classes 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 10.590s 
[INFO] Finished at: Fri Oct 06 01:51:08 PDT 2017 
[INFO] Final Memory: 39M/892M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project vsmvam: Compilation failure -> [Help 1] 
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project vsmvam: Compilation failure 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319) 
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure 
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:976) 
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129) 
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) 
    ... 19 more 
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 
+0

は、このエラーで失敗 [ERROR]はゴールorg.apache.maven.pluginsの実行に失敗しました: 3.5.1:プロジェクトvsmvamのコンパイル(デフォルトコンパイル):コンパイル失敗 - > [ヘルプ1] org.apache.maven.lifecycle.LifecycleExecutionException:目標org.apache.maven.plugins:maven-compiler-pluginの実行に失敗しました:3.5.1:プロジェクトvsmvamでコンパイル(デフォルトコンパイル):Compila \t、org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213) –

+0

完全なエラーとログ出力を投稿してください... – khmarbaise

+0

mvn buildコマンドのエラー出力を追加しました。 –

答えて

0

私は最終的にすべてのlint警告が固定されている場合は、「Werror」フラグを正常にビルドする方法を見つけ出すことができた多くの変更を行った後 -

PFB MVNのビルドコマンドのエラー出力

削除しました - "true" Javacコンパイラを使用するとビルドが失敗する理由を正確に把握できませんでした。

UTF-8エンコードが追加され、処理Lintの警告が表示されなくなりました。 maven-コンパイラプラグイン:

の構成の作業コピーがされて - -

<plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>3.5.1</version> 
      <configuration> 
     <encoding>UTF-8</encoding> 
       <source>1.8</source> 
       <target>1.8</target> 
       <showWarnings>true</showWarnings> 
       <compilerArgs> 
     <arg>-Xlint:all</arg> 
     <arg>-Xlint:-processing</arg> 
       </compilerArgs> 
      </configuration> 
     </plugin> 
関連する問題