Support for explicit module path in dependency
Instead of *always* needing to pull auto-import dependencies from the master parent pom, we now allow normal @Grab-style module specifications, e.g. "io.ratpack:ratpack-groovy:0.9.2"
This commit is contained in:
parent
6bdc229c84
commit
b71f07932e
|
|
@ -205,7 +205,8 @@ public class DependencyCustomizer {
|
|||
ArtifactCoordinatesResolver artifactCoordinatesResolver = this.dependencyResolutionContext
|
||||
.getArtifactCoordinatesResolver();
|
||||
this.classNode.addAnnotation(createGrabAnnotation(
|
||||
artifactCoordinatesResolver.getGroupId(module), module,
|
||||
artifactCoordinatesResolver.getGroupId(module),
|
||||
artifactCoordinatesResolver.getArtifactId(module),
|
||||
artifactCoordinatesResolver.getVersion(module), transitive));
|
||||
}
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -25,18 +25,26 @@ package org.springframework.boot.cli.compiler.dependencies;
|
|||
public interface ArtifactCoordinatesResolver {
|
||||
|
||||
/**
|
||||
* Gets the group id of the artifact identified by the given {@code artifactId}.
|
||||
* Returns {@code null} if the artifact is unknown to the resolver.
|
||||
* @param artifactId The id of the artifact
|
||||
* @return The group id of the artifact
|
||||
* Gets the group id of the artifact identified by the given {@code module}. Returns
|
||||
* {@code null} if the artifact is unknown to the resolver.
|
||||
* @param module The id of the module
|
||||
* @return The group id of the module
|
||||
*/
|
||||
String getGroupId(String artifactId);
|
||||
String getGroupId(String module);
|
||||
|
||||
/**
|
||||
* Gets the version of the artifact identified by the given {@code artifactId}.
|
||||
* Gets the artifact id of the artifact identified by the given {@code module}.
|
||||
* Returns {@code null} if the artifact is unknown to the resolver.
|
||||
* @param artifactId The id of the artifact
|
||||
* @return The version of the artifact
|
||||
* @param module The id of the module
|
||||
* @return The group id of the module
|
||||
*/
|
||||
String getVersion(String artifactId);
|
||||
String getArtifactId(String module);
|
||||
|
||||
/**
|
||||
* Gets the version of the artifact identified by the given {@code module}. Returns
|
||||
* {@code null} if the artifact is unknown to the resolver.
|
||||
* @param module The id of the module
|
||||
* @return The version of the module
|
||||
*/
|
||||
String getVersion(String module);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.cli.compiler.dependencies;
|
|||
import org.springframework.boot.dependency.tools.Dependency;
|
||||
import org.springframework.boot.dependency.tools.ManagedDependencies;
|
||||
import org.springframework.boot.dependency.tools.VersionManagedDependencies;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link ArtifactCoordinatesResolver} backed by {@link ManagedDependencies}.
|
||||
|
|
@ -50,7 +51,17 @@ public class ManagedDependenciesArtifactCoordinatesResolver implements
|
|||
return (dependency == null ? null : dependency.getVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArtifactId(String artifactId) {
|
||||
Dependency dependency = find(artifactId);
|
||||
return (dependency == null ? null : dependency.getArtifactId());
|
||||
}
|
||||
|
||||
private Dependency find(String artifactId) {
|
||||
if (StringUtils.countOccurrencesOf(artifactId, ":") == 2) {
|
||||
String[] tokens = artifactId.split(":");
|
||||
return new Dependency(tokens[0], tokens[1], tokens[2]);
|
||||
}
|
||||
if (artifactId != null) {
|
||||
if (artifactId.startsWith("spring-boot")) {
|
||||
return new Dependency("org.springframework.boot", artifactId,
|
||||
|
|
|
|||
Loading…
Reference in New Issue