On Fri, Oct 9, 2009 at 00:49, Adam Murdoch <[email protected]> wrote:
Steve Ebersole wrote:Ok, got past that (thanks to much help from Jason on IRC): compileJava { options.fork(executable: '/opt/java/jdk-1.6/bin/javac') } However, I am not able to get the dependencies to work properly. It works fine if I just do: dependencies { compile project(':core') } But that gives trouble later when I go to do: jar { from { project(':jdbc3').sourceSets.main.classes } from { project(':jdbc4').sourceSets.main.classes } } complaining about: * What went wrong: Circular dependency between tasks. Cycle includes task ':core:uploadDefaultInternal'.That's right. A project dependency uses the jar from the target project. In your case, the jar need the classes from the other projects, which in turn need the jar in order to be compiled.Looking closer at you suggestions, you had actually said to use: dependencies { compile project(':core').sourceSets.main.classes } To reference the classes directory rather than the jar. However, that is leading to this on my system: Cause: No such property: sourceSets for class: org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependencyYou'll need to use: dependencies { compile this.project(':core').sourceSets.main.classes } Note the call to this.project(...). We need this because DependencyHandler (the delegate for the dependencies {} closure) has a project() method which returns a ProjectDependency, which we don't want - we want the ':core' Project returned by Project.project(). I think the distinction is a little confusing. We could clean this up so that project('...') always returns a Project, and we use some other syntax for project dependencies which need configuring.Was unable to find DefaultProjectDependency in javadocs at http://www.gradle.org/0.8/docs/javadoc/ to check. On Thu, 2009-10-08 at 23:55 -0500, Steve Ebersole wrote:I am trying to figure out exactly how I can specify that a different JDK (different from the one used to launch gradle) be used for the javac tasks for a given (sub)project. Any pointers? On Wed, 2009-10-07 at 10:14 -0500, Steve Ebersole wrote:The difficulty here is that this does not fit well with IDEs (at least not the IDEs with which I am familiar). Most (all?) IDEs want to associate a JDK with each module/project. So the approach of using multiple modules/projects here fits best IMO because it can be used in gradle as well as in an IDE. But I do love that gradle gives you this kind of flexibility. On Wed, 2009-10-07 at 08:39 +1100, Adam Murdoch wrote:You don't necessarily need to use multiple projects if you don't want to. A single project can have multiple groups of source directories, known as source sets. Each source set has its own compile task which you can configure independently - including which javac to use. So, given a single project with a layout something like: src/common/java src/jdbc3/java src/jdbc4/java You could define a source set for each of these source directories, and assemble the classes into a single jar. Here is a (complete) example: sourceSets { common // default source dir is 'src/common/java' jdbc3 { compileClasspath = common.classes + common.compileClasspath } jdbc4 { compileClasspath = common.classes + common.compileClasspath } } compileJdbc3Java { fork(executable: 'path-to-java5') } compileJdbc4Java { fork(executable: 'path-to-java6') } jar { from sourceSets.common.classes from sourceSets.jdbc3.classes from sourceSets.jdbc4.classes }-- Adam Murdoch Gradle Developer http://www.gradle.org --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
We must be doing something wrong Adam.
project structure:
|____build.gradle
|____core
| |____src
| | |____main
| | | |____java
|____jdbc3
| |____build.gradle
| |____src
| | |____main
| | | |____java
| | |____test
| | | |____java
| | | |____resources
|____jdbc4
| |____build.gradle
| |____src
| | |____main
| | | |____java
| | |____test
| | | |____java
| | | |____resources
|____settings.gradle
Here are the build files
[main]
usePlugin 'java'
jar {
from this.project(':core').sourceSets.main.classes
from this.project(':jdbc3').sourceSets.main.classes
from this.project(':jdbc4').sourceSets.main.classes
}
subprojects {
usePlugin('java')
repositories {
mavenCentral()
}
dependencies {
compile(
'org.slf4j:slf4j-api:1.5.8'
)
testCompile(
'junit:junit:3.8.2',
'org.slf4j:jcl-over-slf4j:1.5.8',
'org.slf4j:slf4j-log4j12:1.5.8'
)
}
group = 'org.gradle'
version = '1.0'
manifest.mainAttributes(provider: 'gradle')
}
dependsOnChildren()
[jdbc3]
dependencies {
compile this.project(':core').sourceSets.main.classes
}
compileJava {
options.fork( executable: '/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/javac' )
}
[jdbc4]
dependencies {
compile this.project(':core').sourceSets.main.classes
compile this.project(':jdbc3').sourceSets.main.classes
}
compileJava {
options.fork( executable: '/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javac' )
}
output from main: gradle jar :core:compileJava :core:processResources :core:classes :jdbc3:compileJava :jdbc3:processResources :jdbc3:classes :jdbc4:compileJava :compileJava :jdbc4:processResources :processResources :jdbc4:classes :classes :core:jar :jdbc3:jar :jdbc4:jar :jar [ant:jar] Warning: skipping jar archive /Users/jporter/projects/gradle/gradle-1/build/libs/gradle-1-unspecified.jar because no files were included. [ant:jar] Warning: skipping jar archive /Users/jporter/projects/gradle/gradle-1/build/libs/gradle-1-unspecified.jar because no files were included. BUILD SUCCESSFUL Every thing I've tried points to the fact that the source sets aren't being resolved to their correct locations, they keep going back to the main folder : ( -- Jason Porter Real Programmers think better when playing Adventure or Rogue. PGP key id: 926CCFF5 PGP fingerprint: 64C2 C078 13A9 5B23 7738 F7E5 1046 C39B 926C CFF5 PGP key available at: keyserver.net, pgp.mit.edu
signature.asc
Description: OpenPGP digital signature
