Add .tox/ to .gitignore
[odlparent.git] / karaf / karaf-maven-plugin / src / main / java / org / apache / karaf / tooling / utils / DependencyHelper.java
1 /*
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
9  *
10  *  http://www.apache.org/licenses/LICENSE-2.0
11  *
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
17  * under the License.
18  */
19 package org.apache.karaf.tooling.utils;
20
21 import java.io.File;
22 import java.util.Collection;
23
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;
30
31 /**
32  * <p>An interface for accessing available Aether subsystem (Sonatype for Maven 3.0.x or Eclipse for Maven 3.1.x)</p>
33  *
34  * <p>Some methods have {@link Object} parameters because they should be able to receive Aether classes from
35  * both Aether variants.</p>
36  */
37 public interface DependencyHelper {
38
39     public abstract Collection<LocalDependency> getLocalDependencies();
40
41     public abstract String getTreeListing();
42
43     public abstract void getDependencies(MavenProject project, boolean useTransitiveDependencies) throws MojoExecutionException;
44
45     public boolean isArtifactAFeature(Object artifact);
46
47     public abstract String getArtifactId(Object artifact);
48
49         public abstract String getBaseVersion(Object artifact);
50
51         public abstract String getGroupId(Object artifact);
52     
53     public abstract String getClassifier(Object artifact);
54
55     public abstract File resolve(Object artifact, Log log);
56
57     public abstract File resolveById(String id, Log log) throws MojoFailureException;
58
59     public abstract void setRepositorySession(ProjectBuildingRequest request) throws MojoExecutionException;
60     
61     /**
62      * Convert a Maven <code>Artifact</code> into a PAX URL mvn format.
63      *
64      * @param artifact the Maven <code>Artifact</code>.
65      * @return the corresponding PAX URL mvn format (mvn:groupId/artifactId/version/type/classifier)
66      */
67     public String artifactToMvn(Artifact artifact, String versionOrRange) throws MojoExecutionException;
68
69     /**
70      * Convert an Aether (Sonatype or Eclipse) artifact into a PAX URL mvn format.
71      *
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)
74      */
75     public String artifactToMvn(Object object, String versionOrRange) throws MojoExecutionException;
76
77     public Artifact mvnToArtifact(String name) throws MojoExecutionException;
78
79     /**
80      * Convert a PAX URL mvn format into a filesystem path.
81      *
82      * @param name PAX URL mvn format (mvn:groupId/artifactId/version/type/classifier).
83      * @return a filesystem path.
84      */
85     public String pathFromMaven(String name) throws MojoExecutionException;
86
87     /**
88      * Convert an Aether coordinate format into a filesystem path.
89      *
90      * @param name the Aether coordinate format (groupId:artifactId[:extension[:classifier]]:version).
91      * @return the filesystem path.
92      */
93     public String pathFromAether(String name) throws MojoExecutionException;
94 }