Maven import dependency Jetbrains Exposed - maven

On the github page of Jetbrains' Exposed,a Kotlin SQL Framework, there is a link to a page where you can get the maven dependency for this library (https://bintray.com/kotlin/exposed/exposed/view#). The same dependecy can also be found on MVNRepository (https://mvnrepository.com/artifact/org.jetbrains.exposed/exposed/0.7.6).
I am using maven 3.3.9 and Intellij 2016.3.4, but maven cannot resolve this dependency. I check the ~/.m2/ directory and it seems that it is downloaded (there is a jar present). After looking at the repository I saw that there was no pom.xml and they where using Gradle.
Is it still possible to import this dependency with maven?

It is listed on mvnrepository, but artifact itself is located in Kotlin Exposed repository. You have to add link to the Exposed repository to your POM for Maven to find it.
<repositories>
<repository>
<id>exposed</id>
<name>exposed</name>
<url>https://dl.bintray.com/kotlin/exposed</url>
</repository>
</repositories>

Related

In a Springboot Maven project, how to reference from another Jar?

I have a SpringBoot Maven project. I am dependent on another set of libraries. Currently am pointing to their repository path , downloading it to .m2 repository and using.
But the repository website is not reliable. SO I wanted to package the dependent libraries as part of JAR in the resources folder.
After putting the jars in resource folder. How can I get references of the Types/libraries ?
Currently:
<dependencies>
<dependency>
<groupId>org.dcm4che</groupId>
<artifactId>dcm4che-core</artifactId>
<version>5.23.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>www.dcm4che.org</id>
<name>dcm4che Repository</name>
<url>https://www.dcm4che.org/maven2</url>
</repository>
</repositories>
You can put all your libraries in a single folder either in your project or in some folder in your local. You can then add them to your maven POM.
Lets say you put all your jars in a folder called libs in your base project directory. You can then add something similar to the below in your maven POM.
<groupId>com.abc.xyz</groupId>
<artifactId>my-artifact-id</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/libs/my-jar-name.jar</systemPath>
You need to use the scope system. Excerpt from Maven website,
Scope : system - This scope is similar to provided except that you
have to provide the JAR which contains it explicitly. The artifact is
always available and is not looked up in a repository.
Maven Documentation
If you read further, it also mentions that this has been deprecated. So, its a nice quickfix or a hack but then the best thing would be to set up a repository manager as suggested by others.

Failure to find org.osgi:org.osgi.service.jaxrs:jar:1.0.0-SNAPSHOT

I wanted to analyse the samples for JAX-RS for Pax-Web.
However, I can't import it to Eclise or compile with Maven because the following maven dependency can't be found:
org.osgi:org.osgi.service.jaxrs:jar:1.0.0-SNAPSHOT
I was trying to find the library org.osgi.service.jaxrs, but got no success with Google or Maven repository...
What is this library? Is it a project that has changed name? How to get those samples to life?
It's available from the official OSGi sonatype repository.
And actually also configured in the Pax Web root pom.
See also here
It contains the following location for an extra repository:
<repository>
<id>osgi-releases-and-snapshots</id>
<url>https://oss.sonatype.org/content/groups/osgi/</url>
<layout>default</layout>
</repository>

Where does maven dependency fetch packages from?

As per this below snapshot, I see list of packages for hibernate:
I regularly see update index activity by m2e plugin(maven) in eclipse, for which I have no clue, What does it mean?
Where are these packages fetched from and displayed?
What is groupId/ArtifactId? Why can't one just say package/class instead?
Where are these packages fetched from and displayed?
By default, Maven will download from the Maven Central Repository, which is located at this URL: http://search.maven.org/
You can also add a custom repository by using the <repository> tag. Here is an example of how you can add the JBoss repository to your Maven project:
<project>
<repositories>
<repository>
<id>JBoss repository</id
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
</project>
Maven will download the artifacts when it needs them. So doing an mvn update or mvn install would trigger Maven to go to the repository if it doesn't already have the necessary JARs locally. And the local folder where the JAR files gets stored is C:\Users\your_windows_user\.m2\repository by default.
What is groupId/ArtifactId? Why can't one just say package/class instead?
Maven operates by managing dependencies, which are individual JAR files. So if you need to use a class, Maven will pull in the entire JAR file containing that class. The main reason for this is that Java libraries typically ship as JAR files, not individual classes.

Maven Amdatu Bundle Remote Repository

I'm new to OSGi and Amdatu and I'm using OSGi with Maven.
Usually I import bundles like this
sudo mvn pax:import-bundle -DgroupId=org.eclipse.jetty.osgi -DartifactId=jetty-osgi-boot -Dversion=9.1.3.v20140225
In upper case importing works great because the bundle can be found in maven central repository.
But there is no amdatu bundle in maven central repository, so I tried to add amdatu repositories in pom.xml.
<repositories>
<repository>
<id>dependencies</id>
<name>Amdatu Dependencies</name>
<url>http://repository.amdatu.org/dependencies/</url>
</repository>
<repository>
<id>snapshot</id>
<name>AmdatuSnapshots</name>
<url>http://repository.amdatu.org/snapshot/</url>
</repository>
<repository>
<id>release</id>
<name>AmdatuRelease</name>
<url>http://repository.amdatu.org/release/</
</repository>
</repositories>
I can see added maven repositories in Netbeans, however when exploring any repository I get the message <No result, processing index...>
If I open the link in browser I can see the repository with index.xml file.
So I tried to install a jaxrs bundle and no luck.
sudo mvn pax:import-bundle -DgroupId=org.amdatu.web.rest.jaxrs -DartifactId=org.amdatu.web.rest.jaxrs -Dversion=1.0.4
What am I doing wrong? How can I use maven amdatu repository and import bundles?
Thank you!
What you're doing wrong is assuming that the Amdatu repositories are Maven repositories. They are not. They are in fact OSGi Bundle Repositories, and we provide an index in both the "old" (repository.xml) and "new" (index.xml) format.
Within the Amdatu project, we don't use Maven, we develop with Bndtools, so you would have to provide the proper metadata (pom.xml) yourself and then import the bundles into your own Maven repository. If someone would contribute a tool to automatically generate the proper metadata and/or upload artifacts in Maven central, we would be happy to accept that though.
Marcel, thank you for your help.
I have downloaded all bundles and install them in local maven repository with next command.
mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file -Dfile=path-to-your-artifact-jar \
-DgroupId=your.groupId \
-DartifactId=your-artifactId \
-Dversion=version \
-Dpackaging=jar \
-DlocalRepositoryPath=path-to-specific-local-repo
I saw that you already found a way to automatically generate pom.xml with BND Tools.
https://amdatu.atlassian.net/browse/AMDATU-712

Should I write repositories in my pom.xml?

I am new to Maven. If I start new project with Maven, should I know any repository URLs for it to work?
For example, this Hibernate tutorial http://docs.jboss.org/hibernate/core/3.3/reference/en/html/tutorial.html says about how to create a sample project with pom.xml text. But this pom.xml does not contain any repositories.
So, my m2eclipse plugin says, for example Project build error: 'dependencies.dependency.version' for org.hibernate:hibernate-core:jar is missing., for all dependency tag in pom.xml
Is this because of repositories absence?
Where to know repositories URLs? Is there one big repository? Why doesn't it included by default?
UPDATE 1
It is said here, that Maven should use "central" repository by default: http://maven.apache.org/guides/introduction/introduction-to-repositories.html
I have searched there for hibernate-code artifact and found it. So, this artifact IS in central repository. By my maven says dependency not found. Hence it doesn't use it's central repository. Why?
Apparently your Hibernate dependency is missing <version> tag:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.9.Final</version> <!-- this line is missing -->
</dependency>
Note that you don't have to specify version of dependencies previously declared in <dependencyManagement>.
Old answer:
Every build script (not only with Maven) should be reproducible and independent from environment. Standard pom.xml (called super pom), which every pom.xml inherits from, already defines main Maven central repository:
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>https://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
You don't have to define this repository, and you don't have to define any others if all your dependencies are there. On the other hand if you are using some external repositories, you must add them to pom.xml, so that every developer is always able to build.
The bottom line is: if you can build the project having a completely empty repository, your pom.xml is fine.
It's not advisable to define repositories in POM files as that causes a lot of issues (Maven will search those repositories for ANY artifact even the ones available at Central, poor portability, ...)
Best approach: Setup a repository manager (Artifactory, Nexus) and edit your settings.xml file to use the repo manager as a mirror.
Second best approach: Define the required repositories in your settings.xml file, not in your pom.xml files.
Repositories in poms is a bad idea.

Resources