Created
August 15, 2011 12:08
-
-
Save joserodolfofreitas/1146103 to your computer and use it in GitHub Desktop.
gathering api info for review and discuss.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Describes Maven Resolution Element. | |
* | |
* Contract encapsulates Maven dependency as known from POM files. | |
* | |
*/ | |
public interface MavenDependency extends ResolutionElement<MavenDependency> | |
{ | |
/** | |
* Sets coordinates. | |
* @param coordinates The artifact coordinates in the format | |
* {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>} | |
* , must not be {@code null} or empty. | |
* @return Modified instance for chaining | |
*/ | |
MavenDependency setCoordinates(String coordinates); | |
/** | |
* Gets coordinates of the dependency | |
* @return The coordinates | |
*/ | |
String getCoordinates(); | |
/** | |
* Sets scope of the Maven dependency | |
* @param scope The scope to be set | |
* @return Modified instance for chaining | |
*/ | |
MavenDependency setScope(String scope); | |
/** | |
* Gets scope of the dependency | |
* @return The scope | |
*/ | |
String getScope(); | |
/** | |
* Adds one or more exclusions for current dependency | |
* @param exclusion Array of exclusions to be added, in form {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]} | |
* or {@code *} to exclude all transitive dependencies | |
* @return Modified instance for chaining | |
*/ | |
MavenDependency addExclusions(String... exclusion); | |
/** | |
* Gets all exclusions defined on the dependency | |
* @return Array of exclusions defined for the dependency | |
*/ | |
String[] getExclusions(); | |
/** | |
* Sets dependency as optional. | |
* @param optional The optional flag to set | |
* @return Modified instance for chaining | |
*/ | |
MavenDependency setOptional(boolean optional); | |
/** | |
* Gets optional flag. | |
* | |
* By default dependency is considered non-optional. | |
* @return {@code true} if dependency is optional,{@code false} otherwise | |
*/ | |
boolean isOptional(); | |
/** | |
* Checks if other dependency defined the same artifact, | |
* that is Maven will resolve the same artifact from the other dependency. | |
* | |
* <p> | |
* Coordinates cannot be compared directly, see reason below. | |
* </p> | |
* | |
* <p> | |
* To implement this method, developer must be aware that effectively | |
* @{code foo:bar:jar:1.0} and {@code foo:bar:1.0} are the same coordinates, | |
* because Maven considers jar as default extension. | |
* </p> | |
* | |
* @param other The other dependency | |
* @return {@code true} if other has the same artifact definition, {@code false} otherwise | |
*/ | |
boolean hasSameArtifactAs(MavenDependency other); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* An artifact builder is object which holds and construct dependencies and it is able to resolve them into an array of | |
* ShrinkWrap archives. | |
* | |
* Artifact builder allows chaining of artifacts, that is specifying a new artifact. In this case, currently constructed | |
* artifact is stored as a dependency and user is allowed to specify parameters for another artifact. | |
* | |
*/ | |
public interface MavenDependencyResolver extends | |
DependencyBuilder<MavenDependencyResolver>, | |
DependencyResolver<MavenResolutionFilter, MavenDependency> { | |
/** | |
* Configures Maven from a settings.xml file | |
* | |
* @param path | |
* A path to a settings.xml configuration file | |
* @return A dependency builder with a configuration from given file | |
*/ | |
MavenDependencyResolver configureFrom(String path); | |
/** | |
* Loads remote repositories for a POM file. If repositories are defined in | |
* the parent of the POM file and there are accessible via local file | |
* system, they are set as well. | |
* | |
* These remote repositories are used to resolve the artifacts during | |
* dependency resolution. | |
* | |
* Additionally, it loads dependencies defined in the POM file model in an | |
* internal cache, which can be later used to resolve an artifact without | |
* explicitly specifying its version. | |
* | |
* @param pathx | |
* A path to the POM file, must not be {@code null} or empty | |
* @return A dependency builder with remote repositories set according to | |
* the content of POM file. | |
* @throws Exception | |
*/ | |
MavenDependencyResolver loadMetadataFromPom(String path) throws ResolutionException; | |
/** | |
* Loads remote repositories for a POM file. If repositories are defined in | |
* the parent of the POM file and there are accessible via local file | |
* system, they are set as well. | |
* | |
* These remote repositories are used to resolve the artifacts during | |
* dependency resolution. | |
* | |
* Additionally, it loads dependencies defined in the POM file model in an | |
* internal cache, which can be later used to resolve an artifact without | |
* explicitly specifying its version. | |
* | |
* @param path | |
* A path to the POM file, must not be {@code null} or empty | |
* @return A dependency builder with remote repositories set according to | |
* the content of POM file. | |
* @throws Exception | |
* @deprecated please use {@link #loadMetadataFromPom(String)} instead | |
*/ | |
@Deprecated | |
MavenDependencyResolver loadReposFromPom(String path) throws ResolutionException; | |
/** | |
* Sets a scope of dependency | |
* | |
* @param scope A scope, for example @{code compile}, @{code test} and others | |
* @return Artifact builder with scope set | |
*/ | |
MavenDependencyResolver scope(String scope); | |
/** | |
* Sets dependency as optional. If dependency is marked as optional, it is | |
* always resolved, however, the dependency graph can later be filtered based | |
* on {@code optional} flag | |
* | |
* @param optional Optional flag | |
* @return Artifact builder with optional flag set | |
*/ | |
MavenDependencyResolver optional(boolean optional); | |
/** | |
* Adds an exclusion for current dependency. | |
* | |
* @param exclusion the exclusion to be added to list of artifacts to be | |
* excluded, specified in the format | |
* {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]}, an | |
* empty string or {@code *} will match all exclusions, you can | |
* pass an {@code *} instead of any part of the coordinates to | |
* match all possible values | |
* @return Artifact builder with added exclusion | |
*/ | |
MavenDependencyResolver exclusion(String exclusion); | |
/** | |
* Adds multiple exclusions for current dependency | |
* | |
* @param exclusions the exclusions to be added to the list of artifacts to | |
* be excluded, specified in the format | |
* {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]}, an | |
* empty string or {@code *} will match all exclusions, you can | |
* pass an {@code *} instead of any part of the coordinates to | |
* match all possible values | |
* @return Artifact builder with added exclusions | |
*/ | |
MavenDependencyResolver exclusions(String... exclusions); | |
/** | |
* Adds multiple exclusions for current dependency | |
* | |
* @param exclusions the exclusions to be added to the list of artifacts to | |
* be excluded, specified in the format | |
* {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]}, an | |
* empty string or {@code *} will match all exclusions, you can | |
* pass an {@code *} instead of any part of the coordinates to | |
* match all possible values | |
* @return Artifact builder with added exclusions | |
*/ | |
MavenDependencyResolver exclusions(Collection<String> exclusions); | |
/** | |
* Resolves based upon dependencies declared in the POM at the specified path | |
* | |
* @param path | |
* @return | |
* @throws ResolutionException | |
*/ | |
MavenDependencyResolver includeDependenciesFromPom(final String path) throws ResolutionException; | |
/** | |
* Resolves based upon dependencies declared in the POM at the specified path | |
* | |
* @param path | |
* @return | |
* @throws ResolutionException | |
* @deprecated please use {@link #includeDependenciesFromPom(String)} instead | |
*/ | |
@Deprecated | |
MavenDependencyResolver loadDependenciesFromPom(final String path) throws ResolutionException; | |
/** | |
* Resolves based upon dependencies declared in the POM at the specified path | |
* | |
* @param path | |
* @param filter | |
* @return | |
* @throws ResolutionException | |
* @deprecated please use {@link #includeDependenciesFromPom(String)} instead | |
*/ | |
@Deprecated | |
MavenDependencyResolver loadDependenciesFromPom(final String path, final MavenResolutionFilter filter) throws ResolutionException; | |
/** | |
* Sets the resolver to either consider (or not) Maven Central in resolution | |
* @param useCentral a flag whether to use Maven central | |
* @return | |
*/ | |
MavenDependencyResolver useCentralRepo(final boolean useCentral); | |
/** | |
* Disables touching remote repositories at all, rely on local repository only | |
* @return Modified MavenDependencyResolution | |
*/ | |
MavenDependencyResolver goOffline(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A filter which can filter results retrieved by a particular dependency | |
* builder. | |
* | |
* The filter affects directly the dependency chain. Specifying it can save | |
* bandwidth and number of resolved dependencies, thus making your tests run | |
* faster. | |
* | |
* @see org.sonatype.aether.graph.DependencyFilter | |
* @see MavenDependencyResolver | |
* | |
*/ | |
public interface MavenResolutionFilter extends DependencyResolutionFilter<MavenResolutionFilter, MavenDependency> | |
{ | |
@Override | |
boolean accept(MavenDependency element); | |
MavenResolutionFilter configure(Collection<MavenDependency> dependencies); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* SecurityActions | |
* | |
* A set of privileged actions that are not to leak out of this package | |
*/ | |
final class SecurityActions | |
{ | |
// -------------------------------------------------------------------------------|| | |
// Constructor -------------------------------------------------------------------|| | |
// -------------------------------------------------------------------------------|| | |
/** | |
* No instantiation | |
*/ | |
private SecurityActions(); | |
// -------------------------------------------------------------------------------|| | |
// Utility Methods ---------------------------------------------------------------|| | |
// -------------------------------------------------------------------------------|| | |
/** | |
* Obtains the Thread Context ClassLoader | |
*/ | |
static ClassLoader getThreadContextClassLoader() | |
{ | |
return AccessController.doPrivileged(GetTcclAction.INSTANCE); | |
} | |
/** | |
* Obtains the Constructor specified from the given Class and argument types | |
* | |
* @param clazz | |
* @param argumentTypes | |
* @return | |
* @throws NoSuchMethodException | |
*/ | |
static Constructor<?> getConstructor(final Class<?> clazz, final Class<?>... argumentTypes) throws NoSuchMethodException; | |
/** | |
* Create a new instance by finding a constructor that matches the | |
* argumentTypes signature using the arguments for instantiation. | |
* | |
* @param className Full classname of class to create | |
* @param argumentTypes The constructor argument types | |
* @param arguments The constructor arguments | |
* @return a new instance | |
* @throws IllegalArgumentException if className, argumentTypes, or arguments | |
* are null | |
* @throws RuntimeException if any exceptions during creation | |
* @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a> | |
* @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a> | |
*/ | |
static <T> T newInstance(final String className, final Class<?>[] argumentTypes, final Object[] arguments, final Class<T> expectedType); | |
static String getProperty(final String key); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment