Eclipse debug/run configuration: can another project be included into classpath, along with its runtime dependencies?

I try to implement the following scenario.
My Eclipse project requires a set of JDBC drivers at runtime, which are not supposed to be present in compile classpath. Those drivers are stored in binary repository and must be accessed by artifact coordinates, so, other approaches like local file system are not an option.

Today our Eclipse projects are based on Ivy/IvyDE and the scenario above is quite easy to implement. There is dedicated project in our Eclipse workspace which is just kinda wrapper for the JDBC drivers of interest: those are included into IvyDE classpath container as project’s dependencies. Classpath container is exported and thus it’s just enough to add this project into debug/run configuration classpath. Two items are added then, project itself and its exported classpath container.

My problem is that I’m unable to implement the similar approach with Buildship. Although all necessary artifacts are declared as project’s runtime dependencies and “exported” with “whenMerged” hook, they do not become a part of debug configuration classpath when the project is included there. Container just do not appear in the entries list.

Is such an approach is possible with Buildship? Or is there a better way to implement this scenario?

Buildship implements a custom runtime classpath resolver that customizes what should be on the runtime classpath. From a high-level, only dependencies from the Gradle classpath container are considered.

Maybe you can define a composite build including your original build and the project containing the JDBC drivers. If you are stuck, please create a sample project so that we could investigate your case more effectively.

Hi donat

Well, let’s consider Eclipse project ‘X’ configured as follows:

apply plugin: 'java'
apply plugin: 'eclipse'

repositories {
	...
}

dependencies {
	runtime group: 'com.oracle.jdbc', name: 'ojdbc6', version: '11.2.0.3'
    runtime group: 'net.sf.jt400', name: 'jt400', version: '7.2'
	runtime group: 'com.microsoft.sqlserver', name: 'mssql-jdbc', version: '6.2.2.jre8'
	runtime group: 'mysql', name: 'mysql-connector-java', version: '5.1.45'
}

eclipse {
	classpath{
		file.whenMerged {
			entries.findAll{it.kind.equals('lib')}.forEach{it.exported = true}
		}
	}
}

There is some ‘Java Application’ debug configuration in Eclipse workspace, created for ‘Y’ project. My goal is to configure its classpath by adding ‘X’ to ‘User entries’ (with ‘Add projects…’). I expect X’s classpath be added to the configuration classpath, along with its dependencies. However, this is not the case. Is this expected behaviour?

Hello,

I’m having the same issue than you. Did you find a way to solve yours ?

I also want to manage some dependencies using only the launcher, not directly in gradle.