Skip to content

Commit

Permalink
[SHRINKRES-113] improved canonical coordinate pattern description
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatloka authored and ALRubinger committed Mar 25, 2013
1 parent 437fc48 commit f2c49d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private MavenCoordinates() {

/**
* Creates a new {@link MavenCoordinate} instance from the specified, required canonical form in format
* <code><groupId>:<artifactId>[:<packagingType>[:<classifier>]][:<version>]</code>
* <code><groupId>:<artifactId>[:<packagingType>[:<classifier>]]:(<version>|'?')</code>
*
* @param canonicalForm
* @return
Expand Down Expand Up @@ -84,7 +84,7 @@ public static MavenCoordinate createCoordinate(final String groupId, final Strin

/**
* Parser to obtain {@link MavenCoordinate} instances from the canonical {@link String} form
* <code><groupId>:<artifactId>[:<packagingType>[:<classifier>]][:<version>]</code>
* <code><groupId>:<artifactId>[:<packagingType>[:<classifier>]]:(<version>|'?')</code>
*
* @author <a href="mailto:kpiwko@redhat.com">Karel Piwko</a>
* @author <a href="mailto:alr@jboss.org">Andrew Lee Rubinger</a>
Expand Down Expand Up @@ -121,7 +121,7 @@ static MavenCoordinateParser parse(final String coordinates) throws CoordinatePa
final Matcher m = DEPENDENCY_PATTERN.matcher(coordinates);
if (!m.matches()) {
throw new CoordinateParseException("Bad artifact coordinates"
+ ", expected format is <groupId>:<artifactId>[:<packagingType>[:<classifier>]][:<version>], got: "
+ ", expected format is <groupId>:<artifactId>[:<packagingType>[:<classifier>]]:(<version>|'?'), got: "
+ coordinates);
}

Expand All @@ -135,7 +135,7 @@ static MavenCoordinateParser parse(final String coordinates) throws CoordinatePa
final String position5 = m.group(ID_POS_5);

// some logic with numbers of provided groups
final int noOfColons = numberOfOccurences(coordinates, MavenGABaseImpl.SEPARATOR_COORDINATE);
final int noOfColons = numberOfOccurrences(coordinates, MavenGABaseImpl.SEPARATOR_COORDINATE);

// Parsing is segment-dependent
switch (noOfColons) {
Expand Down Expand Up @@ -177,7 +177,7 @@ public String getArtifactId() {
return artifactId;
}

private static int numberOfOccurences(final CharSequence haystack, char needle) {
private static int numberOfOccurrences(final CharSequence haystack, char needle) {
int counter = 0;
for (int i = 0; i < haystack.length(); i++) {
if (haystack.charAt(i) == needle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public final FORMATSTAGETYPE importRuntimeAndTestDependencies() {
@Override
public final FORMATSTAGETYPE importRuntimeAndTestDependencies(final MavenResolutionStrategy strategy)
throws IllegalArgumentException {

Validate.notNull(strategy, "Specified strategy for importing test dependencies must not be null");

new AddScopedDependenciesTask(ScopeType.values()).execute(this.getMavenWorkingSession());
Expand All @@ -64,7 +63,6 @@ public final FORMATSTAGETYPE importRuntimeAndTestDependencies(final MavenResolut

@Override
public final FORMATSTAGETYPE importRuntimeDependencies() {

ScopeType[] scopes = new ScopeType[] { ScopeType.COMPILE, ScopeType.IMPORT, ScopeType.RUNTIME, ScopeType.SYSTEM };

new AddScopedDependenciesTask(ScopeType.values()).execute(this.getMavenWorkingSession());
Expand All @@ -90,13 +88,12 @@ public final FORMATSTAGETYPE importRuntimeDependencies(final MavenResolutionStra
private FORMATSTAGETYPE importAnyDependencies(final MavenResolutionStrategy strategy) {
// resolve
return this.createStrategyStage().using(strategy);

}

/**
* {@inheritDoc}
*
* @see org.jboss.shrinkwrap.resolver.impl.maven.ResolveStageBaseImpl#resolveVersion(org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinate)
* @see org.jboss.shrinkwrap.resolver.impl.maven.task.ResolveVersionFromMetadataTask
*/
@Override
protected String resolveVersion(final MavenDependency dependency) throws IllegalArgumentException {
Expand Down

0 comments on commit f2c49d9

Please sign in to comment.