renatoathaydes / ceylon-gradle-plugin

A simple Gradle plugin to manage Ceylon projects.
22 stars 6 forks source link

Plugin does not include transitive dependencies for re-exported maven dependencies #10

Closed lucono closed 7 years ago

lucono commented 8 years ago

In building a ceylon module A that imports another ceylon module B which shared imports a maven dependency C, the ceylon gradle plugin fails to include the transitive dependency graph for the maven dependency C which is re-exported by B when building the ceylon overrides.xml file for ceylon module A.

module com.example.a "1.0.0" {
    import com.example.b "1.0.0";
}
module com.example.b "1.0.0" {
    shared import "artifact.group:maven-artifact" "1.0.0";
}

Building module com.example.b produces an overrides file like the following:

<overrides>
  <artifact groupId='artifact.group' artifactId='maven-artifact' version='1.0.0' shared='true'>
    <add groupId='...' artifactId='...' version='...' shared='true' />
  </artifact>
</overrides>

However, even though maven dependency "artifact.group:maven-artifact" "1.0.0" is re-exported by module com.example.b, building module com.example.a does not generate the <artifact> entry for "artifact.group:maven-artifact" "1.0.0" in the overrides.xml file for ceylon module com.example.a.

The problematic end result is that ceylon module com.example.a does not have visibility of types in the transitive dependency graph of "artifact.group:maven-artifact" "1.0.0" even though it is re-exported by ceylon module com.example.b which is directly imported by com.example.a.

renatoathaydes commented 8 years ago

@lucono I don't think this is a bug in the Gradle plugin. The overrides file is not required to add transitive dependencies coming from a Ceylon direct dependency, because Ceylon should be already able to figure out those transitive dependencies (and in the case of com.example.b, it should see its overrides file, which correctly adds maven-artifact).

Does it compile in the command line when you add references to classes in maven-artifact in code of the module com.example.a? I would bet it will work fine.

lucono commented 8 years ago

@renatoathaydes, no it doesn't compile using Gradle. The transitive dependencies are not picked up through the overrides file of the direct Ceylon dependency.

renatoathaydes commented 8 years ago

@lucono So you're saying each overrides file needs to declare every possible transitive dependency, even of Ceylon dependencies? This is unexpected... It's doable, of course, but I can't believe Ceylon is not able to build the dependency tree when all information is already available.

lucono commented 8 years ago

@renatoathaydes From what I can see, that's the behavior. For Ceylon modules that have other Ceylon dependencies which re-export a maven dependency for which an overrides file entry exists to share that maven dependency's own transitive dependencies, the top-level Ceylon module does not seem to have visibility of the transitive maven dependencies declared shared in those overrides files.

renatoathaydes commented 8 years ago

@lucono I had a play with that... I had assumed from what you're saying that Ceylon would normally figure out the transitive Maven dependencies of Ceylon dependencies, but with Gradle, it was not doing that.

For me, even direct transitive dependencies (like depending on a Maven dependency which has transitive dependencies) are not figured out regardless of which options I use (--flat-classpath, --auto-export-maven-dependencies etc)... so I can't even try to compile a Ceylon module which depends on another Ceylon module, which in turn has transitive Maven dependencies.

Do you agree with that?

But once I use this plugin to compile a Ceylon module which has a Maven dep with transitive Maven deps (which creates the proper overrides file), I have confirmed that Ceylon won't compile the module which depends on it.

It seems to me the only way to make this work would be to actually parse the overrides.xml file of the Ceylon dependency, then add its dependencies to the first module. But this probably needs to be recursive... but how would I find the overrides files of all dependencies? The dependencies may not be Gradle projects and may not be local projects, in which case I don't know how to get access to the overrides file (or even module.ceylon, which I could also parse to get the dependencies).

So, I am not too sure there's a simple solution to this issue.

lucono commented 8 years ago

so I can't even try to compile a Ceylon module which depends on another Ceylon module, which in turn has transitive Maven dependencies.

Do you agree with that?

Yes, those are my findings as well.

FroMage commented 8 years ago

This looks weird. Does it work if you have no override file? IMO it should just work.

renatoathaydes commented 8 years ago

@FroMage That's exactly what I said. Without the overrides file, I can't get anything at all to work.

FroMage commented 8 years ago

OK, can you give me a clear example of what your module descriptors look like and the errors you get?

renatoathaydes commented 7 years ago

This is impossible to get right and after improvements in Ceylon 1.3.1, it has become unnecessary as Ceylon itself can do something to work around this issue.