I want dynamic/changing file dependencies instead of static dependencies for my rosjava project which uses the Gradle build system

Hello members of the Gradle community,

I have a problem with rosjava, and it so happens to be that rosjava uses the Gradle build system. So this makes it a Gradle issue.

My build.gradle file looks like this:

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'application'
  mainClassName = 'org.ros.RosRun'
  group 'ros.rosjava_core'
version = '0.0.0'
  sourceCompatibility = 1.6
targetCompatibility = 1.6
  repositories {
  mavenLocal()
  maven {
    url 'http://robotbrains.hideho.org/nexus/content/groups/ros-public'
  }
 flatDir dirs: 'lib'
}
  dependencies {
 compile project(':rosjava')
 compile name: 'JSHOP2', changing: true
 compile name: 'antlr'
 compile name: 'planning'
}
  configurations.all {
 resolutionStrategy.cacheDynamicVersionsFor 3, 'seconds'
 resolutionStrategy.cacheChangingModulesFor 3, 'seconds'
}

It gives no errors.

I have a rosjava “node”, that calls a function from my Java dependency (JSHOP2) which is on my local filesystem. It gets the output of the function, it works fine. But then, my rosjava node keeps running, but my Java dependency gets automatically recompiled. I get no errors in this process, but when the function is called from my dependency I get the old output instead of the new one, even though the dependency is changed. If I check the jar-file of my dependency it is clearly changed.

I read that a dependency needs to implement the ExternalModuleDependency interface of Gradle to get a dynamic linked dependency. However, Files and FileTrees do not implement this interface. Is there any way to work around this?

Am I doing something wrong?

Kind regards, Pieterjan van Gastel

Are you trying to change the jar while the app is running?

Yes, that is indeed what I am doing.

Does rosjava have explicit support for this (i.e. hot class reloading)? Otherwise, this won’t work because Java doesn’t reload classes at runtime without the use of some extra tool like JRebel.

I don’t know if rosjava has such support. I’d have to look into it, but rosjava is not maintained anymore by anyone so I’ll probably have to dive into its source code again and that might take a while…

I have never heard of hot class reloading or JRebel before, I will look into it. Thanks.

Maybe I’ll have to adapt rosjava so it will fit what I am trying to do.