I'm trying to create a project that depends on JDT core. I was using the entries in Maven central until I realized they were several years out of date. After poking around a little, I came across https://repo.eclipse.org. I found the repository I needed and added it:
<repository>
<id>eclipse</id>
<name>Eclipse Repository</name>
<url>https://repo.eclipse.org/content/groups/eclipse/</url>
</repository>
...
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.10.0.v20140316-0146</version>
</dependency>
But then I started getting an error:
The type org.eclipse.core.runtime.IProgressMonitor cannot be resolved.
It is indirectly referenced from required .class files
I managed to find the type in one of the Nexus repositories and added it:
<repository>
<id>eclipse-acceleo</id>
<name>Eclipse Repository</name>
<url>https://repo.eclipse.org/content/groups/acceleo/</url>
</repository>
...
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
<version>3.6.200.v20130402-1505</version>
</dependency>
Now I'm getting the error
The type org.eclipse.core.runtime.Plugin cannot be resolved. It is
indirectly referenced from required .class files
And I cannot find the class in any of the Nexus repositories. org.eclipse.jdt.core.JavaCore is the class referencing org.eclipse.core.runtime.Plugin.
1. Which dependency do I need to add to include org.eclipse.core.runtime.Plugin?
2. Is there a better way to include JDT as a dependency in Maven?
/e1
I found org.eclipse.core.runtime.Plugin with the help of http://grepcode.com. This time, the up-to-date dependency is in Maven Central (and not in Eclipse's Nexus repo):
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>runtime</artifactId>
<version>3.9.100-v20131218-1515</version>
</dependency>
Now when I try to run my tests, I get the following exception all over the place:
java.lang.NoClassDefFoundError: org/eclipse/core/resources/IResource
at org.eclipse.jdt.core.dom.ASTParser.<init>(ASTParser.java:177)
at org.eclipse.jdt.core.dom.ASTParser.newParser(ASTParser.java:126)
.
.
.
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.resources.IResource
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 30 more
At this point I'm considering downloading the complete JAR and adding it as a system dependency. Is there any better way to add JDT as a Maven dependency?
Eclipse JDT is now available on maven central using a new approach to publish the artifacts. For end user like, no work around are needed anymore, the poms are user friendly (simple version numbers, standard maven metadata for dependencies, source artifacts, 3rd party dependencies...).
Just add this to your pom:
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.12.2</version>
</dependency>
See a complete example here.
A temporary work around until a better solution is found (all dependencies in Maven central):
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.9.1.v20130905-0837</version>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>runtime</artifactId>
<version>3.9.100-v20131218-1515</version>
</dependency>
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.core.resources</artifactId>
<version>3.8.101.v20130717-0806</version>
</dependency>
Updated version found in maven repository
<dependencies>
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.12.0.v20160516-2131</version>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>runtime</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>resources</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
Related
I am trying to import a library in Maven which is Kotlin Multiplatform.
This is it's Github repo (does not actually matter much of course)
Point is, it says it can be imported in with this dependency for Gradle:
dependencies {
implementation("com.github.ajalt.colormath:colormath:2.0.0")
}
Obviously, just converting it to Maven does not work:
<dependencies>
...
<dependency>
<groupId>com.github.ajalt.colormath</groupId>
<artifactId>colormath</artifactId>
<version>2.0.0</version>
<type>jar</type>
</dependency>
</dependencies>
So I added it's pom to the project as this answer explains it:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.ajalt.colormath</groupId>
<artifactId>colormath</artifactId>
<version>2.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
This dependency is resolved (it can be only resolved as pom type. Then I add it as dependency:
<dependencies>
...
<dependency>
<groupId>com.github.ajalt.colormath</groupId>
<artifactId>colormath</artifactId>
<version>2.0.0</version>
<type>jar</type>
</dependency>
</dependencies>
It still cannot find it.
I also added the repo1, because I did not see where Maven was looking for this artifact:
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo1.maven.org/maven2</url>
</repository>
</repositories>
But still no success. I don't understand why it's not working.
The code can be found in the repo1, but Maven does not resolve it.
This must be a very simple thing I am not understanding here, please help.
The link to the Maven Central from GitHub points to a bare POM artifact, without any dependencies and/or attached JARs.
It looks like Kotlin MP uploads JVM-specific artifacts with a different artifactId - colormath-jvm in this case. Please check corresponding directory in the Maven Central.
I suggest using following dependency declaration in the POM:
<groupId>com.github.ajalt.colormath</groupId>
<artifactId>colormath-jvm</artifactId>
<version>2.0.0</version>
I am developing an Android project with Maven. I have a third-party jar file that I have included in a lib folder on my project root directory:
<dependency>
<groupId>com.parse</groupId>
<artifactId>parse</artifactId>
<version>1.9.2</version>
<scope>system</scope>
<systemPath>${project.basedir}\lib\Parse-1.9.2.jar</systemPath>
</dependency>
But when I install the apk in my phone, I get NoClassDefFoundError. Obviously, that class exists inside the jar.
How can I do?
Thanks.
I would suggest using one of your directories as a repository, add your jar in it, and load it the proper Maven way.
You can do this adding this to your pom.xml and putting your jar in /lib:
<repositories>
<repository>
<id>mylibid</id>
<url>file://${project.basedir}/lib</url>
</repository>
</repositories>
...
<dependencies>
...
<dependency>
<groupId>com.parse</groupId>
<artifactId>parse</artifactId>
<version>1.9.2</version>
</dependency>
...
</dependencies>
Add my two cents here, you can install the third-party into your local repository firstly and try add dependency directly.
Take your scenario as an example. Change to the folder where contains the third jar and type:
mvn install:install-file -DgroupId=com.parse -DartifactId=parse -Dversion=1.9.2 -Dpackaging=jar -Dfile=Parse-1.9.2.jar
Modify your pom.xml to add the dependency.
<dependencies>
...
<dependency>
<groupId>com.parse</groupId>
<artifactId>parse</artifactId>
<version>1.9.2</version>
</dependency>
...
</dependencies>
I'm following this guide:
https://github.com/maxmind/GeoIP2-java
It says:
We recommend installing this package with Maven. To do this, add the dependency to your pom.xml:
<dependency>
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
<version>2.2.0</version>
</dependency>
There is also pom.xml file in the Git repository of GeoIP2 which is much longer - what is the difference between them?
Cited from the official homepage:
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
Think of the pom.xml as the heart of Maven. In the file you can specify dependencies (most typically jar files), and other information, such as how the project should be built. Without digging to deep into this, one of Maven's strengths is that it manages the dependencies of projects.
To answer your concrete question, GeoIP2 manages its dependencies using Maven. This section of its pom.xml defines them:
<dependencies>
<dependency>
<groupId>com.maxmind.db</groupId>
<artifactId>maxmind-db</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.20.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.3</version>
</dependency>
</dependencies>
By using Maven in your own project, you will only need to add the one dependency to GeoIP2. Maven will then search for the dependency in a repository, typically the Maven Central Repository if Maven isn't configured to use another. It will also automatically download all other needed dependencies (transitive dependencies), in this case it would be the dependencies listed above, plus any other dependencies those in turn depend on, and so on.
So, a short recap: Without a dependency management tool like Maven, you would need to manually make sure you have all the correct dependencies on the classpath. Maven fixes this for you.
I'm trying to get sources added to my project. I manually added the below repo and included an atmosphere snapshot.
<repositories>
<!-- Added to get the Atmosphere 1.1.0-SNAPSHOT, can be removed when 1.1.0 is released -->
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>1.1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
I went and downloaded the .jar from here but when I add it to the "libraries" section in my Project Structure it doesn't add it as a source, but adds it under Classes.
In debugging when viewing the interface of a class, I've used the quick "Attach sources..." option at the top of the editor and navigated to the .jar with no avail.
Maven doesn't find the sources, because there are no sources of that library in that Maven repository (which i think is quite common for snapshots of a library). I downloaded one of the jars, and they contain only class files, so i'm wondering, how you can see the sources even if you attach the jar manually.
I installed Eclipse Helios with the m2eclipse maven plugin.
I want to create an application using JPA. So, what I do is: New > Maven Project then I select the maven default archetype.
The problem is that I want to add the "org.eclipse.persistence" dependency that I can't find.
Where is it? Can we add it manually? Should I update a sort of "repository"?
Then, is it the right archetype that I'm using?
EclipseLink is not available in Maven central repository, you need to add its repository manually. For example, to use the "full" version of EclipseLink 2.0 (you didn't mention the artifact you're looking for):
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
...
</dependency>
<dependencies>
...
<repositories>
<repository>
<id>EclipseLink Repo</id>
<url>http://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/rt/eclipselink/maven.repo</url>
</repository>
...
</repositories>
This is documented in the EclipseLink/Maven page.
Regarding the archetype you're using, it's impossible to answer without more details on the kind of project you want to create. And anyway, you can always modify the POM after the facts.
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
...
<repositories>
<repository>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
You can check below link. I found eclipse JARs on this link.
However, no idea about how to add it on Nexus.
http://dev.nightlabs.org/maven-repository/repo/