I use annotation processing. Therefore I use the apt plugin. It generates new java sources in build/source/apt
.
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' }
I need this sources to be available in my project such that eclipse can find them and such that they are included while compiling the project how can I do that?
Edit: Using
sourceSets { apt{ java{ srcDir 'build/source/apt' } } }
Leads to the following errors when running gradle build
:
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 17: 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 17: 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
Using the former Eclipse finds the sources of the generated files but build does not.
buildDirectory. dir("generated/sources/$name/main/java") . Additionally it is preferrable to use implicit task dependencies over explicit task dependencies. That way every task that needs sources automatically depends on the needed tasks and you don't need manual task dependencies.
Gradle declares dependencies on JAR files inside your project's module_name /libs/ directory (because Gradle reads paths relative to the build.gradle file). This declares a dependency on version 12.3 of the "app-magic" library, inside the "com.example.android" namespace group.
Gradle has the concept of source sets for where your code and test sources live. Some Gradle plugins come with default source sets, for example the Java plugin has a "main" source set where the default location is src/main/java .
sourceSets.main.java.srcDirs = ['build/generated-sources/xjc','src/main/java']
worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With