mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Polish
This commit is contained in:
parent
f49d3518a8
commit
3523bca79b
@ -23,7 +23,6 @@ import java.io.File;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -55,8 +54,12 @@ import org.eclipse.aether.util.filter.DependencyFilterUtils;
|
|||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class AetherGrapeEngine implements GrapeEngine {
|
public class AetherGrapeEngine implements GrapeEngine {
|
||||||
|
|
||||||
private static final Collection<Exclusion> WILDCARD_EXCLUSION = Arrays
|
private static final Collection<Exclusion> WILDCARD_EXCLUSION;
|
||||||
.asList(new Exclusion("*", "*", "*", "*"));
|
static {
|
||||||
|
List<Exclusion> exclusions = new ArrayList<Exclusion>();
|
||||||
|
exclusions.add(new Exclusion("*", "*", "*", "*"));
|
||||||
|
WILDCARD_EXCLUSION = Collections.unmodifiableList(exclusions);
|
||||||
|
}
|
||||||
|
|
||||||
private final DependencyResolutionContext resolutionContext;
|
private final DependencyResolutionContext resolutionContext;
|
||||||
|
|
||||||
@ -79,7 +82,6 @@ public class AetherGrapeEngine implements GrapeEngine {
|
|||||||
this.repositorySystem = repositorySystem;
|
this.repositorySystem = repositorySystem;
|
||||||
this.session = repositorySystemSession;
|
this.session = repositorySystemSession;
|
||||||
this.resolutionContext = resolutionContext;
|
this.resolutionContext = resolutionContext;
|
||||||
|
|
||||||
this.repositories = new ArrayList<RemoteRepository>();
|
this.repositories = new ArrayList<RemoteRepository>();
|
||||||
List<RemoteRepository> remotes = new ArrayList<RemoteRepository>(
|
List<RemoteRepository> remotes = new ArrayList<RemoteRepository>(
|
||||||
remoteRepositories);
|
remoteRepositories);
|
||||||
@ -87,7 +89,6 @@ public class AetherGrapeEngine implements GrapeEngine {
|
|||||||
for (RemoteRepository repository : remotes) {
|
for (RemoteRepository repository : remotes) {
|
||||||
addRepository(repository);
|
addRepository(repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.progressReporter = getProgressReporter(this.session);
|
this.progressReporter = getProgressReporter(this.session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,9 +96,7 @@ public class AetherGrapeEngine implements GrapeEngine {
|
|||||||
if (Boolean.getBoolean("groovy.grape.report.downloads")) {
|
if (Boolean.getBoolean("groovy.grape.report.downloads")) {
|
||||||
return new DetailedProgressReporter(session, System.out);
|
return new DetailedProgressReporter(session, System.out);
|
||||||
}
|
}
|
||||||
else {
|
return new SummaryProgressReporter(session, System.out);
|
||||||
return new SummaryProgressReporter(session, System.out);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -161,9 +160,7 @@ public class AetherGrapeEngine implements GrapeEngine {
|
|||||||
if (isTransitive(dependencyMap)) {
|
if (isTransitive(dependencyMap)) {
|
||||||
return new Dependency(artifact, JavaScopes.COMPILE, false, exclusions);
|
return new Dependency(artifact, JavaScopes.COMPILE, false, exclusions);
|
||||||
}
|
}
|
||||||
else {
|
return new Dependency(artifact, JavaScopes.COMPILE, null, WILDCARD_EXCLUSION);
|
||||||
return new Dependency(artifact, JavaScopes.COMPILE, null, WILDCARD_EXCLUSION);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Artifact createArtifact(Map<?, ?> dependencyMap) {
|
private Artifact createArtifact(Map<?, ?> dependencyMap) {
|
||||||
@ -172,14 +169,12 @@ public class AetherGrapeEngine implements GrapeEngine {
|
|||||||
String version = (String) dependencyMap.get("version");
|
String version = (String) dependencyMap.get("version");
|
||||||
String classifier = (String) dependencyMap.get("classifier");
|
String classifier = (String) dependencyMap.get("classifier");
|
||||||
String type = determineType(dependencyMap);
|
String type = determineType(dependencyMap);
|
||||||
|
|
||||||
return new DefaultArtifact(group, module, classifier, type, version);
|
return new DefaultArtifact(group, module, classifier, type, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String determineType(Map<?, ?> dependencyMap) {
|
private String determineType(Map<?, ?> dependencyMap) {
|
||||||
String type = (String) dependencyMap.get("type");
|
String type = (String) dependencyMap.get("type");
|
||||||
String ext = (String) dependencyMap.get("ext");
|
String ext = (String) dependencyMap.get("ext");
|
||||||
|
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
type = ext;
|
type = ext;
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
@ -198,35 +193,6 @@ public class AetherGrapeEngine implements GrapeEngine {
|
|||||||
return (transitive == null ? true : transitive);
|
return (transitive == null ? true : transitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<File> resolve(List<Dependency> dependencies)
|
|
||||||
throws ArtifactResolutionException {
|
|
||||||
|
|
||||||
try {
|
|
||||||
CollectRequest collectRequest = new CollectRequest((Dependency) null,
|
|
||||||
dependencies, new ArrayList<RemoteRepository>(this.repositories));
|
|
||||||
collectRequest.setManagedDependencies(this.resolutionContext
|
|
||||||
.getManagedDependencies());
|
|
||||||
|
|
||||||
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
|
|
||||||
DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE,
|
|
||||||
JavaScopes.RUNTIME));
|
|
||||||
|
|
||||||
DependencyResult dependencyResult = this.repositorySystem
|
|
||||||
.resolveDependencies(this.session, dependencyRequest);
|
|
||||||
|
|
||||||
this.resolutionContext.getManagedDependencies().addAll(
|
|
||||||
getDependencies(dependencyResult));
|
|
||||||
|
|
||||||
return getFiles(dependencyResult);
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
throw new DependencyResolutionFailedException(ex);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
this.progressReporter.finished();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Dependency> getDependencies(DependencyResult dependencyResult) {
|
private List<Dependency> getDependencies(DependencyResult dependencyResult) {
|
||||||
List<Dependency> dependencies = new ArrayList<Dependency>();
|
List<Dependency> dependencies = new ArrayList<Dependency>();
|
||||||
for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
|
for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
|
||||||
@ -263,11 +229,9 @@ public class AetherGrapeEngine implements GrapeEngine {
|
|||||||
if (this.repositories.contains(repository)) {
|
if (this.repositories.contains(repository)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
repository = getPossibleMirror(repository);
|
repository = getPossibleMirror(repository);
|
||||||
repository = applyProxy(repository);
|
repository = applyProxy(repository);
|
||||||
repository = applyAuthentication(repository);
|
repository = applyAuthentication(repository);
|
||||||
|
|
||||||
this.repositories.add(0, repository);
|
this.repositories.add(0, repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +241,6 @@ public class AetherGrapeEngine implements GrapeEngine {
|
|||||||
if (mirror != null) {
|
if (mirror != null) {
|
||||||
return mirror;
|
return mirror;
|
||||||
}
|
}
|
||||||
|
|
||||||
return remoteRepository;
|
return remoteRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +277,6 @@ public class AetherGrapeEngine implements GrapeEngine {
|
|||||||
public URI[] resolve(Map args, List depsInfo, Map... dependencyMaps) {
|
public URI[] resolve(Map args, List depsInfo, Map... dependencyMaps) {
|
||||||
List<Exclusion> exclusions = createExclusions(args);
|
List<Exclusion> exclusions = createExclusions(args);
|
||||||
List<Dependency> dependencies = createDependencies(dependencyMaps, exclusions);
|
List<Dependency> dependencies = createDependencies(dependencyMaps, exclusions);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<File> files = resolve(dependencies);
|
List<File> files = resolve(dependencies);
|
||||||
List<URI> uris = new ArrayList<URI>(files.size());
|
List<URI> uris = new ArrayList<URI>(files.size());
|
||||||
@ -323,11 +285,48 @@ public class AetherGrapeEngine implements GrapeEngine {
|
|||||||
}
|
}
|
||||||
return uris.toArray(new URI[uris.size()]);
|
return uris.toArray(new URI[uris.size()]);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception ex) {
|
||||||
throw new DependencyResolutionFailedException(e);
|
throw new DependencyResolutionFailedException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<File> resolve(List<Dependency> dependencies)
|
||||||
|
throws ArtifactResolutionException {
|
||||||
|
try {
|
||||||
|
CollectRequest collectRequest = getCollectRequest(dependencies);
|
||||||
|
DependencyRequest dependencyRequest = getDependencyRequest(collectRequest);
|
||||||
|
DependencyResult result = this.repositorySystem.resolveDependencies(
|
||||||
|
this.session, dependencyRequest);
|
||||||
|
addManagedDependencies(result);
|
||||||
|
return getFiles(result);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
throw new DependencyResolutionFailedException(ex);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
this.progressReporter.finished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CollectRequest getCollectRequest(List<Dependency> dependencies) {
|
||||||
|
CollectRequest collectRequest = new CollectRequest((Dependency) null,
|
||||||
|
dependencies, new ArrayList<RemoteRepository>(this.repositories));
|
||||||
|
collectRequest.setManagedDependencies(this.resolutionContext
|
||||||
|
.getManagedDependencies());
|
||||||
|
return collectRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DependencyRequest getDependencyRequest(CollectRequest collectRequest) {
|
||||||
|
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest,
|
||||||
|
DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE,
|
||||||
|
JavaScopes.RUNTIME));
|
||||||
|
return dependencyRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addManagedDependencies(DependencyResult result) {
|
||||||
|
this.resolutionContext.getManagedDependencies().addAll(getDependencies(result));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map[] listDependencies(ClassLoader classLoader) {
|
public Map[] listDependencies(ClassLoader classLoader) {
|
||||||
throw new UnsupportedOperationException("Listing dependencies is not supported");
|
throw new UnsupportedOperationException("Listing dependencies is not supported");
|
||||||
|
@ -82,17 +82,14 @@ class ProjectLibraries implements Libraries {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Set<GradleLibrary> compile = getLibraries("compile", LibraryScope.COMPILE);
|
Set<GradleLibrary> compile = getLibraries("compile", LibraryScope.COMPILE);
|
||||||
|
|
||||||
Set<GradleLibrary> runtime = getLibraries("runtime", LibraryScope.RUNTIME);
|
Set<GradleLibrary> runtime = getLibraries("runtime", LibraryScope.RUNTIME);
|
||||||
runtime = minus(runtime, compile);
|
runtime = minus(runtime, compile);
|
||||||
|
|
||||||
Set<GradleLibrary> provided = getLibraries(this.providedConfigurationName,
|
Set<GradleLibrary> provided = getLibraries(this.providedConfigurationName,
|
||||||
LibraryScope.PROVIDED);
|
LibraryScope.PROVIDED);
|
||||||
if (provided != null) {
|
if (provided != null) {
|
||||||
compile = minus(compile, provided);
|
compile = minus(compile, provided);
|
||||||
runtime = minus(runtime, provided);
|
runtime = minus(runtime, provided);
|
||||||
}
|
}
|
||||||
|
|
||||||
libraries(compile, callback);
|
libraries(compile, callback);
|
||||||
libraries(runtime, callback);
|
libraries(runtime, callback);
|
||||||
libraries(provided, callback);
|
libraries(provided, callback);
|
||||||
@ -111,7 +108,6 @@ class ProjectLibraries implements Libraries {
|
|||||||
libraries.add(new ResolvedArtifactLibrary(artifact, scope));
|
libraries.add(new ResolvedArtifactLibrary(artifact, scope));
|
||||||
}
|
}
|
||||||
libraries.addAll(getLibrariesForFileDependencies(configuration, scope));
|
libraries.addAll(getLibrariesForFileDependencies(configuration, scope));
|
||||||
|
|
||||||
return libraries;
|
return libraries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,10 +241,8 @@ public class Repackager {
|
|||||||
else if (startClass != null) {
|
else if (startClass != null) {
|
||||||
manifest.getMainAttributes().putValue(MAIN_CLASS_ATTRIBUTE, startClass);
|
manifest.getMainAttributes().putValue(MAIN_CLASS_ATTRIBUTE, startClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
String bootVersion = getClass().getPackage().getImplementationVersion();
|
String bootVersion = getClass().getPackage().getImplementationVersion();
|
||||||
manifest.getMainAttributes().putValue(BOOT_VERSION_ATTRIBUTE, bootVersion);
|
manifest.getMainAttributes().putValue(BOOT_VERSION_ATTRIBUTE, bootVersion);
|
||||||
|
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user