[GRADLE-990] adding a project dependency should implicitly add a evaluationDependsOn on that project as well Created: 18/Jun/10  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Improvement
Reporter: Steve Ebersole Assignee: Unassigned
Resolution: Won't Fix Votes: 1

Attachments: Zip Archive gradle_dependencies_test.zip    

 Description   

The specific issue I ran into had to do with custom sourceSets. For example, I have a project called 'hibernate-core' which defines:

sourceSets {
    testing {
        ...
    }
    intgTest {
        ...
    }
}

Another project in this build defines:

dependencies {
    compile( project(':hibernate-core') )
    testCompile( project(':hibernate-core').sourceSets.testing.classes )
    ...
}

Which fails because apparently Gradle did not know about this custom 'testing' source set while evaluating the above project and I had to explicitly say:

dependencies {
    compile( project(':hibernate-core') )
    testCompile( project(':hibernate-core').sourceSets.testing.classes )
    ...
}
evaluationDependsOn( ':hibernate-core' )

To me this seems redundant and unnecessary.



 Comments   
Comment by Balázs Mihály [ 07/Jan/13 ]

I ran into a similar problem while trying to add manifest classpath to a jar.
Let's assume that we have 2 projects: service and cmdapp. It's important that service is after cmdapp in lexicographical order!

service:

dependencies {
    compile 'foo:bar:1.0.0'
}

cmdapp:

dependencies {
    compile project(':service')
}

jar {
    manifest {
        attributes 'Main-Class': foo.bar.Main
        attributes 'Class-Path': project.configurations.runtime.collect { it.getName() }.join(' ')
    }
}

The problem is that the runtime dependencies of cmdapp will be incomplete. The (transitive) dependencies of Service aren't in the tree.
If I add evaluationDependsOn(':service') to cmdapp it works. Or if cmdapp is called e.g. zmdapp.

Comment by Balázs Mihály [ 07/Jan/13 ]

A little working example for my comment.

Comment by Balázs Mihály [ 16/Jan/13 ]

OK, I've found the real solution for my problem (to be more precise "one" solution, there is at least one other good solution). I don't delete my previous comments, maybe they can help for somebody.
My solution is:

jar.doFirst {
    manifest {
        attributes 'Main-Class': foo.bar.Main
        attributes 'Class-Path': project.configurations.runtime.collect { it.getName() }.join(' ')
    }
}

With this method the runtime configurations don't have to be evaluated in script evaluation time.

Comment by Szczepan Faber [ 12/Feb/13 ]

@Balzas, the pattern with doFirst is a good one for this case. This way, the resolution happens at execution time.

@Steve, there are other solutions for this scenario.

The test utility classes can be moved to a separate subproject. Another solution is to publish the utility classes in a separate configuration:

testCompile project(path: ':hibernate-core', configuration: 'testing')  

Access other project's model like project(':hibernate-core').sourceSets... is not really recommended as it inflexibly couples the projects. The recommended way of coupling projects are the project dependencies.

Hope that helps!

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

Generated at Wed Jun 30 11:44:04 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.