Polish
This commit is contained in:
@@ -130,19 +130,15 @@ public class InitCommand extends OptionParsingCommand {
|
||||
|
||||
private void projectGenerationOptions() {
|
||||
this.groupId = option(Arrays.asList("groupId", "g"),
|
||||
"Project coordinates (for example 'org.test')")
|
||||
.withRequiredArg();
|
||||
"Project coordinates (for example 'org.test')").withRequiredArg();
|
||||
this.artifactId = option(Arrays.asList("artifactId", "a"),
|
||||
"Project coordinates; infer archive name (for example 'test')")
|
||||
.withRequiredArg();
|
||||
this.version = option(Arrays.asList("version", "v"),
|
||||
"Project version (for example '0.0.1-SNAPSHOT')")
|
||||
.withRequiredArg();
|
||||
"Project version (for example '0.0.1-SNAPSHOT')").withRequiredArg();
|
||||
this.name = option(Arrays.asList("name", "n"),
|
||||
"Project name; infer application name")
|
||||
.withRequiredArg();
|
||||
this.description = option("description",
|
||||
"Project description")
|
||||
"Project name; infer application name").withRequiredArg();
|
||||
this.description = option("description", "Project description")
|
||||
.withRequiredArg();
|
||||
this.packaging = option(Arrays.asList("packaging", "p"),
|
||||
"Project packaging (for example 'jar')").withRequiredArg();
|
||||
@@ -162,8 +158,7 @@ public class InitCommand extends OptionParsingCommand {
|
||||
this.javaVersion = option(Arrays.asList("java-version", "j"),
|
||||
"Language level (for example '1.8')").withRequiredArg();
|
||||
this.language = option(Arrays.asList("language", "l"),
|
||||
"Programming language (for example 'java')")
|
||||
.withRequiredArg();
|
||||
"Programming language (for example 'java')").withRequiredArg();
|
||||
this.bootVersion = option(Arrays.asList("boot-version", "b"),
|
||||
"Spring Boot version (for example '1.2.0.RELEASE')")
|
||||
.withRequiredArg();
|
||||
@@ -240,22 +235,22 @@ public class InitCommand extends OptionParsingCommand {
|
||||
if (options.has(this.type)) {
|
||||
request.setType(options.valueOf(this.type));
|
||||
}
|
||||
if(options.has(this.language)) {
|
||||
if (options.has(this.language)) {
|
||||
request.setLanguage(options.valueOf(this.language));
|
||||
}
|
||||
if(options.has(this.groupId)) {
|
||||
if (options.has(this.groupId)) {
|
||||
request.setGroupId(options.valueOf(this.groupId));
|
||||
}
|
||||
if (options.has(this.artifactId)) {
|
||||
request.setArtifactId(options.valueOf(this.artifactId));
|
||||
}
|
||||
if(options.has(this.name)) {
|
||||
if (options.has(this.name)) {
|
||||
request.setName(options.valueOf(this.name));
|
||||
}
|
||||
if(options.has(this.version)) {
|
||||
if (options.has(this.version)) {
|
||||
request.setVersion(options.valueOf(this.version));
|
||||
}
|
||||
if(options.has(this.description)) {
|
||||
if (options.has(this.description)) {
|
||||
request.setDescription(options.valueOf(this.description));
|
||||
}
|
||||
request.setExtract(options.has(this.extract));
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -392,7 +391,7 @@ class ProjectGenerationRequest {
|
||||
private static void filter(Map<String, ProjectType> projects, String tag,
|
||||
String tagValue) {
|
||||
for (Iterator<Map.Entry<String, ProjectType>> it = projects.entrySet().iterator(); it
|
||||
.hasNext(); ) {
|
||||
.hasNext();) {
|
||||
Map.Entry<String, ProjectType> entry = it.next();
|
||||
String value = entry.getValue().getTags().get(tag);
|
||||
if (!tagValue.equals(value)) {
|
||||
|
||||
@@ -81,7 +81,6 @@ public abstract class CompilerAutoConfiguration {
|
||||
|
||||
/**
|
||||
* Apply any additional configuration.
|
||||
*
|
||||
* @param loader the class loader being used during compilation
|
||||
* @param configuration the compiler configuration
|
||||
* @param generatorContext the current context
|
||||
@@ -93,4 +92,5 @@ public abstract class CompilerAutoConfiguration {
|
||||
GroovyCompilerConfiguration configuration, GeneratorContext generatorContext,
|
||||
SourceUnit source, ClassNode classNode) throws CompilationFailedException {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,11 +100,9 @@ public class DependencyManagementBomTransformation extends AnnotatedNodeASTTrans
|
||||
|
||||
private List<Map<String, String>> createDependencyMaps(Expression valueExpression) {
|
||||
Map<String, String> dependency = null;
|
||||
|
||||
List<ConstantExpression> constantExpressions = getConstantExpressions(valueExpression);
|
||||
List<Map<String, String>> dependencies = new ArrayList<Map<String, String>>(
|
||||
constantExpressions.size());
|
||||
|
||||
for (ConstantExpression expression : constantExpressions) {
|
||||
Object value = expression.getValue();
|
||||
if (value instanceof String) {
|
||||
@@ -122,7 +120,6 @@ public class DependencyManagementBomTransformation extends AnnotatedNodeASTTrans
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
@@ -130,12 +127,10 @@ public class DependencyManagementBomTransformation extends AnnotatedNodeASTTrans
|
||||
if (valueExpression instanceof ListExpression) {
|
||||
return getConstantExpressions((ListExpression) valueExpression);
|
||||
}
|
||||
|
||||
if (valueExpression instanceof ConstantExpression
|
||||
&& ((ConstantExpression) valueExpression).getValue() instanceof String) {
|
||||
return Arrays.asList((ConstantExpression) valueExpression);
|
||||
}
|
||||
|
||||
reportError("@DependencyManagementBom requires an inline constant that is a "
|
||||
+ "string or a string array", valueExpression);
|
||||
return Collections.emptyList();
|
||||
@@ -166,16 +161,13 @@ public class DependencyManagementBomTransformation extends AnnotatedNodeASTTrans
|
||||
List<Map<String, String>> bomDependencies) {
|
||||
URI[] uris = Grape.getInstance().resolve(null,
|
||||
bomDependencies.toArray(new Map[bomDependencies.size()]));
|
||||
|
||||
DefaultModelBuilder modelBuilder = new DefaultModelBuilderFactory().newInstance();
|
||||
|
||||
for (URI uri : uris) {
|
||||
try {
|
||||
DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
|
||||
request.setModelResolver(new GrapeModelResolver());
|
||||
request.setModelSource(new UrlModelSource(uri.toURL()));
|
||||
Model model = modelBuilder.build(request).getEffectiveModel();
|
||||
|
||||
this.resolutionContext
|
||||
.addDependencyManagement(new MavenModelDependencyManagement(model));
|
||||
}
|
||||
@@ -236,4 +228,5 @@ public class DependencyManagementBomTransformation extends AnnotatedNodeASTTrans
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,23 +28,21 @@ public interface DependencyManagement {
|
||||
|
||||
/**
|
||||
* Returns the managed dependencies.
|
||||
*
|
||||
* @return the managed dependencies
|
||||
*/
|
||||
List<Dependency> getDependencies();
|
||||
|
||||
/**
|
||||
* Returns the managed version of Spring Boot. May be {@code null}.
|
||||
*
|
||||
* @return the Spring Boot version, or {@code null}
|
||||
*/
|
||||
String getSpringBootVersion();
|
||||
|
||||
/**
|
||||
* Finds the managed dependency with the given {@code artifactId}.
|
||||
*
|
||||
* @param artifactId The artifact ID of the dependency to find
|
||||
* @return the dependency, or {@code null}
|
||||
*/
|
||||
Dependency find(String artifactId);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ package org.springframework.boot.cli.compiler.dependencies;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link ArtifactCoordinatesResolver} backed by {@link SpringBootDependenciesDependencyManagement}.
|
||||
* {@link ArtifactCoordinatesResolver} backed by
|
||||
* {@link SpringBootDependenciesDependencyManagement}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
@@ -70,4 +71,5 @@ public class DependencyManagementArtifactCoordinatesResolver implements
|
||||
Dependency dependency = find(module);
|
||||
return dependency == null ? null : dependency.getVersion();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -75,4 +75,5 @@ public class MavenModelDependencyManagement implements DependencyManagement {
|
||||
public Dependency find(String artifactId) {
|
||||
return this.byArtifactId.get(artifactId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import joptsimple.OptionSet;
|
||||
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.junit.Before;
|
||||
@@ -34,7 +35,6 @@ import org.junit.rules.TemporaryFolder;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,7 +27,6 @@ import org.json.JSONObject;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.StreamUtils;
|
||||
@@ -118,7 +117,7 @@ public class ProjectGenerationRequestTests {
|
||||
public void customLanguage() {
|
||||
this.request.setLanguage("groovy");
|
||||
assertEquals(createDefaultUrl("?type=test-type&language=groovy"),
|
||||
this.request.generateUrl(createDefaultMetadata()));
|
||||
this.request.generateUrl(createDefaultMetadata()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,8 +126,9 @@ public class ProjectGenerationRequestTests {
|
||||
this.request.setArtifactId("sample");
|
||||
this.request.setVersion("1.0.1-SNAPSHOT");
|
||||
this.request.setDescription("Spring Boot Test");
|
||||
assertEquals(createDefaultUrl("?groupId=org.acme&artifactId=sample&version=1.0.1-SNAPSHOT" +
|
||||
"&description=Spring+Boot+Test&type=test-type"),
|
||||
assertEquals(
|
||||
createDefaultUrl("?groupId=org.acme&artifactId=sample&version=1.0.1-SNAPSHOT"
|
||||
+ "&description=Spring+Boot+Test&type=test-type"),
|
||||
this.request.generateUrl(createDefaultMetadata()));
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ public class CompositeDependencyManagementTests {
|
||||
public void unknownSpringBootVersion() {
|
||||
given(this.dependencyManagement1.getSpringBootVersion()).willReturn(null);
|
||||
given(this.dependencyManagement2.getSpringBootVersion()).willReturn(null);
|
||||
|
||||
assertThat(new CompositeDependencyManagement(this.dependencyManagement1,
|
||||
this.dependencyManagement2).getSpringBootVersion(), is(nullValue()));
|
||||
}
|
||||
@@ -56,7 +55,6 @@ public class CompositeDependencyManagementTests {
|
||||
public void knownSpringBootVersion() {
|
||||
given(this.dependencyManagement1.getSpringBootVersion()).willReturn("1.2.3");
|
||||
given(this.dependencyManagement2.getSpringBootVersion()).willReturn("1.2.4");
|
||||
|
||||
assertThat(new CompositeDependencyManagement(this.dependencyManagement1,
|
||||
this.dependencyManagement2).getSpringBootVersion(), is("1.2.3"));
|
||||
}
|
||||
@@ -65,7 +63,6 @@ public class CompositeDependencyManagementTests {
|
||||
public void unknownDependency() {
|
||||
given(this.dependencyManagement1.find("artifact")).willReturn(null);
|
||||
given(this.dependencyManagement2.find("artifact")).willReturn(null);
|
||||
|
||||
assertThat(new CompositeDependencyManagement(this.dependencyManagement1,
|
||||
this.dependencyManagement2).find("artifact"), is(nullValue()));
|
||||
}
|
||||
@@ -76,7 +73,6 @@ public class CompositeDependencyManagementTests {
|
||||
new Dependency("test", "artifact", "1.2.3"));
|
||||
given(this.dependencyManagement2.find("artifact")).willReturn(
|
||||
new Dependency("test", "artifact", "1.2.4"));
|
||||
|
||||
assertThat(new CompositeDependencyManagement(this.dependencyManagement1,
|
||||
this.dependencyManagement2).find("artifact"), is(new Dependency("test",
|
||||
"artifact", "1.2.3")));
|
||||
@@ -88,11 +84,11 @@ public class CompositeDependencyManagementTests {
|
||||
Arrays.asList(new Dependency("test", "artifact", "1.2.3")));
|
||||
given(this.dependencyManagement2.getDependencies()).willReturn(
|
||||
Arrays.asList(new Dependency("test", "artifact", "1.2.4")));
|
||||
|
||||
assertThat(
|
||||
new CompositeDependencyManagement(this.dependencyManagement1,
|
||||
this.dependencyManagement2).getDependencies(),
|
||||
contains(new Dependency("test", "artifact", "1.2.3"), new Dependency(
|
||||
"test", "artifact", "1.2.4")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user