[GRADLE-2733] Gradle should honour Ivy artifact type to determine sources and javadoc classification Created: 02/Apr/13  Updated: 10/Feb/17  Resolved: 10/Feb/17

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

Type: Bug
Reporter: Andreas Nyberg Assignee: Unassigned
Resolution: Won't Fix Votes: 5

Issue Links:
Related
Related to GRADLE-3170 Gradle 'idea' task generates wrong so... Resolved

 Description   

When pointing Gradle at existing internal Ivy repositories, source artifacts appear on the classpath instead of attached as source. Existing Ivy module descriptors (inconsistently) identify source artifacts using the artifact type attribute, and changing these descriptors is not an option. For example:

<ivy-module version="2.0">
...
  <publications>
    <artifact name="xyz" type="jar" ext="jar" conf="runtime"/>
    <artifact name="xyz" type="src" ext="src.jar" conf="runtime"/>
  </publications>
...
</ivy-module>

I found to my surprise that the only way to get Eclipse to attach sources for an artifactName.jar is to provide artifactName-sources.jar, regardless of anything (type or classifier) in the module descriptor.

This is consistent with the stricter Maven naming conventions, where sources is the classifier, but it is not flexible enough for Ivy. This has worked for years with Ivy out of the box; the classpath contains only jars, and the Eclipse plugin IvyDE is configurable with the types to map as sources and javadoc respectively. Gradle must be able to do the same in order to fulfill its promise:

Gradle fully supports your existing Maven or Ivy repository infrastructure for publishing and retrieving dependencies.



 Comments   
Comment by Andreas Nyberg [ 18/Jan/14 ]

This is still a huge problem in my organisation that still has to hack/patch Gradle to make our existing Ivy repositories work.

All artifacts have a "type", and the most common type is "jar". Only "jar" artifacts should ever form a classpath, but Gradle constructs classpaths using the sum of all artifacts on a given configuration. This is not only redundant but actually causes failures when a compiler sees duplicate classes, one in the source archive and one in the jar. Pulling artifacts of a certain type from a given configuration should also be better supported.

  1. The compileClasspath for a given configuration should consist of only artifacts with the "jar" type.
  2. Configuration should have a method that returns artifacts that satisfy a given condition, such as its type matching regular expressions "(src|source).*" or "\w+doc(s?)".
  3. The "idea" plugin should be able to set up the correct IDEA module configuration. In the actual result below, scala-library comes from a Maven repository is correctly resolved but openspaces from an Ivy repository fails (both jar and sources on executable classpath) even though it adheres to Maven naming convention.
    mymodule.iml
        <orderEntry type="module-library" exported="">
          <library>
            <CLASSES>
              <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.10.3/21d99cee3d3e478255ef9fcc90b571fb2ab074fc/scala-library-2.10.3.jar!/" />
            </CLASSES>
            <JAVADOC />
            <SOURCES>
              <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.scala-lang/scala-library/2.10.3/71730fdfb1242ae6853f3f72bc9a6a40a67f573c/scala-library-2.10.3-sources.jar!/" />
            </SOURCES>
          </library>
        </orderEntry>
        <orderEntry type="module-library" exported="">
          <library>
            <CLASSES>
              <root url="jar://$MODULE_DIR$/../../ivyrep/com.gigaspaces/xap/9.6.2-9900-RELEASE/openspaces-9.6.2-9900-RELEASE.jar!/" />
            </CLASSES>
            <JAVADOC />
            <SOURCES />
          </library>
        </orderEntry>
        <orderEntry type="module-library" exported="">
          <library>
            <CLASSES>
              <root url="jar://$MODULE_DIR$/../../ivyrep/com.gigaspaces/xap/9.6.2-9900-RELEASE/openspaces-9.6.2-9900-RELEASE-sources.jar!/" />
            </CLASSES>
            <JAVADOC />
            <SOURCES />
          </library>
        </orderEntry>
    
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 12:30:01 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.