public

gathering api info for review and discuss.

  • Download Gist
MavenDependency.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
/**
* 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);
 
}
MavenDependencyResolver.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
/**
* 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();
}
MavenResolutionFilter.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/**
* 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);
}
SecurityActions.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
/**
* 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);
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.