How to add new features to OpenDayLight Karaf? - maven

How can I add new features to ODL Oxygen SR3 (0.8.3) as a Karaf module?
For example, I downloaded the prebuilt ODL from the official page. Then I'd like to make the Toaster sample as a new module for Oxygen, it was created with command:
wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml
mvn archetype:generate -DarchetypeGroupId=org.opendaylight.archetypes -DarchetypeArtifactId=opendaylight-startup-archetype -DarchetypeCatalog=remote -DarchetypeVersion=1.1.0-SNAPSHOT
After compiling, it would generate built files to a local maven repository (~/.m2/repository/com/example/toaster). I copied the com/example/toaster to the Karaf default repository folder ./karaf-0.8.3/system. Then I'd like to make it available in feature:list so I can install with feature:install toaster. First I need to add it to the repo list:
./karaf-0.8.3/bin/karaf
feature:repo-add mvn:com.example.toaster/features-toaster
Unfortunately it showed an error:
Error executing command: Error resolving artifact com.example.toaster:features-toaster:jar:0.1.0-SNAPSHOT:
[Could not find artifact com.example.toaster:features-toaster:jar:0.1.0-SNAPSHOT in opendaylight-snapshot (https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/)] : mvn:com.example.toaster/features-toaster
The above command is based on this post. What's the correct way to do repo-add?

Please read the https://karaf.apache.org/manual/latest/#_artifacts_repositories_and_urls
Article.
What you need to do is basically add the repo URl that contains your toaster to the package like so:
(Example from the documentation linked above)
<bundle>http://repo1.maven.org/maven2/org/apache/servicemix/nmr/org.apache.servicemix.nmr.api/1.0.0-m2/org.apache.servicemix.nmr.api-1.0.0-m2.jar</bundle>
Repositories can also be defined using properties:
org.ops4j.pax.url.mvn.repositories : Comma separated list of remote
repository URLs that are checked in order of occurence when resolving
maven artifacts
Source: https://karaf.apache.org/manual/latest/#_maven_url_handler

After building change configuration at the end of file karaf/target/assembly/etc/org.ops4j.pax.url.mvn.cfg into
org.ops4j.pax.url.mvn.repositories= \
file:${karaf.home}/${karaf.default.repository}#id=system.repository, \
file:${karaf.data}/kar#id=kar.repository#multi, \
https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot#id=opendaylight-snapshot#snapshots, \
https://nexus.opendaylight.org/content/repositories/public#id=opendaylight-mirror
Then you can add a repository with
feature:repo-add mvn:org.opendaylight.netconf/features-restconf/1.9.0-SNAPSHOT/xml/features
where groudId: org.opendaylight.netconf, artifactId: features-restconf and version: 1.9.0-SNAPSHOT are depending on the feature you want to add. You can search at https://nexus.opendaylight.org/ with Articfact Search for them and find them in the Maven pom.

Related

How to get latest artifact from artifactory?

I have artifacts in JFrog.
Example:
https://test.com/artifactory/users/data-config/1.0.0/user.json
https://test.com/artifactory/users/data-config/1.0.1/user.json
https://test.com/artifactory/users/data-config/2.0.0/user.json
Is there a way I can download the latest version using curl? Like in this case it will be
https://test.com/artifactory/users/data-config/2.0.0/user.json
Considering your comment that the files are not maven based, I assume it is deployed to a generic repository and irrespective of the file type, the only way to resolve the file via direct cURL is using the following command.
curl -u<USERNAME>:<PASSWORD> -O "http://<HOSTNAME>:<PORT>/artifactory/generic-repository/<TARGET_FILE_PATH>"
So, the target path name should be given completely when it is being resolved via direct download (API). i.e., The complete target file name manually.
However, for other package types such as a maven release or a snapshot, the available options are described here.
What are a few other additional options available?
Artifact Latest Version Search Based on Layout
, Artifact Latest Version Search Based on Properties

Is gradle stored in a nexus repo?

This is for downloading gradle itself. I'm trying to cache it inside a corporate network as easily as possible. If gradle is available in a nexus repo upstream, then I can point the distributionUrl for the wrapper to the internal nexus.
Maven is available in maven central which is convenient and I was trying to find a similar solution.
https://search.maven.org/search?q=g:org.apache.maven%20a:apache-maven
I did find but I was wondering if there was something more official.
https://github.com/hazendaz/gradle
https://search.maven.org/search?q=g:com.github.hazendaz.gradle%20a:gradle
Thanks for your time
When using Nexus you can create a raw (proxy) repository for https://services.gradle.org/distributions. This will proxy all requests.
In this instance the repository is named gradle-distributions. This allows you to use:
curl https://nexus.example-organisation.com/repository/gradle-distributions/gradle-6.9.1-wrapper.jar.sha256
e996d452d2645e70c01c11143ca2d3742734a28da2bf61f25c82bdc288c9e637
Instead of:
curl https://services.gradle.org/distributions/gradle-6.9.1-wrapper.jar.sha256
e996d452d2645e70c01c11143ca2d3742734a28da2bf61f25c82bdc288c9e637
So then in gradle-wrapper.properties you can use:
distributionUrl=https://nexus.example-organisation.com/repository/gradle-distributions/gradle-6.9.1-bin.zip
Unfortunately no. The Gradle Wrapper JAR is not published to a Maven repository such as Nexus.
You can see on this line where the actual download occurs. Digging further in you can see here Gradle uses lower level Java mechanisms to download the wrapper.
All Gradle distributions are available here: https://services.gradle.org/distributions/. If you look at the version information, there is a JSON file that contains what the latest release version is. I'm not entirely familiar with managing Nexus, but if you could somehow create a plugin of some sort to poll that version information, then you could download it if it's not already available/cached in Nexus.
The solution offered by M.P. Korstanje did not work for me directly, b/c my version of Nexus does not allow me to proxy raw websites. However, I was able to achieve similar functionality by creating a Hosted "Site" repository, and then uploading the Gradle bin zips to my repo with this script:
#/bin/bash
#
# This helper script will upload any file to 'Gradle Distributions' Nexus repo
#
NEXUS_ADMIN_USER=$1
GRADLE_BIN_ZIP_FILE=$2
if [ -z "$NEXUS_ADMIN_USER" ] \
|| [ -z "$GRADLE_BIN_ZIP_FILE" ]
then
echo "$0 <NEXUS_ADMIN_USER> <GRADLE_BIN_ZIP_FILE>"
exit 1
fi
curl -v \
--user $NEXUS_ADMIN_USER \
--upload-file $GRADLE_BIN_ZIP_FILE \
http://nexus-host:8081/nexus/content/sites/gradle-distributions/$GRADLE_BIN_ZIP_FILE
So now all of the approved Gradle distros are available at a Nexus-managed URL:
http://nexus-host:8081/nexus/content/sites/gradle-distributions/
├── gradle-3.5.1-bin.zip
├── gradle-7.4.1-bin.zip
├── gradle-7.4.2-bin.zip
└── upload_gradle_distro.sh
The last step is to modify gradle/wrapper/gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=http\://nexus-host\:8081/nexus/content/sites/gradle-distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

jdb maven: InstallMojo source

I try to debug install::install using mvnDebug/jdb -attach 8000
I get easily to org.apache.maven.plugin.DefaultBuildPluginManager:101
and then step on mojo.execute() which leads me to:
main[1] where
[1] org.apache.maven.plugin.install.InstallMojo.execute (InstallMojo.java:76)
[2] org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:101)
...
I find the sources for InstallMojo.java from svn, but how should I know what tag to checkout?
Thanks,
Marc
Based on the given information you are using the 2.3.1 version of the maven-install-plugin you can simply read the pom file of that particular version which means search for that version in maven central. And the pom file will give you the information you need:
Excerpt:
<scm><connection>scm:svn:http://svn.apache.org/repos/asf/maven/plugins/tags/maven-install-plugin-2.3.1</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/maven/plugins/tags/maven-install-plugin-2.3.1</developerConnection>
This gives you the exact location of the SVN Tag in the apache SVN repository and of course the correct location which you can checkout.

How to index a Maven repo without Nexus/Artifactory/etc?

I run my own little Maven repo for some open source. I have no dedicated server so I use a Google code repository, deploy to file system and then commit and push. Works perfect for me.
But some Maven tools are looking for a nexus-maven-repository-index.properties and the index (in GZ). I would like to generate this index to
get rid of the warning that it's not here
Maven doesn't try the repo for artefacts that are not there.
How can I do that? Is there a tool (Java main) that is able to generate an index? Also tips how to use the proper Nexus Jars with a little commandline tool are welcome.
I came across this post while I was searching for a solution to add a local repository to my Maven project using IntelliJ Idea.
Since Sonatype changed their paths and reorganized the downloads since the last post, here is an updated step-by-step tutorial to get your repository indexed for use with IntelliJ Idea:
Download the latest stand-alone indexer from here.
Extract it somewhere and go into this directory
From the console, run this command: export REPODIR=/path/to/your/local/repo/ && java org.sonatype.nexus.index.cli.NexusIndexerCli -r $REPODIR -i $REPODIR/.index -d $REPODIR/.index -n localrepo
In the directory .index within the repository directory, some files will be created including the file "nexus-maven-repository-index.gz" which is the file IntelliJ looks out for.
You can use the Maven Indexer CLI to product the index directly, but why bother hosting your own repo when OSS projects can use a hosted one for free?
http://nexus.sonatype.org/oss-repository-hosting.html
I was looking at maven indexer... but I am not sure what for is the last parameter indexDir in the method:
public RepositoryIndexer createRepositoryIndexer(String repositoryId,
File repositoryBasedir,
File indexDir)
is it like starting point in the repositoryBasedir?

How to get spring's javadoc in one jar/zip file

Actually, I want to integrate spring javadoc with my netbeans IDE. Spring website only provides an HTML version javadoc online, no download link. But Netbeans only accept a jar/zip file or a local folder.
I know I can build it myself from spring source, but would rather not go through the work.
You can download from this location http://repo.spring.io/libs-release/org/springframework/spring/
You need the -with-docs.zip download
http://www.springsource.com/download/community
It seems the downloads are now managed with Maven only, however, if you want a copy of the JavaDocs locally you could use wget on the JavaDoc URL.
e.g. For release 3.0.5.RELEASE this works a treat.
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--domains docs.spring.io \
--no-parent \
http://docs.spring.io/spring/docs/3.0.5.RELEASE/javadoc-api/
Or you can just grab the version with source code (which is even better in your IDE anyway).
Sign up over at http://www.springsource.com or just grab it from a maven repository like this one:
http://www.jarvana.com/jarvana/browse/org/springframework/spring-jdbc/
Just grab the release you want (like 2.5.6/spring-jdbc-2.5.6-sources.jar), save to disk, and in Netbeans right-click on your library and select "add local sources".
/ Papa Freud
Using of Maven works for me. In the directory with pom.xml type the command:
mvn dependency:sources -DincludeArtifactIds=spring-aop -Dclassifier=javadoc
After that the jar is available in the ~/.m2 directory.
Now Spring uses artifactory.
Go to corresponding folder for further download.
http://repo.spring.io/webapp/browserepo.html?24

Resources