Secondary gradleclasspathcontainer

Hello - I’m a looking to see if there is a way to specify a secondary gradleclasspathcontainer.

I see that in GradleClassPathContainer.java - there is only a single reference to the container, so I’m not sure this is possible yet.

I have put together a small example project to illustrate the classpath loader issue that occurs when a GWT container is required to appear in the classpath before the gradleclasspathcontainer - see build.gradle.

The issue is that the gwt-dev.jar contains a very old version of org.apache.http.conn.ssl.SSLConnectionSocketFactory (1.5 actually), which doesn’t contain the necessary methods, resulting in the following exception when the test case is run:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.conn.ssl.SSLConnectionSocketFactory.<init>(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/HostnameVerifier;)V

If it were possible to create a secondary gradle class path container, and possibly annotate the dependencies to indicate which container they belong to, then theoretically, this new container could appear before the GWT container and resolve this class loader issue.

I imagine something like this to be necessary:

@Container("custom")
dependencies {
    compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.9'
}

dependencies {
    // everything else
}

The eclipse classpath task could then be updated to reflect the new container and respective order:

eclipse {
    classpath {
        defaultOutputDir = file('src/main/webapp/WEB-INF/classes')
        `containers 'org.eclipse.buildship.core.gradleclasspathcontainer.custom'`
        containers 'com.google.gwt.eclipse.core.GWT_CONTAINER'
        containers 'com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER'
        containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
    }
}

I prefer this approach over manually attaching libraries in the WEB-INF/lib folder so that dependency versions can still be managed.

Thank you in advance for your time in reviewing this help/discussion topic.

Well, introducing a second classpath container is possible, although it would involve a lot of changes.

For your case, wouldn’t it be enough to reorder the classpath containers? Although it can’t be done in the build script, it’s possible to write a small plugin extending Buildship which does that. Here’s a POC implementation: custom-classpath-order.zip (4.2 KB)

1 Like

In this particular case, it is not possible to reorder the classpath containers. For the eclipse workspace to function, the GWT container must appear before the gradle container (which in turn has GWT dependencies). The sample POC zip you attached does not appear to have anything other than a blank gradle project. I am interested to see this POC, would you please upload another version?

Sorry about that. I’ve fixed the link above.