Local Dependencies with Source

We are trying to get a local dependency to include its source. The dependency is not in Maven format so we have it in a local folder, structured like it would be in Maven. The dependency is YAJSW. We create the folder layout to mimic the dependency spec and even added the version to the jars. It does nto work. See error below.

We need to include the source because there is a bug in YAJSW and we are trying to debug it.

repositories {
maven {
url uri( “file:///Y:/Dependencies/” )
}
}

dependencies {
compile group: ‘org.rzo.yajsw’, name: ‘wrapper’, version: ‘12.10’
}

Error:
Could not resolve: org.rzo.yajsw:wrapper:12.10

And ideas? We’re stumped. We are using Gradle 4.2.1 in Eclipse (current version) and the latest Buildship.

Hi!

To have the sources automatically loaded, you need to publish the dependencies (and the sources) to a well-formed Maven repository and then reference it in your build. You can create a Maven repository with the maven-publish plugin or with a Maven repository manager (e.g. Artifactory OSS).

In Eclipse there’s an alternative. You can modify the source path for a jar dependency in the eclipse.classpath.file.whenMerged {} block. You’ll find examples of how to do that here.

Thank you Donat. I have used the publishToMavenLocal before but didn’t want to do this with someone else’s product. But I’m surprised that Gradle has no way to specify dependency sources. We should make that a requested feature. You used to be able to do this with .classpath entries but Buildship disables that it seems.

I will try the Eclipse alternative you suggest.

Fantastic, the alternative worked. But I’m curious why Gradle couldn’t understand what I was doing to start with.

I’m just guessing here, but maybe the dependency management engine misses the Maven metadata from the local repository. You could use Docker to spin up a temporary Artifactory instance. Then, you can check the Gradle and Artifactory logs to figure out what’s going on.

Eclipse will pickup sources and javadoc from a local directory maven repository just the same as a remote http maven repository. Perhaps your file paths are not correct?

See Include local javadoc with gradle

The paths are correct. The problem looks like file URI’s don’t work when specifying repositories. It is supposed to work but it doesn’t. Gradle’s documentation does not have an example of that.

Just for completeness, please include the paths of your artifacts

Another thing to try is

repositories {
    maven {
        url file("Y:/Dependencies")
    }
}