[GRADLE-1913] Iterating over runtime dependencies of a project unless a required project has been built, makes the required project JAR not being shown as a dependency Created: 10/Nov/11  Updated: 18/Jan/17  Resolved: 16/Jan/17

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-5
Fix Version/s: None

Type: Bug
Reporter: Mauro Molinari Assignee: Unassigned
Resolution: Won't Fix Votes: 1

Attachments: Zip Archive GRADLE-1913.zip    

 Description   

I don't know if this is really a problem in the actual build process, but it might be when you want to do some debugging or you need to do some special process based on dependencies.

Consider the attached multiproject.
Project A has a runtime dependency on B.
Project A defines a task printDeps that prints its dependencies as a File Set.
If B.jar is built before printDeps is executed, B.jar is printed by printDeps.
If B.jar is not built before printDeps is executed, B.jar is not printed.

Examples: run "gradle clean war printDeps" and "gradle clean printDeps" from the root project and see the differences.

I think this is misleading: even if B.jar does not yet exist, it may be built by subsequent actions, if required. In any case, A has a runtime dependency on B, so it should be present in A runtime configuration.



 Comments   
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 Mauro Molinari [ 15/Nov/16 ]

This is still reproducible in recent Gradle.

Comment by Benjamin Muschko [ 16/Jan/17 ]

I am not quite sure why you used fileTree for iterating over the runtime dependencies. Either way, the following works in both cases:

task printDeps << {
    println "Printing ${name} dependencies:"
    configurations.runtime.each {
        println it
    }
}
Comment by Mauro Molinari [ 17/Jan/17 ]

Well, I can ask you why I should not!

Anyway, a long time has passed and this was just a sample to reproduce the problem. What I think I was trying to achieve was to copy all the JARs a project depended on to a target folder.
After all, if a configuration has a "asFileTree" method, I think it should work as expected or at least it should be well documented. Please note I don't have current Javadoc/Groovydoc with me to check what the documentation says.

Comment by Benjamin Muschko [ 17/Jan/17 ]

If you ask for the FileTree then you are only getting the root folder but not the actual files. You'd either have to call the method getFiles() to get the flattened list or iterate over the files with the method visit. I think the documentation is fairly clear about though I can see how you could miss those details.

Comment by Mauro Molinari [ 18/Jan/17 ]

I am of course iterating over the files (see the sample project), the problem is that the B.jar is not among the dependency files if B has not yet been built, like if it were not a dependency.

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