问题
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
?
回答1:
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
回答2:
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.
来源:https://stackoverflow.com/questions/52311946/how-to-add-new-features-to-opendaylight-karaf