Remove compilation errors
diff --git a/src/main/java/org/apache/sling/feature/resolver/ApplicationResolverAssembler.java b/src/main/java/org/apache/sling/feature/resolver/ApplicationResolverAssembler.java
deleted file mode 100644
index aa60735..0000000
--- a/src/main/java/org/apache/sling/feature/resolver/ApplicationResolverAssembler.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * 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.
- */
-package org.apache.sling.feature.resolver;
-
-import org.apache.sling.feature.Application;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.builder.ApplicationBuilder;
-import org.apache.sling.feature.builder.BuilderContext;
-import org.apache.sling.feature.builder.FeatureProvider;
-import org.apache.sling.feature.io.ArtifactManager;
-import org.apache.sling.feature.io.IOUtils;
-import org.apache.sling.feature.io.file.ArtifactHandler;
-import org.apache.sling.feature.io.json.FeatureJSONReader;
-import org.apache.sling.feature.io.json.FeatureJSONReader.SubstituteVariables;
-
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class ApplicationResolverAssembler {
- /**
- * Assemble an application based on the given files.
- *
- * Read the features and assemble the application
- * @param app The optional application to use as a base.
- * @param featureFiles The feature files.
- * @param artifactManager The artifact manager
- * @param fr
- * @return The assembled application
- * @throws IOException If a feature can't be read or no feature is found.
- */
- public static Application assembleApplication(
- Application app,
- final ArtifactManager artifactManager,
- final FeatureResolver fr,
- final String... featureFiles)
- throws IOException {
- final List<Feature> features = new ArrayList<>();
- for(final String initFile : featureFiles) {
- try {
- final Feature f = IOUtils.getFeature(initFile, artifactManager, SubstituteVariables.RESOLVE);
- features.add(f);
- } catch (Exception ex) {
- throw new IOException("Error reading feature: " + initFile, ex);
- }
- }
-
- return assembleApplication(app, artifactManager, fr, features.toArray(new Feature[0]));
- }
-
- public static Feature[] sortFeatures(final FeatureResolver fr,
- final Feature... features) {
- final List<Feature> featureList = new ArrayList<>();
- for(final Feature f : features) {
- featureList.add(f);
- }
-
- final List<Feature> sortedFeatures;
- if (fr != null) {
- // order by dependency chain
- final List<FeatureResource> sortedResources = fr.orderResources(featureList);
-
- sortedFeatures = new ArrayList<>();
- for (final FeatureResource rsrc : sortedResources) {
- Feature f = rsrc.getFeature();
- if (f != null && !sortedFeatures.contains(f)) {
- sortedFeatures.add(rsrc.getFeature());
- }
- }
- } else {
- sortedFeatures = featureList;
- Collections.sort(sortedFeatures);
- }
- return sortedFeatures.toArray(new Feature[sortedFeatures.size()]);
- }
-
- public static Application assembleApplication(
- Application app,
- final ArtifactManager artifactManager,
- final FeatureResolver fr,
- final Feature... features)
- throws IOException {
- if ( features.length == 0 ) {
- throw new IOException("No features found.");
- }
-
- app = ApplicationBuilder.assemble(app, new BuilderContext(new FeatureProvider() {
-
- @Override
- public Feature provide(final ArtifactId id) {
- try {
- final ArtifactHandler handler = artifactManager.getArtifactHandler("mvn:" + id.toMvnPath());
- try (final FileReader r = new FileReader(handler.getFile())) {
- final Feature f = FeatureJSONReader.read(r, handler.getUrl(), SubstituteVariables.RESOLVE);
- return f;
- }
-
- } catch (final IOException e) {
- // ignore
- }
- return null;
- }
- }), sortFeatures(fr, features));
-
- // check framework
- if ( app.getFramework() == null ) {
- // use hard coded Apache Felix
- app.setFramework(IOUtils.getFelixFrameworkId(null));
- }
-
- return app;
- }
-}
diff --git a/src/main/java/org/apache/sling/feature/resolver/FrameworkResolver.java b/src/main/java/org/apache/sling/feature/resolver/FrameworkResolver.java
index 2478bd5..c8e5e40 100644
--- a/src/main/java/org/apache/sling/feature/resolver/FrameworkResolver.java
+++ b/src/main/java/org/apache/sling/feature/resolver/FrameworkResolver.java
@@ -32,7 +32,7 @@
import org.apache.sling.feature.Artifact;
import org.apache.sling.feature.ArtifactId;
import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.io.ArtifactManager;
+import org.apache.sling.feature.io.file.ArtifactManager;
import org.apache.sling.feature.resolver.impl.BundleResourceImpl;
import org.apache.sling.feature.resolver.impl.FeatureResourceImpl;
import org.apache.sling.feature.resolver.impl.ResolveContextImpl;
diff --git a/src/test/java/org/apache/sling/feature/resolver/AnalyserTest.java b/src/test/java/org/apache/sling/feature/resolver/AnalyserTest.java
deleted file mode 100644
index 8768ae2..0000000
--- a/src/test/java/org/apache/sling/feature/resolver/AnalyserTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.
- */
-package org.apache.sling.feature.resolver;
-
-import org.apache.sling.feature.Application;
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.analyser.Analyser;
-import org.apache.sling.feature.io.ArtifactManager;
-import org.apache.sling.feature.io.file.ArtifactManagerConfig;
-import org.apache.sling.feature.io.json.FeatureJSONReader;
-import org.apache.sling.feature.io.json.FeatureJSONReader.SubstituteVariables;
-import org.apache.sling.feature.scanner.BundleDescriptor;
-import org.apache.sling.feature.scanner.Scanner;
-import org.apache.sling.feature.scanner.impl.BundleDescriptorImpl;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.fail;
-
-public class AnalyserTest {
- @Test
- public void testAnalyserWithCompleteFeature() throws Exception {
- final Scanner scanner = new Scanner(new ArtifactManagerConfig());
- final Analyser analyser = new Analyser(scanner);
- try ( final Reader reader = new InputStreamReader(AnalyserTest.class.getResourceAsStream("/feature_complete.json"),
- "UTF-8") ) {
- Feature feature = FeatureJSONReader.read(reader, "feature", SubstituteVariables.RESOLVE);
-
- Application app = ApplicationResolverAssembler.assembleApplication(null, ArtifactManager.getArtifactManager(new ArtifactManagerConfig()),
- getTestResolver(), feature);
-
- analyser.analyse(app);
- }
- }
-
- @Test
- public void testAnalyserWithInCompleteFeature() throws Exception {
- final Scanner scanner = new Scanner(new ArtifactManagerConfig());
- final Analyser analyser = new Analyser(scanner);
- try ( final Reader reader = new InputStreamReader(AnalyserTest.class.getResourceAsStream("/feature_incomplete.json"),
- "UTF-8") ) {
- Feature feature = FeatureJSONReader.read(reader, "feature", SubstituteVariables.RESOLVE);
-
- Application app = ApplicationResolverAssembler.assembleApplication(null, ArtifactManager.getArtifactManager(new ArtifactManagerConfig()),
- getTestResolver(), feature);
-
- try {
- analyser.analyse(app);
-
- fail("Expected an exception");
- }
- catch (Exception ex) {
- // Pass
- }
- }
- }
-
- private FeatureResolver getTestResolver() {
- return new FeatureResolver() {
- @Override
- public void close() throws Exception {
- }
-
- @Override
- public List<FeatureResource> orderResources(List<Feature> features) {
- try {
- // Just return the resources in the same order as they are listed in the features
- List<FeatureResource> l = new ArrayList<>();
-
- for (Feature f : features) {
- for (Artifact a : f.getBundles()) {
- BundleDescriptor bd = getBundleDescriptor(ArtifactManager.getArtifactManager(new ArtifactManagerConfig()), a);
- l.add(new TestBundleResourceImpl(bd, f));
- }
- }
-
- return l;
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- private BundleDescriptor getBundleDescriptor(ArtifactManager artifactManager, Artifact b) throws IOException {
- final File file = artifactManager.getArtifactHandler(b.getId().toMvnUrl()).getFile();
- if ( file == null ) {
- throw new IOException("Unable to find file for " + b.getId());
- }
-
- return new BundleDescriptorImpl(b, file, -1);
- }
- };
- }
-}
diff --git a/src/test/java/org/apache/sling/feature/resolver/FrameworkResolverTest.java b/src/test/java/org/apache/sling/feature/resolver/FrameworkResolverTest.java
index 6c2b479..35ba24e 100644
--- a/src/test/java/org/apache/sling/feature/resolver/FrameworkResolverTest.java
+++ b/src/test/java/org/apache/sling/feature/resolver/FrameworkResolverTest.java
@@ -16,18 +16,7 @@
*/
package org.apache.sling.feature.resolver;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.io.ArtifactManager;
-import org.apache.sling.feature.io.file.ArtifactHandler;
-import org.apache.sling.feature.io.file.ArtifactManagerConfig;
-import org.apache.sling.feature.io.json.FeatureJSONReader;
-import org.apache.sling.feature.io.json.FeatureJSONReader.SubstituteVariables;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.osgi.framework.Constants;
-import org.osgi.framework.namespace.IdentityNamespace;
+import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.FileReader;
@@ -39,7 +28,17 @@
import java.util.Comparator;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.io.file.ArtifactHandler;
+import org.apache.sling.feature.io.file.ArtifactManager;
+import org.apache.sling.feature.io.file.ArtifactManagerConfig;
+import org.apache.sling.feature.io.json.FeatureJSONReader;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.osgi.framework.Constants;
+import org.osgi.framework.namespace.IdentityNamespace;
public class FrameworkResolverTest {
private Path tempDir;
@@ -142,7 +141,7 @@
final ArtifactHandler featureArtifact = artifactManager.getArtifactHandler(file);
try (final FileReader r = new FileReader(featureArtifact.getFile())) {
- final Feature f = FeatureJSONReader.read(r, featureArtifact.getUrl(), SubstituteVariables.RESOLVE);
+ final Feature f = FeatureJSONReader.read(r, featureArtifact.getUrl());
return f;
}
}