Open jvasileff opened 9 years ago
So, in the case of your first errors:
source/com/vasileff/csmpetstore/module.ceylon:35: error: Error while loading the org.springframework:spring-web/4.1.4.RELEASE module:
import "org.springframework:spring-web" "4.1.4.RELEASE";
^
Declaration 'javax.servlet.Filter' could not be found in module 'org.springframework:spring-web' or its imported modules
source/com/vasileff/csmpetstore/web/config/WebAppConfig.ceylon:8: error: package not found in imported modules: 'javax.servlet' (add module import to module descriptor of 'com.vasileff.csmpetstore')
import javax.servlet {
^
They are both due to the fact that I only auto-export maven dependencies from a Maven module to an importing Maven module. I don't want Ceylon modules to have every dependency of a Maven module auto-imported. Ceylon modules should explicitly list every module they import. I don't want bad POMs to leak into Ceylon modules. So your second error is normal: you should import the servlet module in your module descriptor, rather than rely on spring to export it for you.
The first error is related, but slightly different: because we only add (to the classpath) transitive dependencies visible to the modules we compile. So spring gets added, but because its servlet dependency is not shared, it does not get added to the classpath. And if that dependency did not need to be shared (did not appear in the spring public API) then you would never get any error about it. But it is in its public API and so it must be shared. And again we don't want them to be shared by default for the reason listed above. Yes I know your patch did that, but I still think it's wrong, for Ceylon importers. I also disagree with having shared
be the default, since it will be the default for Maven modules if you have --auto-export-maven-dependencies
and it should not be the default for Ceylon modules.
Now, as to the rest of your errors, honestly I have no idea.
Well, that's completely broken and useless even if it does do what you now describe. This isn't about polluted namespaces. It's about class loading. You have to solve the class loading problem first, and then worry about narrowing visibility, and in a way that doesn't just re-break class loading.
I suggest the --auto-export-maven-dependencies
option be removed.
Now, as to the rest of your errors, honestly I have no idea.
Too bad. I wish I was better able to describe the problem and the solution from the start, but I don't know what more I could have done. I put a lot of effort into making Ceylon + JBoss Modules work with maven dependencies, and haven't seemed to achieve or contribute anything aside from an outdated patch and a misunderstood description of an approach that actually does work. I wish I could contribute more, but we can't even get past the first step of a minimally working system. I'll set this aside for now. I hope you do figure all of this out, and best of luck.
At least some transitive maven dependencies are not automatically shared with this option.
Using csmpetstore commit e9ce80f33a4f00df for testing, Java 7, and the original
overrides.xml
file referenced in.ceylon/config
, I get the following errors:Adding
shared="true"
to the override below (which shouldn't be necessary) resolves the compile errors (original shown):The flag does clearly work for
ceylon run
, since after compiled, the program runs correctly with the flag, but produces the following when the flag is missing (as expected due to unwanted classloader isolation):An additional test is to remove necessary version overrides. With the following removed:
ceylon compile --auto-export-maven-dependencies
still works, rather than producing the expected version conflict errors.Running with
ceylon run --auto-export-maven-dependencies com.vasileff.csmpetstore
then fails (as expected). In this case, the exception is:which I can't really explain, but I'm sure would make sense given enough effort trying to understand whatever classloader arrangement this is running under.
Another test is to comment out the following:
resulting in the runtime error:
which is probably more easily explained as being a classpath or classloader problem.
Now, as a potentially related issue, testing with Java 8 produces different results. (Still using Ceylon compiled with Java 7, but now using Java 8 to compile and run csmpetstore.)
As in the original test,
shared="true"
must be explicitly added. But unlike the original test,ceylon run --auto-export-maven-dependencies com.vasileff.csmpetstore
fails with an exception resembling the exception in the second case above:The proof of concept patch (https://github.com/jvasileff/ceylon-module-resolver/commits/maven-share-deps) does not exhibit these problems (at least on Java 7), and supports
shared="false"
.