Use class/package to guess version
This commit is contained in:
@@ -45,8 +45,7 @@ public class SpringCloudCompilerAutoConfiguration extends CompilerAutoConfigurat
|
|||||||
dependencies.ifAnyMissingClasses(
|
dependencies.ifAnyMissingClasses(
|
||||||
"org.springframework.boot.actuate.endpoint.EnvironmentEndpoint").add(
|
"org.springframework.boot.actuate.endpoint.EnvironmentEndpoint").add(
|
||||||
"spring-boot-starter-actuator");
|
"spring-boot-starter-actuator");
|
||||||
dependencies
|
dependencies.ifAnyMissingClasses("org.springframework.cloud.config.Environment")
|
||||||
.ifAnyMissingClasses("org.springframework.cloud.config.Environment")
|
|
||||||
.add("spring-cloud-config-client");
|
.add("spring-cloud-config-client");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +65,8 @@ public class SpringCloudCompilerAutoConfiguration extends CompilerAutoConfigurat
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<Dependencies> getAdditionalDependencies() {
|
private List<Dependencies> getAdditionalDependencies() {
|
||||||
String[] components = "org.springframework.cloud:spring-cloud-versions:1.0.0.BUILD-SNAPSHOT"
|
String version = getVersion();
|
||||||
|
String[] components = ("org.springframework.cloud:spring-cloud-versions:" + version)
|
||||||
.split(":");
|
.split(":");
|
||||||
Map<String, String> dependency;
|
Map<String, String> dependency;
|
||||||
dependency = new HashMap<String, String>();
|
dependency = new HashMap<String, String>();
|
||||||
@@ -89,6 +89,19 @@ public class SpringCloudCompilerAutoConfiguration extends CompilerAutoConfigurat
|
|||||||
return managedDependencies;
|
return managedDependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getVersion() {
|
||||||
|
try {
|
||||||
|
Package pkg = getClass().getPackage();
|
||||||
|
if (pkg != null) {
|
||||||
|
return pkg.getImplementationVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
return "1.0.0.BUILD-SNAPSHOT";
|
||||||
|
}
|
||||||
|
|
||||||
static class AetherManagedDependencies implements Dependencies {
|
static class AetherManagedDependencies implements Dependencies {
|
||||||
|
|
||||||
private Map<String, org.springframework.boot.dependency.tools.Dependency> groupAndArtifactToDependency = new HashMap<String, org.springframework.boot.dependency.tools.Dependency>();
|
private Map<String, org.springframework.boot.dependency.tools.Dependency> groupAndArtifactToDependency = new HashMap<String, org.springframework.boot.dependency.tools.Dependency>();
|
||||||
@@ -102,10 +115,11 @@ public class SpringCloudCompilerAutoConfiguration extends CompilerAutoConfigurat
|
|||||||
String groupId = dependency.getArtifact().getGroupId();
|
String groupId = dependency.getArtifact().getGroupId();
|
||||||
String artifactId = dependency.getArtifact().getArtifactId();
|
String artifactId = dependency.getArtifact().getArtifactId();
|
||||||
String version = dependency.getArtifact().getVersion();
|
String version = dependency.getArtifact().getVersion();
|
||||||
|
|
||||||
List<org.springframework.boot.dependency.tools.Dependency.Exclusion> exclusions = new ArrayList<org.springframework.boot.dependency.tools.Dependency.Exclusion>();
|
List<org.springframework.boot.dependency.tools.Dependency.Exclusion> exclusions = new ArrayList<org.springframework.boot.dependency.tools.Dependency.Exclusion>();
|
||||||
org.springframework.boot.dependency.tools.Dependency value = new org.springframework.boot.dependency.tools.Dependency(groupId, artifactId, version, exclusions);
|
org.springframework.boot.dependency.tools.Dependency value = new org.springframework.boot.dependency.tools.Dependency(
|
||||||
|
groupId, artifactId, version, exclusions);
|
||||||
|
|
||||||
groupAndArtifactToDependency.put(groupId + ":" + artifactId, value);
|
groupAndArtifactToDependency.put(groupId + ":" + artifactId, value);
|
||||||
artifactToGroupAndArtifact.put(artifactId, groupId + ":" + artifactId);
|
artifactToGroupAndArtifact.put(artifactId, groupId + ":" + artifactId);
|
||||||
|
|
||||||
@@ -122,7 +136,7 @@ public class SpringCloudCompilerAutoConfiguration extends CompilerAutoConfigurat
|
|||||||
@Override
|
@Override
|
||||||
public org.springframework.boot.dependency.tools.Dependency find(String artifactId) {
|
public org.springframework.boot.dependency.tools.Dependency find(String artifactId) {
|
||||||
String groupAndArtifact = artifactToGroupAndArtifact.get(artifactId);
|
String groupAndArtifact = artifactToGroupAndArtifact.get(artifactId);
|
||||||
if (groupAndArtifact==null) {
|
if (groupAndArtifact == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return groupAndArtifactToDependency.get(groupAndArtifact);
|
return groupAndArtifactToDependency.get(groupAndArtifact);
|
||||||
|
|||||||
Reference in New Issue
Block a user