Hello,
in our project we use some Java libraries which need native libraries as well.
The current approach is that the native libraries are packed into jar files and stored next to the java libraries within artifactory. Via gradle dependency resolution these jars are downloaded and a gradle task extracts the native libaries
into a specific subdirectory of the build directory. The classes task depends on the extraction task to make sure the native libraries are there before test execution.
In the context of test and integrationtest the java.library.path is set to the subdirectory automatically within the build script. Everything works nice on the command line and in Jenkins.
Since we are using Eclipse we would like to execute the tests and the application itself within Eclipse as well.
Before switching to buildship we used the gradle IDE plugin from pivotal and extended the eclipse task appending the native library directory;
eclipse.classpath { containers "org.springsource.ide.eclipse.gradle.classpathcontainer" } eclipse.classpath.file { withXml { xml -> def node = xml.asNode() def container = node.find { it.@path == 'org.springsource.ide.eclipse.gradle.classpathcontainer' } container.appendNode('attributes').appendNode('attribute', [name: 'org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY', value:"$project.name/build/natives/windows"]) } }
This worked partially but lead to having “Gradle dependency” and “Referenced Libraries” shown in Eclipse and we got an update problem using snapshot dependencies because Eclipse used to containers and only one got updated by the plugin.
Therefor I tried to switch to buildship hoping the problem can be dealt with in another way.
Currently I have a couple of problems:
- The build directory is hidden in Eclipse importing the gradle projects via buildship. Therefor I cannot set up the native libary location for the “Project and External Dependencies” container manually in Eclipse which would be an intermediate solution
- Using the same task shown above with “org.eclipse.buildship.core.gradleclasspathcontainer” instead of “org.springsource.ide.eclipse.gradle.classpathcontainer” has no effect. It looks like buildship is not using the eclipse plugin and its tasks or overwrites the classpath file afterwards.
Do you have any ideas how to integrate native library setup in Eclipse via gradle and buildship?
I’m also happy to change our current approach dealing with native libraries if a better way of integration is available.