Gradle

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
To raise new issues or bugs against Gradle, please use forums.gradle.org.
  • Gradle
  • GRADLE-1000

Use source set compile/runtime classpath for determining dependencies.

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Resolution: Incomplete
  • Affects Version/s: None
  • Fix Version/s: None

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • History
  • Activity
  • TeamCity
  • Commits
  • Source
  • Reviews
Hide
Permalink
Blaine Simpson added a comment - 02/May/11 9:46 PM

Gradle dependencies are crazy. For a build system to be adequate for professional usage, it needs to at least allow for precise control over sequence of task executions, and precise control over classpaths. At this point in time, Gradle has neither.

Compile classpaths bleed over to the runtime classpath when using java plugin. War plugin classpaths are at least usable but the rules are idiosyncratic. Why not just leverage Ivy and have predefined Ivy configs mirroring runtime names so the user can directly specify what they want for build time and for bundle and/or runtime?

Show
Blaine Simpson added a comment - 02/May/11 9:46 PM Gradle dependencies are crazy. For a build system to be adequate for professional usage, it needs to at least allow for precise control over sequence of task executions, and precise control over classpaths. At this point in time, Gradle has neither. Compile classpaths bleed over to the runtime classpath when using java plugin. War plugin classpaths are at least usable but the rules are idiosyncratic. Why not just leverage Ivy and have predefined Ivy configs mirroring runtime names so the user can directly specify what they want for build time and for bundle and/or runtime?
Hide
Permalink
Adam Murdoch added a comment - 02/May/11 11:06 PM

Can you give us some more details of the precise control that you'd like? It might already be there.

Show
Adam Murdoch added a comment - 02/May/11 11:06 PM Can you give us some more details of the precise control that you'd like? It might already be there.
Hide
Permalink
Blaine Simpson added a comment - 03/May/11 6:42 AM - edited

Regarding execution sequence, that is already covered by Issue #427. I have to add distracting, superfluous tasks to use alphabetical ordering to force sequence. I don't get how a team could design and implement complex inter-project builds and such yet never have considered that there is a need to execute peer tasks in a specified order.

I'm going to rewrite the description (which was previously here) of the classpath problem with a new post, because after more testing I have learned more about the cause...

Show
Blaine Simpson added a comment - 03/May/11 6:42 AM - edited Regarding execution sequence, that is already covered by Issue #427. I have to add distracting, superfluous tasks to use alphabetical ordering to force sequence. I don't get how a team could design and implement complex inter-project builds and such yet never have considered that there is a need to execute peer tasks in a specified order. I'm going to rewrite the description (which was previously here) of the classpath problem with a new post, because after more testing I have learned more about the cause...
Hide
Permalink
Blaine Simpson added a comment - 04/May/11 7:51 PM

I understand that Gradle automatically adds compile dependencies onto the runtime classpath. Though I hate this behavior (I specified "compile" classpath, not "compile + runtime" classpath), it is understandable.

What I don't understand is why the dependencies that I am setting for my custom source set ("altRuntime") is clobbering my plain "runtime" dependency.

defaultTasks 'run'
...
configurations { compile { transitive = false } }
configurations { altCompile { transitive = false } }
configurations { altRuntime { transitive = false } }
configurations { runtime { transitive = false } }
dependencies {
    compile(
        [group: 'commons-logging', name: 'commons-logging', version: '1.1.1'],
    )
    altCompile (
        [group: 'commons-logging', name: 'commons-logging', version: '1.1.1'],
    )
    altRuntime (
        [group: 'commons-logging', name: 'commons-logging', version: '1.1.1']
    )
    runtime(
        'javax.servlet:jstl:1.2:jar'
        )
}
sourceSets {
    alt {
        compileClasspath = configurations.altCompile
        runtimeClasspath = configurations.altRuntime
    }
}
...
task run (dependsOn: assemble) << {
    String jarPath = relativePath(new File(libsDir, archivesBaseName + ".jar"))
    println configurations.runtime.files

Output from gradle -i:

: resolving dependencies :: #gra2;unspecified
        confs: [runtime]
        found commons-logging#commons-logging;1.1.1 in clientModuleChain
        found javax.servlet#jstl;1.2 in MavenRepo
:: resolution report :: resolve 305ms :: artifacts dl 0ms
        ---------------------------------------------------------------------
        |                  |            modules            ||   artifacts   |
        |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
        ---------------------------------------------------------------------
        |      runtime     |   2   |   0   |   0   |   0   ||   0   |   0   |
        ---------------------------------------------------------------------
:: resolving dependencies :: #gra2;unspecified
        confs: [altCompile]
        found commons-logging#commons-logging;1.1.1 in clientModuleChain
:: resolution report :: resolve 42ms :: artifacts dl 0ms
        ---------------------------------------------------------------------
        |                  |            modules            ||   artifacts   |
        |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
        ---------------------------------------------------------------------
        |    altCompile    |   1   |   0   |   0   |   0   ||   0   |   0   |
        ---------------------------------------------------------------------
All projects evaluated.
...
:compileJava
:: resolving dependencies :: #gra2;unspecified
        confs: [compile]
        found commons-logging#commons-logging;1.1.1 in clientModuleChain
:: resolution report :: resolve 15ms :: artifacts dl 0ms
        ---------------------------------------------------------------------
        |                  |            modules            ||   artifacts   |
        |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
        ---------------------------------------------------------------------
        |      compile     |   1   |   0   |   0   |   0   ||   0   |   0   |
        ---------------------------------------------------------------------
...
:assemble UP-TO-DATE
:run
Executing task ':run' due to:
Task ':run' has not declared any outputs.
[/home/blaine/.gradle/cache/commons-logging/commons-logging/jars/commons-logging-1.1.1.jar]

See that though I set the runtime dependency to the jstl jar file, Gradle sets my runtime classpath to the commons logging jar file. (I found by changing things that the problem goes away if I remove the alt settings, so I think Gradle is treating the altRuntime dep or classpath value is my plain runtime value).

Show
Blaine Simpson added a comment - 04/May/11 7:51 PM I understand that Gradle automatically adds compile dependencies onto the runtime classpath. Though I hate this behavior (I specified "compile" classpath, not "compile + runtime" classpath), it is understandable. What I don't understand is why the dependencies that I am setting for my custom source set ("altRuntime") is clobbering my plain "runtime" dependency.
defaultTasks 'run'
...
configurations { compile { transitive = false } }
configurations { altCompile { transitive = false } }
configurations { altRuntime { transitive = false } }
configurations { runtime { transitive = false } }
dependencies {
    compile(
        [group: 'commons-logging', name: 'commons-logging', version: '1.1.1'],
    )
    altCompile (
        [group: 'commons-logging', name: 'commons-logging', version: '1.1.1'],
    )
    altRuntime (
        [group: 'commons-logging', name: 'commons-logging', version: '1.1.1']
    )
    runtime(
        'javax.servlet:jstl:1.2:jar'
        )
}
sourceSets {
    alt {
        compileClasspath = configurations.altCompile
        runtimeClasspath = configurations.altRuntime
    }
}
...
task run (dependsOn: assemble) << {
    String jarPath = relativePath(new File(libsDir, archivesBaseName + ".jar"))
    println configurations.runtime.files
Output from gradle -i:
: resolving dependencies :: #gra2;unspecified
        confs: [runtime]
        found commons-logging#commons-logging;1.1.1 in clientModuleChain
        found javax.servlet#jstl;1.2 in MavenRepo
:: resolution report :: resolve 305ms :: artifacts dl 0ms
        ---------------------------------------------------------------------
        |                  |            modules            ||   artifacts   |
        |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
        ---------------------------------------------------------------------
        |      runtime     |   2   |   0   |   0   |   0   ||   0   |   0   |
        ---------------------------------------------------------------------
:: resolving dependencies :: #gra2;unspecified
        confs: [altCompile]
        found commons-logging#commons-logging;1.1.1 in clientModuleChain
:: resolution report :: resolve 42ms :: artifacts dl 0ms
        ---------------------------------------------------------------------
        |                  |            modules            ||   artifacts   |
        |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
        ---------------------------------------------------------------------
        |    altCompile    |   1   |   0   |   0   |   0   ||   0   |   0   |
        ---------------------------------------------------------------------
All projects evaluated.
...
:compileJava
:: resolving dependencies :: #gra2;unspecified
        confs: [compile]
        found commons-logging#commons-logging;1.1.1 in clientModuleChain
:: resolution report :: resolve 15ms :: artifacts dl 0ms
        ---------------------------------------------------------------------
        |                  |            modules            ||   artifacts   |
        |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
        ---------------------------------------------------------------------
        |      compile     |   1   |   0   |   0   |   0   ||   0   |   0   |
        ---------------------------------------------------------------------
...
:assemble UP-TO-DATE
:run
Executing task ':run' due to:
Task ':run' has not declared any outputs.
[/home/blaine/.gradle/cache/commons-logging/commons-logging/jars/commons-logging-1.1.1.jar]
See that though I set the runtime dependency to the jstl jar file, Gradle sets my runtime classpath to the commons logging jar file. (I found by changing things that the problem goes away if I remove the alt settings, so I think Gradle is treating the altRuntime dep or classpath value is my plain runtime value).
Hide
Permalink
Luke Daley added a comment - 23/Jan/13 7:14 AM

It's not clear what this issue is about.

If you feel it's still an issue, please post a clarifying comment and I'll reopen it.

Show
Luke Daley added a comment - 23/Jan/13 7:14 AM It's not clear what this issue is about. If you feel it's still an issue, please post a clarifying comment and I'll reopen it.

People

  • Assignee:
    Unassigned
    Reporter:
    Hans Dockter
Vote (1)
Watch (2)

Dates

  • Created:
    22/Jun/10 2:54 PM
    Updated:
    23/Jan/13 7:14 AM
    Resolved:
    23/Jan/13 7:14 AM
  • Atlassian JIRA (v5.0.3#729-sha1:bf569e4)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Gradle. Try JIRA - bug tracking software for your team.