2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
19 package org.apache.karaf.tooling.utils;
22 import java.util.Collection;
24 import org.apache.maven.artifact.Artifact;
25 import org.apache.maven.plugin.MojoExecutionException;
26 import org.apache.maven.plugin.MojoFailureException;
27 import org.apache.maven.plugin.logging.Log;
28 import org.apache.maven.project.MavenProject;
29 import org.apache.maven.project.ProjectBuildingRequest;
32 * <p>An interface for accessing available Aether subsystem (Sonatype for Maven 3.0.x or Eclipse for Maven 3.1.x)</p>
34 * <p>Some methods have {@link Object} parameters because they should be able to receive Aether classes from
35 * both Aether variants.</p>
37 public interface DependencyHelper {
39 public abstract Collection<LocalDependency> getLocalDependencies();
41 public abstract String getTreeListing();
43 public abstract void getDependencies(MavenProject project, boolean useTransitiveDependencies) throws MojoExecutionException;
45 public boolean isArtifactAFeature(Object artifact);
47 public abstract String getArtifactId(Object artifact);
49 public abstract String getBaseVersion(Object artifact);
51 public abstract String getGroupId(Object artifact);
53 public abstract String getClassifier(Object artifact);
55 public abstract File resolve(Object artifact, Log log);
57 public abstract File resolveById(String id, Log log) throws MojoFailureException;
59 public abstract void setRepositorySession(ProjectBuildingRequest request) throws MojoExecutionException;
62 * Convert a Maven <code>Artifact</code> into a PAX URL mvn format.
64 * @param artifact the Maven <code>Artifact</code>.
65 * @return the corresponding PAX URL mvn format (mvn:groupId/artifactId/version/type/classifier)
67 public String artifactToMvn(Artifact artifact, String versionOrRange) throws MojoExecutionException;
70 * Convert an Aether (Sonatype or Eclipse) artifact into a PAX URL mvn format.
72 * @param object the Aether <code>org.sonatype|eclipse.aether.artifact.Artifact</code>.
73 * @return the corresponding PAX URL mvn format (mvn:groupId/artifactId/version/type/classifier)
75 public String artifactToMvn(Object object, String versionOrRange) throws MojoExecutionException;
77 public Artifact mvnToArtifact(String name) throws MojoExecutionException;
80 * Convert a PAX URL mvn format into a filesystem path.
82 * @param name PAX URL mvn format (mvn:groupId/artifactId/version/type/classifier).
83 * @return a filesystem path.
85 public String pathFromMaven(String name) throws MojoExecutionException;
88 * Convert an Aether coordinate format into a filesystem path.
90 * @param name the Aether coordinate format (groupId:artifactId[:extension[:classifier]]:version).
91 * @return the filesystem path.
93 public String pathFromAether(String name) throws MojoExecutionException;