Why does GWT compile errors won't break the maven build? - java

I'm building a GWT project in maven using gwt-maven-plugin.
Recently I noticed an error on a class, where some server code was called on a client class. At first I thought that something was wrong with the gwt compilation (not including this class). But then I notice that it was compiling that class and it was throwing the error on info log level.
[INFO] Tracing compile failure path for type 'com.mycompany.shared.IElement'
[INFO] Errors in 'jar:file:/Users/myuser/.m2/repository/com/mycompany/package/package-java/1.0.0-SNAPSHOT/package-java-1.0.0-SNAPSHOT-sources.jar!/com/mycompany/shared/IElement.java'
[INFO] Line 45: No source code is available for type com.mycompany.test.Tester; did you forget to inherit a required module?
Why this is only a info log?
Why this does not breaks the build?
Can I force the build to break upon this kind of errors?

Yes you can, and in fact you should! Its even likely that this option will be on by default in the future, as these sorts of 'recoverable' errors cause performance issues in the compiler as it keeps recovering and working around the missing code.
Using the maven plugin, you can simply set this flag to true. From http://mojo.codehaus.org/gwt-maven-plugin/compile-mojo.html#failOnError,
failOnError:
Fail compilation if any input file contains an error.
Can be set from command line using '-Dgwt.compiler.strict=true'.
In your plugin's <configuration> block, this looks like
<failOnError>true</failOnError>
(This used to be called <strict>, and in some of my own pom files, still lives that way...)

Related

How to debug Dagger2 not generating components

Is there a way to get dagger to spit out why it didn't generate a particular component?
I tried refactoring some of our modules and ended up breaking something, but I have literally no idea what I broke! All I see is that all my DaggerFoo components are missing, because dagger is apparently silently failing.
I've tried compiling with verbosity & higher max errors, but I still see absolutely nothing from Dagger itself saying what went wrong.
-Xdiags:verbose
-Xmaxerrs=1000
I have no relevant errors to share, because none are printed!
How the heck do you debug Dagger2?
Dagger runs as an annotation processor, so its error messages will manifest as compiler errors. These will often look like this message ("X cannot be provided...").
error: some.injected.ClassName cannot be provided without an #Inject constructor
or from an #Provides- or #Produces-annotated method.
some.injected.ClassName is injected at
some.class.that.InjectsIt
some.class.that.InjectsThatAbove
some.class.that.FurtherInjectsThat
If you're not sure where to look for compiler errors, you can see some other answers here:
Android Studio: Where is the Compiler Error Output Window?
How to view the list of compile errors in IntelliJ?
eclipse annotation processor not working. Where are errors shown?
If you've edited your project configuration or Gradle definition, it is also possible that Dagger is no longer running at all, or that it hasn't run for a while and has been working only based on its previous output. If so, check your Gradle file or Eclipse project definition to ensure that you are including Dagger as an annotationProcessor, and that you have at least one #Component file for that annotation processor to find.

How do I get missed classes from JaCoCo?

I have a mixed Java/Kotlin project, and after a failed build the report says:
Loading execution data file jacoco.exec
Analyzed bundle 'xxx-api' with 884 classes
[WARNING] Rule violated for bundle xxx-api: classes missed count is 36, but expected maximum is 35
This is my local build, and it fails in Jenkins too (with the same error), so I need to solve this locally (I mean, I can't change nothing about the environment nor the pom.xml), so I was wondering if there's a way to know what are the missed classes.
This is a part of the report:
And this is what appears in the bottom:
So, the "36 missed classes" aren't the sum of the missed column, and I don't get how to know what are the missed classes.
Is it any way to know it?

How to debug project.clj to find which dependency is breaking my project compilation

I have just updated my system from Java 8 to the OpenJDK Java 11 version. I have one project that won't compile and I get the following error:
Java.lang.IllegalArgumentException: Must hint overloaded method:
toArray, compiling:(flatland/ordered/set.clj:19:1)
Exception in thread "main" java.lang.IllegalArgumentException: Must
hint overloaded method: toArray, compiling:
(flatland/ordered/set.clj:19:1)
From the looks of it, this error was fixed here: https://dev.clojure.org/jira/browse/CLJ-2374
So I update my project to clojure 1.10.0-RC3 and now I get this error:
Syntax error compiling deftype* at (flatland/ordered/set.clj:19:1).
Exception in thread "main" Syntax error compiling deftype* at
(flatland/ordered/set.clj:19:1).
Has anyone seen this error OR is there a way for me to expand Clojure's error messages to show me which dependency in my project is failing during compilation (could be multiple)?
I also noticed that I copied over the dependency list which was failing in my first project to a new project and the new project compiled. However, I didn't reference the dependencies or call functions from the deps list. Does Clojure bring in the dependencies/libraries and then reference the required dependencies from the libraries that are included in my project.clj?
EDIT***
I found that this is likely the error.
https://github.com/amalloy/ordered/pull/37
You already have an answer though I thought i'd leave my general process for this incase it's useful for folks who come along later:
turn of any auto AOT in my tooling so i can get a repl witout triggering the problem.
load namespaces one at a time till i find one that triggers the problem (this usually doesn't take long ;-)
comment out half the dependencies of that namespace and evaluate the ns form at the top of the file
do a binary search till i find the one or two that trigger it
load just that dependency in a scrap project.
... lots of effort ...
SUCCESS !

GWT Compiler : when is a compilation error fatal?

I'm trying to understand more about how GWT compilation works.
More specifically, I want to know how does GWT decide that a particular error is fatal, and the app compilation should fail because of it, and how does it decide that compilation is successful, even though there are compilation errors.
The reason I'm asking is that it's very difficult to distinguish legitimate errors in my log when doing a search, from ones that don't seem to cause any problem.
I'm talking about GWT 2.7 and GWT 2.8 (which I've seen they exhibit the same behavior).
Also, I'm using GWTP 1.5.3, if this is relevant somewhat.
A concrete example: I have this error in my logs:
Tracing compile failure path for type 'myApp.ClientModule'
Errors in 'file:/E:/data/.../myApp/ClientModule.java'
Line 24: No source code is available for type myApp.client.ServicesProvidersModuleGen; did you forget to inherit a required module?
Checked 1 dependencies for errors.
The error above does not make my app to fail compilation, and myApp works just fine (the class is something that registers some GIN bindings, which also work).
Why didn't GWT failed my compilation when it encountered that error?
Additionally, I also have other errors such as:
Errors in 'com/google/gwt/validation/client/impl/AbstractGwtSpecificValidator.java'
Line 102: No source code is available for type javax.validation.ValidationException; did you forget to inherit a required module?
Line 177: No source code is available for type javax.validation.ConstraintValidator<A,T>; did you forget to inherit a required module?
Line 153: No source code is available for type javax.validation.groups.Default; did you forget to inherit a required module?
Line 302: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?
These errors also don't fail my compilation. Why?
Edit1: forgot to add.
I'm tempted to guess that compilation fails when the error is in something directly reachable from an entry point, and that compilation is OK when that code is not reachable.
However, I have the counter-example of code with annotations.
I have code that IS reachable from the entry point, and has annotations whose source code is not available, and yet the compilation succeeds (although this is the only exception that I could find so far).
Your analysis is good.
GWT will scan the entire classpath, ignoring everything not in the source path and "rebasing" super-sources. During that scan, it emits the kind of error you saw, but only when code will reach the missing sources (from entry points) the error will become fatal. Annotations are no exception, but code will never actually reach them as their just metadata (unless you implement an #interface, which Java allows). Annotations can be used by generators though, in which case they can fail the build.
Note that if you use -failOnError (or -strict, which is an alias), then all errors are fatal. You should aim for turning this on IMO.

GWT Maven Plugin -- gwt:run works but gwt:compile doesn't. Why?

I'm using gwt-maven-plugin to manage a GWT project. I use the gwt:run goal all the time to run locally in "dev mode" for testing. I now want to compile my project into a war for deployment on Tomcat. When I run gwt:compile, however, I get compile errors that indicate a classpath configuration issue. An example:
Finding entry point classes
[ERROR] Errors in 'shared.MyClass.java'
[ERROR] Line 4: The import server.model.MyObject cannot be resolved
Any ideas? Do I need to manually add the server package to some config file somewhere? Thanks in advance for any info.
-tjw
Ok, I found the problem. I found this in the GWT forums by Thomas Broyer (a GWT dev):
I mean you have to "javac" classes that are referenced from
annotations (in this case, the PlaceTokenizer classes referenced from
#WithTokenizers; that'd be true also of your service, domain object,
locator or service locator with RequestFactory, unless you use
#ServiceName and #ProxyForName). Otherwise, GWT can work with only
the *.java files, without the *.class.
I am trying to load in these classes from annotations since they are used with RequestFactory. My question is now this: How is this restriction not completely insane?

Categories