[GRADLE-3044] Compilation fails if the archive name is changed Created: 12/Mar/14 Updated: 10/Feb/17 Resolved: 10/Feb/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Task | ||
Reporter: | Gradle Forums | Assignee: | Unassigned |
Resolution: | Won't Fix | Votes: | 0 |
Description |
Hello, I have noticed "strange" behavior during project compilation under the following conditions. top-level
(2) The main source set of subproject1 contains production code and some testing utils that are needed for testing of subproject2 (used only in the test source set). So what I'm doing is excluding some part of the sources from production archive. Additionally I declare a configuration and a jar that contains both production and testing code. I use this configuration as a testCompile dependency of subproject2. (3) The build files are the following: subproject1.gradle apply plugin: 'java' ext.productionArchiveName = 'demo-production.jar' configurations { dependencies { jar { task(testingJar, type: Jar) { artifacts { subproject2.gradle apply plugin: 'java' dependencies { (4) With the provided code the project succeeds to compile. The "strange" behavior I'm talking about manifests itself if you uncomment the archiveName = ... in the jar task or in the testingJar task or in both of them then the compilation fails during compileTestJava with missing test utilities classes. Moreover if you uncomment exclude ...in testingJar task the compilation fails during compileTestJava but the missing production classes from subproject1. My expectation was that testCompile extends the compile configuration and everything visible in compile should be visible in testCompile. It seems there is some colision between the published artifacts. The only situation when such a setup works is when the published archives names are identical, which I'm tryin to avoid. To summarize: declaring a several configurations with a published artifacts and then trying to use them for different denedency configurations brings compilation errors due to classes not found. My expectation was that naming of the artifacts should not influence how the classes are resolved in the dependent projects. |
Comments |
Comment by Gradle Forums [ 12/Mar/14 ] |
If you don't give the test Jar a different name (e.g. by setting `appendix = "test"`), it will overwrite the main Jar on disk. Another thing that's suspicious is that you configure the test Jar to contain `sourceSets.main.output` rather than `sourceSets.test.output`. |
Comment by Gradle Forums [ 12/Mar/14 ] |
Thanks for the quick response Peter If you don't give the test Jar a different name (e.g. by setting appendix = "test"). Exactly this is what bothers me: if I do give the test Jar a different name the project does not compile anymore. With a different name for some reasons the classes contained in the second test jar are not resolved anymore. test Jar to contain sourceSets.main.output rather than sourceSets.test.output. And again exactly because I need some of the test helpers to be available in production code for our internal tools I cannot put them into the test sourceSet (limitation of the IDE that the test classes of one subproject are not visible for production code in another subproject) If you wish I can provide the minimal project where the problem can be easily reproduced. |
Comment by Gradle Forums [ 12/Mar/14 ] |
> if I do give the test Jar a different name the project does not compile anymore This just means that fixing one problem (the name collision) exposed another, likely unrelated, problem. > And again exactly because I need some of the test helpers to be available in production code The way the two Jar tasks are configured right now, the test Jar is a superset of the main Jar. That doesn't seem right to me. |
Comment by Gradle Forums [ 12/Mar/14 ] |
Thaks for your reply Peter, I wouldn't claim that I like current layout of the project either. But I have to handle the limitations of the tools I use and limitation in current project structure which requires weeks of refactoring to fix it. Before posting here I tried of course lots of different layouts and the one described in the first post is the only one that worked. At first to avoid the situation when "test Jar is a superset of the main Jar" I tried to split the code in two separate jars with no overlap. Prod jar has prod classes e.g. everything from com.vozniuk.demo.** and test jar has only test helper classes from com.vozniuk.testing.** task(testingJar, type: Jar) { Uncommenting the exclusion line makes the build produce 2 disjoint jars. Unfortunately this setup doesn't work. Can I then put the question this way: Thanks for help! |
Comment by Gradle Forums [ 12/Mar/14 ] |
1-3 should be clear by now. (The way you publish and reference the test Jar looks fine.) There is no generic answer to 4. The problem is likely specific to your build, and to help further I'd need a reproducible example. |
Comment by Gradle Forums [ 12/Mar/14 ] |
Sure. Here is a reproducible example: [Download]([1]http://goo.gl/IOzfW6) |
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:
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. |