Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions assemblies/apache-karaf-light/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
</installedFeatures>
<startupFeatures>
<feature>eventadmin</feature>
<feature>url</feature>
</startupFeatures>
<bootFeatures>
<feature>wrap</feature>
Expand All @@ -176,6 +177,12 @@
<feature>service</feature>
<feature>system</feature>
</bootFeatures>
<!-- the mvn: and wrap: protocols, and the Maven resolver of the features service, are provided by the Karaf URL service (url feature) -->
<blacklistedBundles>
<bundle>mvn:org.ops4j.pax.url/pax-url-aether</bundle>
<bundle>mvn:org.ops4j.pax.url/pax-url-wrap</bundle>
<bundle>mvn:org.apache.karaf.maven/org.apache.karaf.maven.resolver.paxurl</bundle>
</blacklistedBundles>
<libraries>
</libraries>
<javase>17</javase>
Expand All @@ -200,6 +207,21 @@
</target>
</configuration>
</execution>
<execution>
<id>remove-pax-url</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!-- provided by the framework KAR, but not used with the Karaf URL service -->
<delete dir="${project.build.directory}/assembly/system/org/ops4j/pax/url" />
<delete dir="${project.build.directory}/assembly/system/org/apache/karaf/maven/org.apache.karaf.maven.resolver.paxurl" />
<delete file="${project.build.directory}/assembly/etc/org.ops4j.pax.url.mvn.cfg" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Expand Down Expand Up @@ -231,6 +253,10 @@
<id>use-simple-resolver</id>
<phase>none</phase>
</execution>
<execution>
<id>remove-pax-url</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
Expand Down
7 changes: 7 additions & 0 deletions assemblies/apache-karaf-light/src/main/distribution/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ License: Apache License 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt

-----------------------------------------------------------------------------

This product bundles bnd.

Project URL: https://bnd.bndtools.org/
License: Apache License 2.0 - https://www.apache.org/licenses/LICENSE-2.0.txt

-----------------------------------------------------------------------------

This product bundles istack-common-runtime.

Project URL: https://github.com/eclipse-ee4j/jaxb-istack-commons
Expand Down
4 changes: 4 additions & 0 deletions assemblies/apache-karaf-light/src/main/distribution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ requirements/capabilities, which is faster and deterministic at the cost of not
requirements, conditional features, and resource repositories. See the provisioning section of the
[documentation](https://karaf.apache.org/manual/latest/#_feature_and_resolver) for details.

The light distribution also uses the Karaf URL service instead of Pax URL to provide the `mvn:` and `wrap:`
protocols, and to resolve the Maven artifacts of the features. The Maven repositories are configured in
`etc/org.apache.karaf.url.mvn.cfg`.

## Prerequisites

Apache Karaf requires a Java SE 11 or higher to run.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ org.apache.aries.proxy.weaving.enabled=
# mvn url handler requires config instance configuration
#
org.ops4j.pax.url.mvn.requireConfigAdminConfig=true
org.apache.karaf.url.mvn.requireConfigAdminConfig=true

#
# Don't delay the console startup. Set to true if you want the console to start after all other bundles
Expand Down
7 changes: 7 additions & 0 deletions assemblies/features/standard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,13 @@
<scope>provided</scope>
</dependency>

<!-- url deps -->
<dependency>
<groupId>org.apache.karaf.services</groupId>
<artifactId>org.apache.karaf.services.url</artifactId>
<scope>provided</scope>
</dependency>

<!-- jasypt-encryption deps -->
<dependency>
<groupId>org.jasypt</groupId>
Expand Down
90 changes: 90 additions & 0 deletions assemblies/features/standard/src/main/feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,96 @@ org.apache.felix.eventadmin.AddSubject=true
</capability>
</feature>

<feature name="url" description="Karaf URL handlers (mvn: and wrap: protocols)" version="${project.version}">
<config name="org.apache.karaf.url.mvn">
################################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################

#
# Apache Karaf Maven URL Handler configuration
#
# This replaces the pax-url-mvn configuration with a native Karaf implementation.
# Property names are compatible with org.ops4j.pax.url.mvn.* for easier migration.
#

# If set to true, SSL certificate validation is enforced when accessing
# Maven repositories through HTTPS
#
org.apache.karaf.url.mvn.certificateCheck = true

#
# Path to the local Maven repository which is used to avoid downloading
# artifacts when they already exist locally.
# Defaults to: ${user.home}/.m2/repository
#
#org.apache.karaf.url.mvn.localRepository =

#
# Comma separated list of default repositories (local, file-based).
# These are checked first, before the local repository and remote repositories.
# A repository URL can be appended with:
# @snapshots : the repository contains snapshots
# @noreleases : the repository does not contain releases
# @id=repo.id : the repository identifier
#
org.apache.karaf.url.mvn.defaultRepositories = \
${karaf.home.uri}${karaf.default.repository}@id=system.repository@snapshots, \
${karaf.data.uri}kar@id=kar.repository@multi@snapshots, \
${karaf.base.uri}${karaf.default.repository}@id=child.system.repository@snapshots

#
# Comma separated list of remote repositories.
# These are accessed via HTTP/HTTPS when the artifact is not found locally.
# A repository URL can be appended with:
# @snapshots : the repository contains snapshots
# @noreleases : the repository does not contain releases
# @id=repo.id : the repository identifier
#
org.apache.karaf.url.mvn.repositories = \
https://repo1.maven.org/maven2@id=central, \
https://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases

#
# Global update policy: always, daily, interval:NNN (minutes), never
#
#org.apache.karaf.url.mvn.globalUpdatePolicy = daily

#
# Global checksum policy: warn, fail, ignore
#
#org.apache.karaf.url.mvn.globalChecksumPolicy = warn

#
# Connection and socket timeouts
#
org.apache.karaf.url.mvn.timeout = 5000
org.apache.karaf.url.mvn.socket.connectionTimeout = 5000
org.apache.karaf.url.mvn.socket.readTimeout = 30000

#
# Number of connection retries after failure
#
org.apache.karaf.url.mvn.connection.retryCount = 3
</config>
<bundle start-level="5">mvn:org.apache.karaf.services/org.apache.karaf.services.url/${project.version}</bundle>
</feature>

<feature name="pax-url-wrap" description="Wrap URL handler" version="${pax.url.version}">
<bundle dependency="true">mvn:org.ops4j.pax.logging/pax-logging-api/${pax.logging.version}</bundle>
<bundle start-level="10">mvn:org.ops4j.pax.url/pax-url-wrap/${pax.url.version}/jar/uber</bundle>
Expand Down
5 changes: 5 additions & 0 deletions bom/artifacts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,11 @@
<artifactId>org.apache.karaf.services.staticcm</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.karaf.services</groupId>
<artifactId>org.apache.karaf.services.url</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.karaf.shell</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,21 @@ public synchronized Instance createInstance(final String name, final InstanceSet
File rootEtc = new File(System.getProperty("karaf.etc"));
copy(new File(rootEtc, "startup.properties"), new File(karafBase, "etc/startup.properties"));

// the startup.properties of the root instance may use the Karaf URL service, which needs its configuration
File rootUrlConfig = new File(rootEtc, "org.apache.karaf.url.mvn.cfg");
if (rootUrlConfig.exists()) {
copy(rootUrlConfig, new File(karafBase, "etc/org.apache.karaf.url.mvn.cfg"));
}

// align child with any bundles we have overriden in the root instance
File rootOverrides = new File(rootEtc, "overrides.properties");
if (rootOverrides.exists()) {
copy(rootOverrides, new File(karafBase, "etc/overrides.properties"));
}
File rootFeaturesProcessing = new File(rootEtc, "org.apache.karaf.features.xml");
if (rootFeaturesProcessing.exists()) {
copy(rootFeaturesProcessing, new File(karafBase, "etc/org.apache.karaf.features.xml"));
}

HashMap<String, String> props = new HashMap<>();
props.put("${SUBST-KARAF-NAME}", name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ org.apache.aries.proxy.weaving.enabled=
# mvn url handler requires config instance configuration
#
org.ops4j.pax.url.mvn.requireConfigAdminConfig=true
org.apache.karaf.url.mvn.requireConfigAdminConfig=true

#
# Don't delay the console startup. Set to true if you want the console to start after all other bundles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public void testConfigurationFiles() throws Exception {
assertFileExists(instance.getLocation(), "etc/org.apache.karaf.management.cfg");
assertFileExists(instance.getLocation(), "etc/org.ops4j.pax.logging.cfg");
assertFileExists(instance.getLocation(), "etc/org.ops4j.pax.url.mvn.cfg");

// files aligned with the root instance
assertFileExists(instance.getLocation(), "etc/org.apache.karaf.url.mvn.cfg");
assertFileExists(instance.getLocation(), "etc/org.apache.karaf.features.xml");
}

public void testTextResources() throws Exception {
Expand Down
23 changes: 23 additions & 0 deletions instance/src/test/resources/etc/org.apache.karaf.features.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<featuresProcessing xmlns="http://karaf.apache.org/xmlns/features-processing/v1.0.0">
<blacklistedBundles>
<bundle>mvn:org.ops4j.pax.url/pax-url-aether</bundle>
</blacklistedBundles>
</featuresProcessing>
20 changes: 20 additions & 0 deletions instance/src/test/resources/etc/org.apache.karaf.url.mvn.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
################################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################

org.apache.karaf.url.mvn.defaultRepositories = ${karaf.home.uri}${karaf.default.repository}@id=system.repository
5 changes: 5 additions & 0 deletions manual/src/main/asciidoc/developer-guide/extending.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ and it is configured with `etc/org.ops4j.pax.url.mvn.cfg` (see <<_maven_url_hand

You can replace this bundle with your own provider, for instance to create a distribution which does not contain Pax URL.

Apache Karaf provides another implementation, which does not depend on Pax URL: the `org.apache.karaf.services.url` bundle,
installed by the `url` feature. Besides the Maven resolver, it provides the `mvn` and `wrap` URL handlers, and it is
configured with `etc/org.apache.karaf.url.mvn.cfg`. The `apache-karaf-light` distribution uses it as a startup feature,
and blacklists the Pax URL bundles and the `org.apache.karaf.maven.resolver.paxurl` provider.

===== Contract

A provider implements two interfaces:
Expand Down
1 change: 1 addition & 0 deletions services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<module>eventadmin</module>
<module>staticcm</module>
<module>interceptor</module>
<module>url</module>
</modules>

</project>
Expand Down
Loading
Loading