Maven Amdatu Bundle Remote Repository - maven

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

Related

Maven import dependency Jetbrains Exposed

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>

Setup AEM Adobe CQ5 6.1 project to build/install offline

I'm new to CQ5 and looking for steps/settings I may need to do to setup an AEM adobe CQ5 6.1 project to build/install offline (not connected to internet).
I've to use our internal network Nexus (which has lot of general dependencies available except AEM related).
I've to use Maven & Java7.
Looking for possible issues/resolutions, steps & any helpful info.
Thanks all for your inputs.
After a detailed investigation, this is now resolved. Just want to share the findings so that it may help others.
The content-package-maven-plugin which was uploaded to our local nexus got corrupted.
Interestingly maven was not throwing any errors when i was trying mvn install command on my AEM project. Rather it was giving NoClassDefFound error for a further dependency of content-package-maven-plugin.
From the output of, mvn dependency:resolve-plugins, it was confirmed that the dependencies are not fully resolved for particular this plugin JAR, I tried to manually download the artifact from nexus & try to open/unjar it.
The artifact pom was corrupted and hence I uploaded the fresh artifact in nexus, and this time all went smooth.
My AEM project is now building fine with local nexus dependencies.
a typical AEM project does have lots of dependencies. There are some dependencies for the AEM platform(including granite, sling, osgi etc). These dependencies are downloaded from the adobe public repositories, unless you have a nexus repository in your company where all these dependencies are available.
If your Organization specific Nexus repository can connect to internet and download dependencies (AEM and non AEM related) atleast for the first time , then you do not need to connect to internet from your local sand box.
Theoretically, your organization specific nexus repo also might not be
connected to the internet and all the JARs can be uploaded to Nexus
manually. But, that would be the last thing I will do in my life !
Your project can download all the dependencies from the Nexus repo(only) in multiple ways.
Configure the repository configuration in your pom.xml file to point
to your internal Nexus repo.
<repositories>
<repository>
<id>internal</id>
<name>Internal Public Repository</name>
<url>URL to the public repository of your internal nexus</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>internal</id>
<name>Internal Public Repository</name>
<url>URL to the public repository of your internal nexus</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
Change your Maven settings (settings.xml) to use your internal Nexus
every time it downloads dependencies (Recommened).
settings.xml can be found in your <user>/.m2 directory or <maven-installation>/conf
<mirrors>
<mirror>
<id>public</id>
<mirrorOf>*</mirrorOf>
<url>URL to the public repository of your internal nexus</url>
</mirror>
</mirrors>

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.

How to deploy maven project with parent packaging pom

I'm trying to deploy a maven web app with two modules and I tried using mvn package to get a war. Instead I got a pom.xml for the parent app and two jars for the submodules. That's...that's just great. How do I deploy that? I was expecting a war. Also, trying to deploy to jboss.
Edit: What goes in web.xml?
Make sure that your sub-modules declare <packaging>war</packaging>.
If you define not a packaging-type maven will choose jar as default.
If your parent-pom defines your modules it should be a POM as packaging (guess the parent-pom is in 99.9% cases POM as packaging-type). So as result for the parent-pom you get just a pom.xml.
For deploy you need to specifiy a <distributionManagent>.
<distributionManagement>
<repository>
<id>corp1</id>
<name>Corporate Repository</name>
<url>scp://repo/maven2</url>
</repository>
</distributionManagement>
For username and password i prefer to declare a <server> in the ~/.m2/settings.xml
so your password is not public for everyone.
I recommend to look into the maven-book from Sonatype.
If this don't help, please edit your post and insert your POMs.
Here is a good reference for building multi-module project from Maven into one war file.
The war file can be deployed via jboss-maven plugin.

Maven: Manually install a Jar from local folder and then go online and grab & install all its dependencies

In my project's pom file I have a dependency that I can see in Maven central repository, javax.enterprise:cdi-api:jar:1.0-SP4 but for some reason I am getting on some of my computers the following error while building the project (hence the build fails):
[INFO] Unable to find resource 'javax.enterprise:cdi-api:jar:1.0-SP4' in repository central (http://repo1.maven.org/maven2)
Any idea why I get this error only on some of my computers (I can say all the computers are using the same network)?
Why do I get this error at all? As far as I can see the jar IS in the maven central repository.
Even though maven could not locate/download the jar on some of the computers, I was able to download it manually through the browser on these computers. How could it be?
Okay, so I've downloaded the jar manually through the browser at one of the problematic computers. I want to install it manually to the local repository on this computer. So from the command line I do:
mvn install:install-file -DgroupId=javax.enterprise -DartifactId=cdi-api -Dversion=1.0-SP4 -Dpackaging=jar -Dfile=path/to/file
...but none of its dependencies has been downloaded as well. Is there some maven plugin to install the file to the local repository AND download & install all its dependencies to the local repository?
If so, please show me how to use it.
Please check in the computers where the jar are not downloaded if the settings.xml file present in .m2 folder is having the url of the jar needed. If not add them.
You are not able to download because maven searches in the urls defined in the settings.xml file only. So if the url is not present there, even if the jar is in the central repository it wont be downloaded.
In your browser you can navigate to that link and download. Maven wont be able to do it for the reason given in the second point
Ok, looks like you need to mention your repository path in your pom file, What is the url of the repository? is it local to your network or some open url? for example: http://repo2.mvn.org/???
Sample example would be like this::
<repositories>
<repository>
<id>codehausSnapshots</id>
<name>Codehaus Snapshots</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://snapshots.maven.codehaus.org/maven2</url>
<layout>default</layout>
</repository>
</repositories>
If you could paste the pom file, it would be easier to help you.
To answer your 3 point: Check the settings.xml file in .m2\settings.xml, make sure that same content is present. Sometimes settings.xml are modified directly in maven installation directory. so you better check in that location also.
To Answer your 4th point: mvn install:install installs (in simple terms copies) an artifact (jar/ear/zip/any artifact that meant for distribution) into maven local repository or into remote repository. So in your command, you just tried to install only cdi-api jar.
Whenever you run mvn compile, mvn package, mvn install, maven will scan your pom file and downloads all dependency mentioned into your local repository. I would suggest you to look your local repository and see how is it creating directory structure.

Resources