ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How do I add a jar dependency in rosjava?

asked 2012-08-04 01:31:18 -0500

liangfok gravatar image

I have a node written in ROSJava that depends on third party jar files. How do I add these jar files so they can be found when I execute "gradlew installApp"?

I notice that by default numerous jar files are located in ~/.m2/repository/ros/rosjava_core/ and ~/.gradle/caches/artifacts-8/filestore/. How do I add more jar files to either of these?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-08-04 02:38:37 -0500

KruseT gravatar image

The .m2 directory is where Maven downloads files to.

In Maven you add repos and dependencies to your pom files, in gradle to your gradle file. As an example, in the rosjava stack build.gradle:

repositories {
  mavenLocal()
  maven {
    url 'http://robotbrains.hideho.org/nexus/content/groups/ros-public'
  }
}

and in the rosjava PACKAGE's build.gradle:

dependencies {
  ...
  compile 'org.apache.commons:com.springsource.org.apache.commons.logging:1.1.1'
  compile 'org.apache.commons:com.springsource.org.apache.commons.net:2.0.0'
  testCompile 'junit:junit:4.8.2'
  }

Gradle then goes to the URL and tries to find the dependencies in the given version numbers, when gradle needs them.

edit flag offensive delete link more

Comments

Additionally, you can install jar files directly to your local maven repository using something like (using junit as an example): mvn install:install-file -Dfile=/PATH/TO/JAR/FILE.jar -DgroupId=junit -DartifactId=junit -Dversion=4.8.2 -Dpackaging=jar

piyushk gravatar image piyushk  ( 2012-08-04 08:45:11 -0500 )edit

Thank you, it worked. After manually adding the jar files, I had to add the following to my package's build.gradle's dependency list: compile '[groupId]:[artifactId]:[version]'

liangfok gravatar image liangfok  ( 2012-08-06 10:10:09 -0500 )edit

The jar file I needed to add was JFreeChart's (http://www.jfree.org/jfreechart/). I manually installed it in my local maven repository using the command above and it worked, but I wonder if there's some on-line maven repository that I could have used to automatically install it.

liangfok gravatar image liangfok  ( 2012-08-06 10:14:53 -0500 )edit

Hi, I have the same issue! I have a jar file containing some java classes. I want to use them in my java program. Shall I manually add it ~/.gradle/caches/artifacts-8/filestore/? but I see three dirs jar,pom and source. Do I make it by mkdir command and what to add in there? Thanks in advance

safzam gravatar image safzam  ( 2012-11-03 00:09:11 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2012-08-04 01:31:18 -0500

Seen: 789 times

Last updated: Aug 04 '12