The Tomcat case is a bit tricky. What I’m trying to do now is not to set up the webapp class path, but the classpath of Tomcat itself. That is, I’m simulating the case in which I’m putting some JARs in Tomcat’s own lib directory. These JARs should be put on the Tomcat own classpath and then be available for Tomcat to work.
This is accomplished in Ecilpse by changing the Tomcat classpath in the Classpath tab of the Tomcat launch configuration. Here is a screenshot:
Under “User Entries” I’m adding my project (the one that contains my X509TrustManager implementation I want Tomcat to use). As you can see, when you add a project to the Tomcat classpath, you can optionally tell Eclipse to also add the project exported entries and/or the projects required by that project (but NOT the libraries/JARs required by that project, if not exported - these are not added to the classpath in any case, unless they are exported AND the first flag is checked).
In my case I would like to add my project (that is: the compiled classes of my project) and the libraries I need to compile/run my X509TrustManager implementation. These are defined in my build script in the custom source set called “appServer”. So, in my buildscript I have:
def lib = new org.gradle.plugins.ide.eclipse.model.Library(fileReference(it))
lib.exported = true
entries += lib
(by the way, I removed the “eclipse.classpath.plusCpmfogiratopms << appServerRuntime” to avoid duplicate addition to the Eclipse build path). What I see, however, is that even if these dependencies are then added to the “Project and External Dependencies” container, if I then add my project to the Tomcat classpath and run Tomcat, my required libraries are not indeed in the classpath and I receive a lot of NoClassDefFound, ClassNotFound etc. exceptions.
After all, I still can’t see anywhere that the “exported” flag is honoured in this case.
In the above screenshot, after “shop-sc-auth” (which is my project) you see a list of JARs. These where automatically added by the UI when I put those JARs as manual entries in my .classpath file, with kind=“lib” and exported=“true”. If I remove those entries, though, and I use the code above to let Buildship add my dependencies to the “Project and External Dependencies”, those JARs are not shown in the Classpath tab (only sho-sc-auth is added). And, in fact, I get the NoClassDefFound/ClassNotFound exceptions at runtime.
Where should I see that an element inside “Project and External Dependencies” is exported?
In the project “Java Build Path”, under “Order and Export”, I can only check the whole “Project and External Dependencies” container for export, not any single JAR inside it.
I hope I’ve explained it somehow. If I only had “withXml” supported, I may edit the .classpath programmatically to add entries with exported=true to that file directlry, but currently I can’t. This would solve my problem.
Any suggestion would be appreciated.