eclipseClasspath chokes on Javadoc in archive with anything but a file: URI

In Eclipse in the Java Build Path, I assigned a javadoc jar to a library by selecting “Javadoc in archive”, then giving the path in my project like myProject/lib/doc/spring-framework-3.1.3-RELEASE-javadoc.jar. With this, the eclipse task chokes:

robert@pferdeapfel:~/pmc/1808/powermta> gradlew eclipse -s :eclipseClasspath FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:eclipseClasspath’. > Cannot parse file ‘/Users/robert/myProject/.classpath’.

Perhaps this file was tinkered with? In that case try delete this file and then retry.

… Caused by: org.gradle.api.GradleException: Cannot parse file ‘/Users/robert/myProject/.classpath’.

Perhaps this file was tinkered with? In that case try delete this file and then retry. … Caused by: java.lang.IllegalArgumentException: URI scheme is not “file”

at org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory.fromJarURI(FileReferenceFactory.groovy:77)

Looking at .classpath in an editor, the entry in question is

<classpathentry kind="lib" path="lib/org.springframework.core-3.1.3.RELEASE.jar">
        <attributes>
            <attribute name="javadoc_location" value="jar:platform:/resource/myProject/lib/doc/spring-framework-3.1.3-RELEASE-javadoc.jar!/"/>
        </attributes>
    </classpathentry>

Is that expected?

Even if I change the Eclipse setting from Workspace File to External File, Eclipse does not put a file: URI in. In my example I got

<attribute name="javadoc_location" value="jar:file:/Users/robert/myProject/lib/doc/spring-framework-3.1.3-RELEASE-javadoc.jar!/"/>

Of course I don’t want to use this cause the absolute path would break the location for everybody else on the team.

What do I need to change to make both Eclipse and Gradle happy?

Thanks,

Robert

Just realized that Eclipse will put absolute paths in .classpath for jars and javadoc jars. Guess I need to change my project setup and not have .classpath in version control. Makes sense.

That said, it would still be nice if Gradle could handle an existing project’s jar:resource: Javadoc locations. Or am I missing something else?

Can you tell us what Eclipse version you use and how did you create that classpath entry definition? I guess there are some ways how to fix this in Gradle: probably we need to add URL handler for ‘platform:’ protocol or parse this as simple String.

In the meantime: my first choice would be to use a repository like Artifactory or Nexus for your binary dependencies rather than adding them to your project (and possibly to SCM). This will take care of the association with sources and javadoc in most cases too.

This is Eclipse Kepler, Build id: 20130614-0229.

To add a javadoc jar, go to Java build path settings, then the Libraries tab. Open any library, click the Javadoc location, then click Edit… Select Javadoc in archive, select Workspace file, select the docjar in Archive path.

I agree that jars should not be in the SCM. This is an ant-based project and I want to get it working with Gradle without breaking ant. I’ll have a hard time selling gradle in the company if it breaks the current build.