Resolving Dependency from Github using Ivy.xml - java

I have a github repo that I created a Release for. While creating the release I manually added a .jar file. Lets call it exampleLibrary.jar
This would be github.com/MyExampleRepo/Releases
I have a project I want to add a dependency for to use this exampleLibrary.jar file I added in my release v1.0
This project using Ivy.xml for resolving dependencies.
To get the jar from github using maven with pom.xml I imagine it would look something like this:
<dependency>
<groupId>com.github.User</groupId>
<artifactId>Repo name</artifactId>
<version>Release tag</version>
</dependency>
How would I do this using Ivy.xml? This is what I have tried:
<dependency org="com.github" name="MyExampleRepo" rev="v1.0"/>

Related

sharing a library with dependencies requiring transitive = false setting in gradle to work

I have a library i share on jcenter for maven and gradle users to add to their dependencies. This library uses some common stuff like gson, guava, etc. It is part of a large multi-module project but i only deploy the one child module to the repositories. The complete parent pom.xml is here:
https://github.com/bsautner/com.nimbits/blob/master/pom.xml
The child pom that results in the library's pom is here:
https://github.com/bsautner/com.nimbits/blob/master/nimbits_io/pom.xml
The child pom has dependencies like this:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
Pretty standard. When I import my library into an android project (gradle in this case) I need to include a transitive=false like this:
compile ('com.nimbits:nimbits_io:3.9.47') {
transitive = false
}
If I don't do this, android builds fail with many errors like this one:
Error:Gradle: Execution failed for task
':app:packageAllDebugClassesForMultiDex'.
java.util.zip.ZipException: duplicate entry: org/slf4j/impl/StaticLoggerBinder.class
My understanding is that my jar has duplicate dependencies already in the android project.
I don't get what i'm doing wrong, and why i need to use that flag. If i set these dependencies as "provided" I'd need my users to add my libraries to their dependencies. How do I share a library with dependencies without causing duplicate errors with the user. No other libraries require this flag, so i must be doing something wrong

Maven , How to add dependency of local system java-source?

I want to build one jar that includes a child module which depends on other package of my own project.
The output one jar should include all the related class (both from jar and my own project's classes).So the child module's classes is the base classes that should be included in the output jar,and these import some classes of my own project.All the related classes in my own project should be included.
for more detail please visit How to automatically collect all related class into one jar (use maven)?
Here is what I already find:
<project>
<dependencies>
<dependency>
<scope>system</scope>
<systemPath>D:\how\to\write</systemPath>
<groupId>how.to.write</groupId>
<artifactId>how-to-write</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>java-source</type>
</dependency>
</dependencies>
</project>
The error message is : Could not find artifact how.to.write:how-to-write:jar:sources:0.0.1-SNAPSHOT at specified path D:\how\to\write
the path D:\how\to\write contains my own project's classes that could support the build
Your maven dependency will look for a jar file with name how.to.write:how-to-write:jar:sources:0.0.1-SNAPSHOT in D:\how\to\write directory. Since you do not have one, the build will fail.
If your own project does not use maven, then you should create a jar file and place it in D:\how\to\write location and rename it to how.to.write:how-to-write:jar:sources:0.0.1-SNAPSHOT. Then your build mvn clean install will be success.
The command for creating jar file is jar cf jar-file input-file(s).
Have a look at this page on how to create a jar file

Finding Dependency tag for rs2xml.jar

Could you please help me to find Dependency tag for rs2xml.jar. i think it is really helpful for me. net.proteanit.sql.DbUtils
I checked the Maven Central Repository as well as the MvnRepository for the rs2xml JAR file and could not find it. A Google search for a POM corresponding to this dependency also came up empty. However, you can still manually install the JAR into your own local repository and then use it as if it were any other dependency.
mvn install:install-file -Dfile=C:\rs2xml.jar -DgroupId=net.proteanit.sql
-DartifactId=rs2xml -Dversion=1.0 -Dpackaging=jar
Replace the path C:\rs2xml.jar with the actual location on your computer where you downloaded the JAR. To use the rs2xml dependency in your project, include the following tag in your POM file:
<dependency>
<groupId>net.proteanit.sql</groupId>
<artifactId>rs2xml</artifactId>
<version>1.0</version>
</dependency>
I have to extracrt the package:
net.proteanit.sql.DbUtils
to import im my project.
It's works!
Before I tried to edit pom.xml with the sugestion :
<dependency>
<groupId>net.proteanit.sql</groupId>
<artifactId>rs2xml</artifactId>
<version>1.0</version>
But doesn't works... :(
https://github.com/wfrsilva/javaMySQL03_infoX

Ivy can not resolve the scope of a dependency which is a dependency of a transitive dependency

I add a dependency(let's name it as A) to ivy.xml which has a pom file in maven central. Ivy uses ibiblio for resolving the maven dependencies. The dependency(A) which is added to ivy.xml has a transitive dependency(B). So far so good till here. The dependency(C) of transitive dependency(B) can not be resolved by ivy.
I defined A in ivy.xml like this:
<dependency org="Z" name="A" rev="0.6-SNAPSHOT" conf="*->default"/>
In pom file of B, C is defined both in compile and test scopes like below:
<dependency>
<groupId>X</groupId>
<artifactId>C</artifactId>
</dependency>
<dependency>
<groupId>X</groupId>
<artifactId>C</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
When I look the xml file of B which is resolved by ivy in ivy's cache file(~/.ivy2/cache/X/C/ivy-0.98.8-hadoop2.xml), it looks like this:
<dependency org="X" name="C" rev="0.98.8-hadoop2" force="true" conf="test->runtime(*),master(*)"/>
<dependency org="X" name="C" rev="0.98.8-hadoop2" force="true" conf="test->runtime(*),master(*)">
<artifact name="C" type="test-jar" ext="jar" conf="" m:classifier="tests"/>
</dependency>
For this reason, ivy can not define C scopes correctly. For the record, I don't have permissions to modify the pom files as they are third party projects. How can I fix it ?
I reviewed the ivy usage of the nutch project and apologies but my conclusion is that it's overly complex for the following reasons:
"compile" and "test" targets are issuing separate calls to the resolve task
Each plugin is also calling an ivy resolve task
Complex logic for maintaining classpaths. Could be simplified using the cachepath task and ivy configurations.
Build plugins are not managed by ivy (Sonar, eclipse, rat)
I started to refactor the build, but had to stop when I realised that I didn't understand the relationship between the main nutch artifact and the plugins... (I discovered NUTCH-1515 the hard way... big time-waster The feed plugin has missing dependencies).
I also noticed issue NUTCH-1371 calling for the removal of ivy. This would be a tricky refactoring without significant change to the current codebase. I suspect it would have to be a multi-module build with each plugin listing its own dependencies.
In conclusion, this work does not answer your question, but thought I needed to at least document the result of a few hours analysis :-) In light of NUTCH-1371 I don't know if your project will tolerant major ivy refactoring?
Refactoring ivy
Here follows what I achieved so far:
Private "development" fork of the nutch project
Diff with trunk
Benefits:
Single ivy report showing all configurations (New ivy-resolve target)
New mechanism for installing ivy (New ivy-install target)
Classpaths are managed using ivy configurations (See use of ivy cachepath task and configurations in ivy file)
Eclipse, sonar and rat ANT tasks automatically installed using ivy (The Eclipse plugin is noteworthy as it uses a packager resolver to download and extract jar from a tar archive).
Impacts the following Nutch issues
NUTCH-1881 : This new approach removes resolve-test and resolve-default targets and manages the classpaths using ivy instead of the ${build.lib.dir}
NUTCH-1805 : Can easily setup a separate configuration for the job target with it's own dependencies.
NUTCH-1755 : I think this one is fixed by assigning a name to the the build.xml (see: diff)

2d vector class for PlayN?

I see the jbox2d Vec2 class in the repository:
http://code.google.com/p/playn/source/browse/gwtbox2d/src/org/jbox2d/common/Vec2.java
How do I make the PlayN port of JBox2D package accessible to my code? I'm using Eclipse but my project does not appear to be aware of the package.
Update:
Following the example here, I've added playn-jbox2d as a dependency in my core/pom.xml file. However, when I load my project I get the following error:
ArtifactDescriptorException: Failed to read artifact descriptor for
com.googlecode.playn:playn-jbox2d:jar:1.1.1:
ArtifactResolutionException: Could not transfer artifact
com.googlecode.playn:playn-jbox2d:pom:1.1.1 from/to central
(http://repo1.maven.org/maven2): Failed to transfer
http://repo1.maven.org/maven2/com/googlecode/playn/playn-jbox2d/1.1.1/playn-jbox2d-1.1.1.pom.
Error code 416, Requested Range Not
Satisfiable pom.xml /myproject-core line 1 Maven Dependency Problem
After a bit of a goose chase, I figured out how to enable this. Following the example here, I manually added playn-jbox2d as a dependency in my core/pom.xml file. Here is what that section of my pom.xml file now looks like:
<dependencies>
<dependency>
<groupId>com.googlecode.playn</groupId>
<artifactId>playn-core</artifactId>
<version>${playn.version}</version>
</dependency>
<dependency>
<groupId>com.googlecode.playn</groupId>
<artifactId>playn-jbox2d</artifactId>
<version>${playn.version}</version>
</dependency>
</dependencies>
Then in Eclipse:
Right-click core directory in Package Explorer window > Maven > Update Dependencies
Thanks to all who offered assistance.
You need to add JBox2D library to your workspace. Follow Basic guide for importing and building JBox2D. There are instructions for eclipse as well. Or you can download JBox2D jars and add them to eclipse. Here is a tutorial how to add jars to your workspace.

Categories

Resources