Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Eclipse compiler in CI to control 0 Warning level #2600

Closed
romani opened this issue Nov 13, 2015 · 10 comments
Closed

Using Eclipse compiler in CI to control 0 Warning level #2600

romani opened this issue Nov 13, 2015 · 10 comments

Comments

@romani
Copy link
Member

romani commented Nov 13, 2015

Since it is not a regular Static Code Analysis tool, but a compiler I will need to investigate a way to show compiler warning/errors in the build flow. I will start from the checking this stackoverflow thread. If it will be too challenging to add it to the build we could just launch it by some command in CI.

Review and provide some shell instructions for Travis or Appveyor.
http://stackoverflow.com/questions/14198977/using-eclipse-compiler-in-jenkins-to-get-compiler-warnings-errors

we already have this for IntelijIdea IDE, so keeping Eclipse's warning to 0 by CI is also good idea.

The full list of available inspections you can find here.

@MEZk
Copy link
Contributor

MEZk commented Apr 18, 2017

@romani
Is is still actual? Can I try ?

@romani
Copy link
Member Author

romani commented Apr 22, 2017

@romani
Copy link
Member Author

romani commented Aug 27, 2017

@Nimfadora ,

Items to improve:

I changed rule to be error:

$ git diff
diff --git a/config/org.eclipse.jdt.core.prefs b/config/org.eclipse.jdt.core.prefs
index 5ba759c..9b03568 100644
--- a/config/org.eclipse.jdt.core.prefs
+++ b/config/org.eclipse.jdt.core.prefs
@@ -56,7 +56,7 @@ org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error
 
 org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
 org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.deprecation=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=error

executed:

$ mvn clean compile exec:exec -Peclipse-compiler
....
[INFO] --- exec-maven-plugin:1.6.0:exec (default-cli) @ checkstyle ---
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 255 (Exit value: 255)
	at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
	at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
	at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:804)
	at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:751)
	at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:313)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	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:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	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:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

build is failed but no details are printed.
It is not OK as user will not see what is wrong in TRAVIS logs
please do cat target/eclipse/report.txt

Please do PR(not for merge) with some rule enabled to show how it will be printed to user in logs.

downloads/drops4/R-4.7-201706120950/"ecj-$ECJ_VERSION.jar"

version is defined in two places, so ECJ_VERSION does not make sense.
there should be:
ECJ_JAR="ecj-4.7.jar"
ECJ_MAVEN_VERSION="R-4.7-201706120950"

Extra quotes have to be removed, see my last comment in PR.

romani pushed a commit that referenced this issue Aug 31, 2017
@romani
Copy link
Member Author

romani commented Aug 31, 2017

@Nimfadora ,

please do:

  1. non-for-merge PR with one rule activated to make sure that error is printed in logs for contributor review and make sure that it fails the build.

Unexpected message
/home/travis/build/checkstyle/checkstyle/.ci/eclipse-compiler-javac.sh: 20: /home/travis/build/checkstyle/checkstyle/.ci/eclipse-compiler-javac.sh: 0: not found
https://travis-ci.org/checkstyle/checkstyle/jobs/270551844#L603

this should work:

git diff
diff --git a/.ci/eclipse-compiler-javac.sh b/.ci/eclipse-compiler-javac.sh
index 6887915..5eba08b 100755
--- a/.ci/eclipse-compiler-javac.sh
+++ b/.ci/eclipse-compiler-javac.sh
@@ -10,12 +10,12 @@ fi
 mkdir -p target/classes
 mkdir -p target/eclipse
 
-set +e
+#set +e
 java -jar ~/.m2/repository/$ECJ_MAVEN_VERSION/$ECJ_JAR -target 1.8 -source 1.8 -cp $1 \
         -nowarn:[./target/generated-sources/antlr] -d target/eclipse-compile \
         -enableJavadoc src/main/java target/generated-sources/antlr -properties config/org.eclipse.jdt.core.prefs \
-    > target/eclipse/report.txt 2>&1
-set -e
+    | cat > target/eclipse/report.txt 2>&1
+#set -e

After execution where is file with name "0", it is not expected. Nothing should be changed in repo that git can notice.

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	0

@Nimfadora
Copy link
Contributor

@romani

+#set -e

Did you intend to comment it? Why?

@Nimfadora
Copy link
Contributor

  • | cat > target/eclipse/report.txt 2>&1

this doesn't work. report file is empty.

@Nimfadora
Copy link
Contributor

After execution where is file with name "0", it is not expected. Nothing should be changed in repo that git can notice.

Unexpected message
/home/travis/build/checkstyle/checkstyle/.ci/eclipse-compiler-javac.sh: 20: /home/travis/build/checkstyle/checkstyle/.ci/eclipse-compiler-javac.sh: 0: not found

Could not reproduce it...

@romani
Copy link
Member Author

romani commented Aug 31, 2017

Could not reproduce it...

I pretty sure it is result of problem 2)

Did you intend to comment it? Why?

just to make "... | cat "

@romani
Copy link
Member Author

romani commented Aug 31, 2017

@Nimfadora ,

I fixed your script - 553e33b

please rebase and proceed with testing of it on travis

@romani
Copy link
Member Author

romani commented Sep 2, 2017

final fix is merged.
activation of the rest validation will be done at #5060

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

3 participants