Skip to content

Commit e7b107f

Browse files
committed
Move OSGi caches to target directory
1 parent e3a2559 commit e7b107f

File tree

3 files changed

+57
-13
lines changed

3 files changed

+57
-13
lines changed

log4j-osgi-test/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@
136136
</dependency>
137137
</dependencies>
138138
<build>
139+
<testResources>
140+
<testResource>
141+
<!-- Enable variable interpolation in resources -->
142+
<filtering>true</filtering>
143+
<directory>src/test/resources</directory>
144+
</testResource>
145+
</testResources>
139146
<plugins>
140147

141148
<!--
@@ -192,6 +199,15 @@
192199
</configuration>
193200
</plugin>
194201

202+
<plugin>
203+
<groupId>org.apache.maven.plugins</groupId>
204+
<artifactId>maven-resources-plugin</artifactId>
205+
<configuration>
206+
<!-- Property files must be encoded in ISO-8859-1 -->
207+
<propertiesEncoding>ISO-8859-1</propertiesEncoding>
208+
</configuration>
209+
</plugin>
210+
195211
<plugin>
196212
<groupId>org.apache.maven.plugins</groupId>
197213
<artifactId>maven-surefire-plugin</artifactId>

log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/OsgiRule.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
*/
1717
package org.apache.logging.log4j.osgi.tests;
1818

19+
import java.io.InputStream;
1920
import java.util.HashMap;
2021
import java.util.Map;
22+
import java.util.Properties;
23+
import java.util.stream.Collectors;
2124
import org.junit.rules.ExternalResource;
2225
import org.osgi.framework.BundleException;
2326
import org.osgi.framework.launch.Framework;
@@ -29,7 +32,6 @@
2932
class OsgiRule extends ExternalResource {
3033

3134
private final FrameworkFactory factory;
32-
3335
private Framework framework;
3436

3537
OsgiRule(final FrameworkFactory factory) {
@@ -51,18 +53,19 @@ protected void after() {
5153

5254
@Override
5355
protected void before() throws Throwable {
54-
final Map<String, String> configMap = new HashMap<>();
55-
// Cleans framework before first init. Subsequent init invocations do not clean framework.
56-
configMap.put("org.osgi.framework.storage.clean", "onFirstInit");
57-
configMap.put("felix.log.level", "4");
58-
configMap.put("eclipse.log.level", "ALL");
59-
// Hack to get the build working on Windows. Could try newer versions of Felix.
60-
configMap.put("felix.cache.locking", "false");
61-
// Delegates loading of endorsed libraries to JVM classloader
62-
// config.put("org.osgi.framework.bootdelegation", "javax.*,org.w3c.*,org.xml.*");
63-
framework = factory.newFramework(configMap);
64-
framework.init();
65-
framework.start();
56+
try (final InputStream is = OsgiRule.class.getResourceAsStream("/osgi.properties")) {
57+
final Properties props = new Properties();
58+
props.load(is);
59+
final Map<String, String> configMap = props.entrySet().stream()
60+
.collect(Collectors.toMap(
61+
e -> String.valueOf(e.getKey()),
62+
e -> String.valueOf(e.getValue()),
63+
(prev, next) -> next,
64+
HashMap::new));
65+
framework = factory.newFramework(configMap);
66+
framework.init();
67+
framework.start();
68+
}
6669
}
6770

6871
public Framework getFramework() {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to you under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
org.osgi.framework.storage.clean = onFirstInit
18+
felix.log.level = 4
19+
eclipse.log.level = ALL
20+
# Hack to get the build working on Windows. Could try newer versions of Felix.
21+
felix.cache.locking = false
22+
# Location of `felix-cache` directory
23+
felix.cache.rootdir = @project.build.directory@
24+
# Location of Equinox's cache
25+
osgi.configuration.area= @project.build.directory@/equinox-cache

0 commit comments

Comments
 (0)