I have this problem, i have tried to publish an artifact of mine in my archiva repository, but even if phisical it seems that everything is ok when i go to the ui view of archiva i don't find anything about that artifact.
I have allready try to do the scan of the repositories, but nothing happens, i had look into the log file, and the only error that i see is this one
Not a valid artifact path in a Maven 2 repository, filename 'bbi-resutil.jar' doesn't start with artifact ID 'resutil'
i suspect that the error is in my make pom structure
Build.xml
<ivy:makepom ivyfile="ivy.xml" pomfile="bbi-resutil-pom.pom" conf="default,runtime">
<mapping conf="default" scope="compile"/>
<mapping conf="runtime" scope="runtime"/>
</ivy:makepom>
ivy.xml
<publications>
<artifact name="bbi-resutil" type="pom" ext="pom"/>
<artifact name="bbi-resutil" type="jar" ext="jar"/>
</publications>
i don't really understand if it is necessaire that something else must be in the ivy.xml, or if th problem is something else,
If it's the problem how i have to structure the making of the pom?
While running junit test in eclipse I am getting this Exception:
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
I've added junit.jar library file.
I've tried different versions of junit.jar: 4.4, 4.8, etc.
How do I fix this Exception?
Add hamcrest-all-X.X.jar to your classpath.
Latest version as of Feb 2015 is 1.3:
http://code.google.com/p/hamcrest/downloads/detail?name=hamcrest-all-1.3.jar&can=2&q=
According to the JUnit GitHub team website (https://github.com/junit-team/junit/wiki/Download-and-Install), junit.jar and hamcrest-core.jar are both needed in the classpath when using JUnit 4.11.
Here is the Maven dependency block for including junit and hamcrest.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.1.2</version>
<scope>test</scope>
</dependency>
<!-- Needed by junit -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
A few steps you have to follow:
Right click on the project.
Choose Build Path Then from its menu choose Add Libraries.
Choose JUnit then click Next.
Choose JUnit4 then Finish.
Works for me: IntelliJ IDEA 13.1.1, JUnit4, Java 6
I changed the file in project path: [PROJECT_NAME].iml
Replaced:
<library>
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.11.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
By:
<library name="JUnit4">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.11.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-library-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
So the final .iml file is:
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.11.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-library-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
P.S.: save the file and don't let to IntelliJ Idea reload it. Just once.
You need junit-dep.jar because the junit.jar has a copy of old Hamcrest classes.
Just in case there's anyone here using netbeans and has the same problem, all you have to do is
Right click on TestLibraries
Click on Add Library
Select JUnit and click add library
Repeat the process but this time click on Hamcrest and the click add library
This should solve the problem
This problem is because of your classpath miss hamcrest-core-1.3.jar. To resolve this add hamcrest-core-1.3.jar as you add junit-4.XX.jar into your classpath.
At first, I encounter this problem too, but after I refer to the official site and add hamcrest-core-1.3.jar into classpath with command line, it works properly finally.
javac -d ../../../../bin/ -cp ~/libs/junit-4.12.jar:/home/limxtop/projects/algorithms/bin MaxHeapTest.java
java -cp ../../../../bin/:/home/limxtop/libs/junit-4.12.jar:/home/limxtop/libs/hamcrest-core-1.3.jar org.junit.runner.JUnitCore com.limxtop.heap.MaxHeapTest
You need to add the hamcrest-core JAR to the classpath as described here: https://github.com/junit-team/junit4/wiki/Download-and-Install
As a general rule, always make sure hamcrest is before any other testing libraries on the classpath, as many such libraries include hamcrest classes and may therefore conflict with the hamcrest version you're using. This will resolve most problems of the type you're describing.
the simplest way of solving the problem to begin with is copying latest version of hamcrest-code.jar into your CLASSPATH that is the file you store other .jar files needed for compilation and running of your application.
that could be e.g.: C:/ant/lib
It sounds like a classpath issue, so there are a few different ways to go about it. Where does org/hamcret/SelfDescribing come from? Is that your class or in a different jar?
Try going to your project Build Path and on the Libraries tab, add a Library. You should be able to choose JUnit to your project. This is a little bit different than just having the JUnit jar file In your project.
In your Run Configuration for the JUnit test, check the Classpath. You could probably fix this by adding making sure your Classpath can see that SelfDescribing class there. The Run option in Eclipse has a different set of options for the JUnit options.
If this problem arise in a RCP project it can be because JUnit has been explicitly imported.
Check the editor for your plugin.xml under Dependencies tab, remove the org.junit from the Imported Packages and add org.junit to the Required Plug-ins.
The problem is when you set up eclipse to point to JRE instead of JDK. JRE has junit4.jar in the lib/ext folder, but not hamcrest.jar :) So the solution is to check installed JREs in Eclipse, remove the existing one and create a new one pointing to your JDK.
This happens when you run Ant via command line. The implicit user dependencies are added in the classpath at the end and take precedence over the project-added classpath. Run Ant with -nouserlib flag. The implicit dependencies would be excluded from the classpath.
There is a better answer to solve this problem.
add dependency
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
The hamcrest-core-1.3.jar available on maven repository is deprecated.
Download working hamcrest-core-1.3.jar from official Junit4 github link .
If you want to download from maven repository, use latest hamcrest-XX.jar.
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
I had the same problem, the solution is to add in build path/plugin the jar org.hamcrest.core_1xx, you can find it in eclipse/plugins.
A few steps you have to follow:
Right click on the project.
Choose Build Path & then from its menu choose Add Libraries.
Choose JUnit then click Next.
Choose JUnit4 then Finish.
This works for me...
"java.lang.SecurityException: class" org.hamcrest.Matchers "'s signer information does not match signer information of other classes in the same package"
Do it:
Right-click on your package
click on Build Path -> Configure Build Path
Click on the Libraries tab
Remove JUnit
Apply and close
Ready.
Try adding the jar files manually or try with force update with the latest hamcrest.jar
Extreme edit to question to have it make more sense:
Let's assume that I need to use a local version of httpclient rather than one that I can just pull from an online repo (due to signing reasons). The way that I want to handle this is like so...
ivy.xml
<dependencies>
...Other dependencies here
<dependency org="com.apache" name="httpclient" rev="4.2.2" conf="compile->default" ext="jar" />
</dependencies>
ivysettings.xml
<settings defaultResolver="central"/>
<resolvers>
<url name="repo">
<ivy pattern="http://myServer:8080/Repo/[organisation]/[artifact]/[revision]/ivy.xml" />
<artifact pattern="http://myServer:8080/Repo/[organisation]/[artifact]/[revision]/[artifact].[ext]"/>
</url>
<url name="httpclient">
<artifact pattern="http://myServer:8080/Repo/com.apache/httpclient/4.2.2/[artifact].[ext]"/>
</url>
<modules>
<module organisation="com.apache" resolver="repo" />
<module organisation="com.httpclient" resolver="httpclient" />
</modules>
Now what I'm hoping for here (and haven't been having much luck with) is the com.apache resolver looking for myServer:8080/Repo/com.apache/httpclient/4.2.2/ivy.xml and reading that, here's the contents of that file:
ivy.xml (in myServer:8080/repo/... directory)
<dependency org="com.httpclient" name="commons-codec" rev="1.6" />
<dependency org="com.httpclient" name="commons-logging" rev="1.1.1" />
<dependency org="com.httpclient" name="fluent-hc" rev="4.2.2" />
<dependency org="com.httpclient" name="httpclient" rev="4.2.2" />
<dependency org="com.httpclient" name="httpclient-cache" rev="4.2.2" />
<dependency org="com.httpclient" name="httpcore" rev="4.2.2" />
<dependency org="com.httpclient" name="httpmime" rev="4.2.2"/>
The reasoning behind wanting to read the second xml file rather than including the markup in my first file is pretty obvious when you consider how many LOC that would add to something that we include frequently. It also makes all future includes easier as well.
Right now the error that I'm getting is:
Some projects fail to be resolved
Impossible to resolve dependencies of com.myCompany#myProgramt;working#CompName
unresolved dependency: com.apache#httpclient;4.2.2: not found
Thanks for your help on this matter.
Ivy expects to find all the dependencies of a given artifact in the same resolver. So, it finds the artifacts for com.apache in your repo resolver, and expects to find com.httpclient in there as well.
Ivy also will roll through your <ivy pattern.../> and <artifact pattern.../> statements in order within the same resolver declaration. You can use this to your advantage to create a single resolver which hits both repositories in the order you want:
<url name="amalgamation">
<ivy pattern="http://myServer:8080/Repo/[organisation]/[artifact]/[revision]/ivy.xml" />
<artifact pattern="http://myServer:8080/Repo/[organisation]/[artifact]/[revision]/[artifact].[ext]"/>
<artifact pattern="http://myServer:8080/Repo/com.apache/httpclient/4.2.2/[artifact].[ext]"/>
</url>
When you configure your build to use the following resolver
<ibiblio name="central" m2compatible="true"/>
You are telling ivy to download its dependencis from Maven Central
What is your objective here? To create a local ivy repo that functionally works like Maven Central? In that case the simplest solution would be to setup a Maven repository manager like: Nexus, Artifactory or Archiva. A maven repository manager can act like a smart cache and "proxy" jars stored in the Central Maven repo.
Configuring your build to use a local Maven Repository is easy:
<ibiblio name="central" m2compatible="true" root="http://hostname:portnum/MavenRepo/>
What server are you using for your remote JAR repository?
Both Nexus and Artifactory can be setup to pull jars stored locally on themselves before puling ones from the remote repository. This way, you don't have to munge your ivysettings.xml. Instead, you simply download your preferred versions of the jars on Artifactory/Nexus. And, both are free, open source, downloads. It's way easier to do what you want with Artifactory/Nexus than futzing with your Ivy settings.
By the way, I have a Ivy project in Github you might want to look at. You simply attach this project to your Ant project, and it has everything automatically configured for Ivy. This way, an entire site can use Ivy for all of their projects, and everything is centrally controlled.
So, since I've been unable to find a way to resolve our dependency issues by including everything from external sources I've turned to Eclipse / IvyDE for ant / Ivy integration.
With that said, I normally include a lib like this:
<dependency org="org.jsoup" name="jsoup" rev="1.6.3"/>
However what if I want to look at something in our own intranet?
Example, if the folder holding the jar is somewhere like this:
https://prdsvn01.company.intra.net/repo/libName/
and I want to include lib.jar into my folder.
I've been relatively unable to find ivysettings.xml in this implementation of eclipse, nor am I confident that I'd be able to get it right if I could.
Could someone help me with this?
The following ivy settings file:
<ivysettings>
<settings defaultResolver="central"/>
<resolvers>
<ibiblio name="central" m2compatible="true"/>
<url name="my-repo">
<artifact pattern="http://myserver/myrepo/[organisation]/[artifact]/[revision]/[artifact].[ext]"/>
</url>
</resolvers>
<modules>
<module organisation="org.mycompany" resolver="my-repo"/>
</modules>
</ivysettings>
Is configured to retrieve artifacts from Maven Central by default, and local artifacts from a HTTP server.
Update
ivy.xml
Nothing special in the ivy file. Just declare the dependencies and which configuration to associate them with:
<configurations>
<conf name="compile" description="Required to compile application"/>
</configurations>
<dependencies>
<!-- compile dependencies -->
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.4" conf="compile->default"/>
<dependency org="org.mycompany" name="my-module" rev="1.0" conf="compile->default"/>
</dependencies>
Note:
It's ivy best practice to use configurations.
build.xml
<target name="resolve" dependencies="Resolve build dependencies">
<ivy:resolve/>
<ivy:report todir='build/reports' graph='false' xml='false'/>
<ivy:cachepath pathid="compile.path" conf="compile"/>
..
</target>
Notes:
The ivycachepath task transforms an ivy configuration into a populated ANT classpath. Very useful.
The ivy report task tells you the jars on the classpath(s)
Ivy resolve build output
All the magic is in the settings file. Running the build produces the following:
[ivy:resolve] found org.slf4j#slf4j-api;1.6.4 in central
[ivy:resolve] found org.mycompany#my-module;1.0 in my-repo
..
[ivy:resolve] downloading http://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4.jar ...
..
[ivy:resolve] downloading http://myserver/myrepo/org.mycompany/my-module/1.0/my-module.jar ...
Notes:
The my-repo resolver is used for modules with a "org.mycompany" groupId.
Everything else comes from the default resolver, Maven Central.
I have a ivy.xml - https://gist.github.com/1898060
I also have the jar file related to this ivy.xml.
What i need is a mechanism to import this project to my maven repo and use it in my maven project.
SO basically if i am able to convert the ivy.xml to pom.xml , i might be able to get it work.
Is there some mechanism through which i can achieve this.
I am looking for something like a maven plugin to accomplish this task.
I know that there are ways we can edit the ivy.xml and build.xml to achieve this but then i dont want to do it , as the project is in a private repo.
What you really need to do is publish the jars built by ANT project into your Maven repository.
ant -Dproject.version=0.9.0-local-20120211095554 clean publish
I know you don't want to change the ANT build, but creating an extra "publish" target will properly integrate your ANT and Maven projects.
The two jar artifacts, published by your modified ANT build, could be consumed normally as follows:
<dependency>
<groupId>com.opengamma</groupId>
<artifactId>og-analytics</artifactId>
<version>0.9.0-local-20120211095554</version>
</dependency>
<dependency>
<groupId>com.opengamma</groupId>
<artifactId>og-analytics</artifactId>
<version>0.9.0-local-20120211095554</version>
<classifier>sources</classifier>
</dependency>
Modifications to your ANT build
ivy.xml
Main changes are to your publications section:
<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
<info organisation="com.opengamma" module="og-analytics"/>
<publications>
<artifact name="og-analytics" type="jar"/>
<artifact name="og-analytics" type="pom"/>
<artifact name="og-analytics" type="jar" e:classifier="sources"/>
</publications>
<dependencies>
<dependency name="og-util" rev="0.9.0-local-20120211095525" revConstraint="latest.integration"/>
<dependency org="org.jfree" name="jfreechart" rev="1.0.13"/>
<dependency org="cern" name="colt" rev="1.2.0"/>
<dependency org="cern" name="parallelcolt" rev="0.9.1"/>
<dependency org="latexlet" name="latexlet" rev="1.11"/>
<dependency org="org.apache.commons" name="commons-math" rev="2.1"/>
<dependency org="it.dexy" name="json-doclet" rev="0.3.1"/>
<dependency org="org.json" name="simple" rev="1.1"/>
<exclude org="org.junit"/>
</dependencies>
</ivy-module>
Notes:
The ANT project will now publish 3 files, jar, sources jar and the Maven POM
In Maven source jars have a "classifier" attributes that is set to "sources" (Not source). To facilitate this we're adding an ivy extra attribute.
No need for version and status information in the info tag header. This will be added by the publication step.
build.xml
<target name="prepare" description="Generate POM">
<fail message="Unset property: project.version" unless="project.version"/>
<ivy:deliver deliverpattern="${build.dir}/ivy.xml" pubrevision="${project.version}" status="release"/>
<ivy:makepom ivyfile="${build.dir}/ivy.xml" pomfile="${build.dir}/${ivy.module}.pom"/>
</target>
<target name="publish" depends="build,prepare" description="Upload to Nexus">
<ivy:publish resolver="nexus-deploy" pubrevision="${project.version}" overwrite="true" publishivy="false" >
<artifacts pattern="${build.dir}/[artifact](-[classifier]).[ext]"/>
</ivy:publish>
</target>
Notes:
The deliver task is optional, but recommended in case your ivy file contains dynamic revisions, such as "latest.release" or "latest.integration".
The makepoms task has powerful support for convert ivy configurations into Maven scopes. Does not apply in your case, but an incentive to learn more about ivy :-)
The publish task uses a specified pattern to find files specified in ivy's publications section.
ivysettings.xml
This is where you configure the location of the repositories and credentials to be used by publish build target.
<ivysettings>
<settings defaultResolver="nexus-central"/>
<credentials host="somehost" realm="Sonatype Nexus Repository Manager" username="????" passwd="????"/>
<resolvers>
<ibiblio name="nexus-central" root="http://somehost/nexus/content/repositories/central/" m2compatible="true"/>
<ibiblio name="nexus-deploy" root="http://somehost/nexus/content/repositories/repo" m2compatible="true"/>
</resolvers>
</ivysettings>
Notes:
Ivy downloads use the configured default resolver nexus-central.
The ivy publish task pushes to the Nexus repository called nexus-deploy
The security realm in this example matches Nexus Maven. Would be different for other repo managers.
Apache Ant itself provides a task to do this - makepom. Always helps to consult the documentation!