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.DefaultProjectDependency


You'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


Reply via email to