Eclipse Buildship and java.library.path

Hi all,
i always used the Eclipse plugin to create eclipse projects of my code. One thing was setting the ‘java.library.path’ wich I did as follows:

eclipse.classpath.file.whenMerged {
    classpath ->
        classpath.entries.each {
            p ->
                if (p instanceof org.gradle.plugins.ide.eclipse.model.Container) {
                    p.setNativeLibraryLocation("$buildDir/natives/lib/")
                }
        }
}

to get the project ready to import i called ‘gradle eclipse’. And after that I was able to use the project in Eclipse.
But now I wanted to use the Eclipse Buildship integration.
Can anyone tell me how I can modify my build script so the ‘java.library.path’ is automatically set when I import the project via Buildship?
Thanks very much in advance for any help.

There are no hooks defined to customize the .classpath file when importing a project with Buildship for the time being. One thing you can do is to keep the Eclipse descriptors. If they exist Buildship won’t touch them upon import.

1 Like

We have the same problem with migrating to buildship from the ‘eclipse’ gradle plugin. Ideally we would like to avoid having to use the ‘eclipse’ gradle plugin and having to run ‘gradle eclipse’ every time a customization (such as setting java.library.path) to the ‘.classpath’ file is needed. People in our team often forget to re-run ‘gradle eclipse’ which leads to lost time and frustration. If java.library.path could be set in ‘build.gradle’ and buildship picked it up automatically that would be great.

Hi Jesse,

In fact the next Buildship release will contain a feature which automatically configures the projects to use the JDK what is used by the Gradle build. I’d like to invite you to install the latest snapshot from our P2 repository to evaluate whether this feature fits your needs.