Generated Source files not found
Opened this issue · 15 comments
I use this plugin with the apt (https://github.com/Jimdo/gradle-apt-plugin) plugin. The APT plugin generates .java files in build/source/apt
My problem is that the java files in this folder are not visible for the GWT plugin during gradle build
.
Here is my build.gradle:
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'apt'
apply plugin: 'war'
apply plugin: 'gwt'
apply plugin: 'jetty'
sourceCompatibility = 1.7
version = '1.0'
eclipse {
classpath {
downloadSources=true
downloadJavadoc=true
}
}
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.jimdo.gradle:gradle-apt-plugin:0.5-SNAPSHOT'
}
}
repositories {
mavenCentral()
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT:jar-with-dependencies'
compile 'com.google.guava:guava:18.0'
compile 'com.google.guava:guava-gwt:18.0'
compile 'javax.inject:javax.inject:1'
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
}
gwt {
gwtVersion='2.7.0'
logLevel = 'INFO'
minHeapSize = "512M";
maxHeapSize = "1024M";
compiler {
strict = true;
}
modules 'test.GWTT'
}
tasks.withType(de.richsource.gradle.plugins.gwt.AbstractGwtActionTask) {
args '-XjsInteropMode', 'JS'
}
sourceSets {
apt{
java{
srcDir 'build/source/apt'
}
}
}
Is there any way to fix this such that the GWT plugin will find the sources?
Try the following to make the additional sources visible to GWT compiler.
gwt {
src += files(sourceSets.apt.allJava.srcDirs)
}
@jnehlmeier I still getting the following error:
:addAptCompilerArgs
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileGwt
Compiling module test.GWTT
Tracing compile failure path for type 'test.client.GWTT$$MembersInjector'
[ERROR] Errors in 'file:/Users/mg/Documents/Grails/GGTS3.6.2/TestGradle2/build/source/apt/test/client/GWTT$$MembersInjector.java'
[ERROR] Line 7: No source code is available for type dagger.MembersInjector<T>; did you forget to inherit a required module?
Tracing compile failure path for type 'test.client.test2.Dagger_MyWidgetGinjector'
[ERROR] Errors in 'file:/Users/mg/Documents/Grails/GGTS3.6.2/TestGradle2/build/source/apt/test/client/test2/Dagger_MyWidgetGinjector.java'
[ERROR] Line 9: No source code is available for type javax.inject.Provider<T>; did you forget to inherit a required module?
Tracing compile failure path for type 'test.client.test2.MyWidgetClientModule$$ProvideSomeServiceFactory'
[ERROR] Errors in 'file:/Users/mg/Documents/Grails/GGTS3.6.2/TestGradle2/build/source/apt/test/client/test2/MyWidgetClientModule$$ProvideSomeServiceFactory.java'
[ERROR] Line 7: No source code is available for type dagger.Factory<T>; did you forget to inherit a required module?
[ERROR] Aborting compile due to errors in some input files
:compileGwt FAILED
Here is what I found. You cannot use the following plugins with the GWT plugin:
apply plugin: 'war'
apply plugin: 'jetty'
Do you have any idea why this error comes only with these two plugins?
I'm using both war and jetty without ill effect.
My buildscript uses a different dependency classpath for gwt-gradle-plugin:
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
I am not using the gradle-apt-plugin
I'm not using it, period. It's not part of my application's build.
@johnthad Well if you do not use APT then your comment does not mean anything it does not belong to this issue.
@jnehlmeier Jens do you have any other idea how to solve this?
Oh I see the issue is Dagger on client side.
Dagger 2.0 can not be used with GWT out of the box because Dagger 2.0 does not provide a GWT module yet. To use Dagger 2.0 in GWT you need to create a Dagger.gwt.xml which makes Dagger source code available to the GWT compiler and also super sources javax.inject annotations + interfaces. Then you need to inherit this module.
Generally pretty easy, I have done that for myself some time back to play with GWT + Dagger 2.0.
@jnehlmeier I did this too. Dagger2 and GWT works in a normal web application project. I have a dagger.gwt.xml and a inject.gwt.xml. Also I have the inject and dagger2 sources on my build path.
As I said the problem that I can to a gradle build
when I do not use the war and jetty plugin. In this case the GWT plugin finds the generated sources correctly.
When I use the war and the jetty plugin your GWT plugin does not find the generated sources anymore. Could you imagine why this is so?
No idea, should not make any difference if you use the war
plugin or not. The gwt
plugin configures the war
plugin so it includes the output of compileGwt
task but it does not change the behavior of the compileGwt
task itself.
@jnehlmeier Is it important in which order the GWT plugin is with the other plugins?
@jnehlmeier I created a simple demo project to show you the problem:
GWT needs source files for compilation. In your project you are missing Dagger source files so your dagger.gwt.xml does not publish any source to the GWT compiler. Thus the GWT compiler produces the "no source code available" errors. The same for javax.inject.
I fixed this with adding the following to the dependencies:
dependencies {
compile name: 'dagger-2.0-SNAPSHOT-sources'
compile name: 'javax.inject-1-sources'
}
But now I still get the following errors:
:compileGwt
Compiling module test.GWTT
Tracing compile failure path for type 'test.client.GWTT'
[ERROR] Errors in 'file:/Users/mg/Documents/Grails/GGTS3.6.2/TestGradle2/src/main/java/test/client/GWTT.java'
[ERROR] Line 15: No source code is available for type test.client.test2.Dagger_MyWidgetGinjector; did you forget to inherit a required module?
Finding entry point classes
Tracing compile failure path for type 'test.client.GWTT'
[ERROR] Errors in 'file:/Users/mg/Documents/Grails/GGTS3.6.2/TestGradle2/src/main/java/test/client/GWTT.java'
[ERROR] Line 15: No source code is available for type test.client.test2.Dagger_MyWidgetGinjector; did you forget to inherit a required module?
[ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
:compileGwt FAILED
The GWT plugin cannot find the generated sources.