You didn’t really configure your build to produce multiple JAR files. To achieve this you can create additional tasks of type Jar to bundle source files and Javadocs.
Many thanks for the response. I am using GGTS 3.4.
I get Build Successful but non of the build is run. The java source files are not compiled. I do not get any class files in the build directory of the Jars of the Docs.
You don’t have to declare the task classJar. This functionality is already provided by the Java plugin. Also, in your case it would try to bundle the Javadocs as indicated by javadoc.destinationDir. I’d also define the sourceSet customization as follows:
If your source files sit in the src directory, then the command "gradle build: should create all three JAR files. Based on your question about “settings.gradle” it sounds as if you are working on a multi-project build and not a single project build. Is that the case?
Can you provide us with an example project preferably on GitHub? That’ll make it easier to troubleshoot your issue.
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties.
Deprecated dynamic property: "srcDir" on "source set main", value: "[src]".
Deprecated dynamic property: "classesDir" on "source set output", value: "[bin]".
C:\WorkSpace\workspace-ggts-3.3.0.RELEASE\GradleTest\build\classes\main
BUILD SUCCESSFUL
Total time: 0.443 secs
But build is not executed. Non ot the tasks is executed.
You had a typo in sourceSets.main.java.srcDirs. You were missing an “s”. I also corrected some of your logic. After executing “gradle build” you will find your generated JAR files under build/libs.
To your question “BTW, how can you set alternate different directories in Gradle 2.0”: The version property assigns the version to your project and not the version of Gradle. Plus you are already setting different source and classes directories.
Works fine for me with Gradle 1.8. Not sure what wrong on your end. BTW: You moved output.classesDir = ‘bin’ into the wrong spot. Check my original posted listing. You do not need to create nor check-in the output directories. Gradle creates the directories for you.
An important part of learning Gradle is to get into the documentation (online docs, DSL guide). You can easily reconfigure the output directories.
Benjamin, how come your “sourcesJar” task is not explicitly declared to “dependsOn classes”? But you explicitly declare that “javadocJar” “dependsOn javadoc”? For me, leaving sourcesJar without no explicit dependsOn declaration work and I think it is 'cause Gradle know that already from the “from” statement. But, I can not leave out the dependsOn declaration from the javadocJar task. If I do that, the built jar will be empty. How come sourcesJar work without dependsOn, but javadocJar fail?
you don’t need to compile source files to create a jar containing source files. So no dependsOn is needed. The sources are there, and all the task needs to do is putting them in a jar file. To generate a jar containing the javadoc, the javadoc must first be generated, hence the dependsOn javadoc.