diff --git a/initializr-docs/src/main/asciidoc/configuration-format.adoc b/initializr-docs/src/main/asciidoc/configuration-format.adoc index 9ead2e6650..e23d3c2926 100644 --- a/initializr-docs/src/main/asciidoc/configuration-format.adoc +++ b/initializr-docs/src/main/asciidoc/configuration-format.adoc @@ -90,6 +90,7 @@ with that id is assumed. * A `version` if Spring Boot does not already provide a dependency management for that dependency. * A `scope` (can be `compile`, `runtime`, `provided` or `test`). +* A `classifier` (if the dependency to use is classified, such as `test-jar`). * The reference to a `bom` or a `repository` that must be added to the project once that dependency is added. * A `compatibilityRange` used to determine the platform versions that are compatible diff --git a/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/Dependency.java b/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/Dependency.java index fd7761c4fb..8054158b47 100644 --- a/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/Dependency.java +++ b/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/Dependency.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -41,10 +41,10 @@ public class Dependency { private final DependencyScope scope; - private final String type; - private final String classifier; + private final String type; + private final Set exclusions; protected Dependency(Builder builder) { @@ -110,6 +110,14 @@ public DependencyScope getScope() { return this.scope; } + /** + * The classifier of this dependency. Can be {@code null} + * @return the classifier or {@code null} + */ + public String getClassifier() { + return this.classifier; + } + /** * The type of the dependency. Can be {@code null} to indicate that the default type * should be used (i.e. {@code jar}). @@ -119,14 +127,6 @@ public String getType() { return this.type; } - /** - * The classifier of this dependency. Can be {@code null} - * @return the classifier or {@code null} - */ - public String getClassifier() { - return this.classifier; - } - /** * The {@link Exclusion exclusions} to apply. * @return the exclusions to apply @@ -151,10 +151,10 @@ public static class Builder> { private DependencyScope scope; - private String classifier; - private String type; + private String classifier; + private Set exclusions = new LinkedHashSet<>(); protected Builder(String groupId, String artifactId) { @@ -182,13 +182,13 @@ public B scope(DependencyScope scope) { return self(); } - public B type(String type) { - this.type = type; + public B classifier(String classifier) { + this.classifier = classifier; return self(); } - public B classifier(String classifier) { - this.classifier = classifier; + public B type(String type) { + this.type = type; return self(); } @@ -208,8 +208,8 @@ protected B self() { } protected B initialize(Dependency dependency) { - version(dependency.getVersion()).scope(dependency.getScope()).type(dependency.getType()) - .exclusions(dependency.getExclusions()); + version(dependency.getVersion()).scope(dependency.getScope()).classifier(dependency.getClassifier()) + .type(dependency.getType()).exclusions(dependency.getExclusions()); return self(); } diff --git a/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/gradle/GroovyDslGradleBuildWriter.java b/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/gradle/GroovyDslGradleBuildWriter.java index 429f17f12b..780dbf4ba7 100644 --- a/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/gradle/GroovyDslGradleBuildWriter.java +++ b/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/gradle/GroovyDslGradleBuildWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -134,8 +134,8 @@ protected void writeConfiguration(IndentingWriter writer, GradleConfiguration co protected void writeDependency(IndentingWriter writer, Dependency dependency) { String quoteStyle = determineQuoteStyle(dependency.getVersion()); String version = determineVersion(dependency.getVersion()); - String type = dependency.getType(); String classifier = dependency.getClassifier(); + String type = dependency.getType(); boolean hasExclusions = !dependency.getExclusions().isEmpty(); writer.print(configurationForDependency(dependency)); writer.print((hasExclusions) ? "(" : " "); diff --git a/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/gradle/KotlinDslGradleBuildWriter.java b/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/gradle/KotlinDslGradleBuildWriter.java index 09fb0ff3a0..a308332206 100644 --- a/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/gradle/KotlinDslGradleBuildWriter.java +++ b/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/gradle/KotlinDslGradleBuildWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -149,8 +149,8 @@ protected void writeConfiguration(IndentingWriter writer, GradleConfiguration co @Override protected void writeDependency(IndentingWriter writer, Dependency dependency) { String version = determineVersion(dependency.getVersion()); - String type = dependency.getType(); String classifier = dependency.getClassifier(); + String type = dependency.getType(); writer.print(configurationForDependency(dependency) + "(\"" + dependency.getGroupId() + ":" + dependency.getArtifactId() + ((version != null) ? ":" + version : "") + ((classifier != null) ? ":" + classifier : "") + ((type != null) ? "@" + type : "") + "\")"); diff --git a/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/maven/MavenBuildWriter.java b/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/maven/MavenBuildWriter.java index d2eba02487..6e325ec467 100644 --- a/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/maven/MavenBuildWriter.java +++ b/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/maven/MavenBuildWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. diff --git a/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/maven/MavenDependency.java b/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/maven/MavenDependency.java index 9f084e2fa3..87d8955f9b 100644 --- a/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/maven/MavenDependency.java +++ b/initializr-generator/src/main/java/io/spring/initializr/generator/buildsystem/maven/MavenDependency.java @@ -49,8 +49,7 @@ public static Builder withCoordinates(String groupId, String artifactId) { * @return a new builder initialized with the same state as the {@code dependency} */ public static Builder from(Dependency dependency) { - return new Builder(dependency.getGroupId(), dependency.getArtifactId()).initialize(dependency) - .classifier(dependency.getClassifier()); + return new Builder(dependency.getGroupId(), dependency.getArtifactId()).initialize(dependency); } /** diff --git a/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/DependencyTests.java b/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/DependencyTests.java index ae8cecf980..fa080157cf 100644 --- a/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/DependencyTests.java +++ b/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/DependencyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -36,6 +36,7 @@ void dependencyWithCoordinatesOnly() { assertThat(dependency.getArtifactId()).isEqualTo("acme"); assertThat(dependency.getScope()).isNull(); assertThat(dependency.getVersion()).isNull(); + assertThat(dependency.getClassifier()).isNull(); assertThat(dependency.getType()).isNull(); assertThat(dependency.getExclusions()).isEmpty(); } @@ -48,6 +49,19 @@ void dependencyWithScopeAndVersionValue() { assertThat(dependency.getArtifactId()).isEqualTo("acme"); assertThat(dependency.getScope()).isEqualTo(DependencyScope.RUNTIME); assertThat(dependency.getVersion().getValue()).isEqualTo("1.0.0"); + assertThat(dependency.getClassifier()).isNull(); + assertThat(dependency.getType()).isNull(); + assertThat(dependency.getExclusions()).isEmpty(); + } + + @Test + void dependencyWithClassifier() { + Dependency dependency = Dependency.withCoordinates("com.example", "acme").classifier("test").build(); + assertThat(dependency.getGroupId()).isEqualTo("com.example"); + assertThat(dependency.getArtifactId()).isEqualTo("acme"); + assertThat(dependency.getScope()).isNull(); + assertThat(dependency.getVersion()).isNull(); + assertThat(dependency.getClassifier()).isEqualTo("test"); assertThat(dependency.getType()).isNull(); assertThat(dependency.getExclusions()).isEmpty(); } @@ -59,6 +73,7 @@ void dependencyWithType() { assertThat(dependency.getArtifactId()).isEqualTo("acme"); assertThat(dependency.getScope()).isNull(); assertThat(dependency.getVersion()).isNull(); + assertThat(dependency.getClassifier()).isNull(); assertThat(dependency.getType()).isEqualTo("test-zip"); assertThat(dependency.getExclusions()).isEmpty(); } @@ -71,6 +86,7 @@ void dependencyWithExclusions() { assertThat(dependency.getArtifactId()).isEqualTo("acme"); assertThat(dependency.getScope()).isNull(); assertThat(dependency.getVersion()).isNull(); + assertThat(dependency.getClassifier()).isNull(); assertThat(dependency.getType()).isNull(); assertThat(dependency.getExclusions()).containsExactly(new Exclusion("com.example", "exclude1"), new Exclusion("com.example", "exclude2")); diff --git a/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/gradle/GroovyDslGradleBuildWriterTests.java b/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/gradle/GroovyDslGradleBuildWriterTests.java index f751f20237..ef790feef8 100644 --- a/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/gradle/GroovyDslGradleBuildWriterTests.java +++ b/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/gradle/GroovyDslGradleBuildWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -305,16 +305,6 @@ void gradleBuildWithCompileDependency() { " implementation 'org.springframework.boot:spring-boot-starter'", "}"); } - @Test - void gradleBuildWithClassifierDependency() { - GradleBuild build = new GradleBuild(); - build.dependencies().add("root", - Dependency.withCoordinates("org.springframework.boot", "spring-boot-starter").classifier("classifier")); - List lines = generateBuild(build); - assertThat(lines).containsSequence("dependencies {", - " implementation 'org.springframework.boot:spring-boot-starter:classifier'", "}"); - } - @Test void gradleBuildWithNoScopeDependencyDefaultsToCompile() { GradleBuild build = new GradleBuild(); @@ -373,6 +363,14 @@ void gradleBuildWithTestRuntimeDependency() { " testRuntimeOnly 'de.flapdoodle.embed:de.flapdoodle.embed.mongo'", "}"); } + @Test + void gradleBuildWithClassifierDependency() { + GradleBuild build = new GradleBuild(); + build.dependencies().add("root", Dependency.withCoordinates("com.example", "acme").classifier("test-jar")); + List lines = generateBuild(build); + assertThat(lines).containsSequence("dependencies {", " implementation 'com.example:acme:test-jar'", "}"); + } + @Test void gradleBuildWithExclusions() { GradleBuild build = new GradleBuild(); @@ -410,11 +408,11 @@ void gradleBuildWithNonNullArtifactTypeDependency() { @Test void gradleBuildWithNonNullArtifactTypeAndClassifierDependency() { GradleBuild build = new GradleBuild(); - build.dependencies().add("root", Dependency.withCoordinates("org.springframework.boot", "spring-boot-starter") - .scope(DependencyScope.COMPILE).type("tar.gz").classifier("classifier")); + build.dependencies().add("root", Dependency.withCoordinates("com.example", "acme") + .scope(DependencyScope.COMPILE).type("tar.gz").classifier("test-jar")); List lines = generateBuild(build); - assertThat(lines).containsSequence("dependencies {", - " implementation 'org.springframework.boot:spring-boot-starter:classifier@tar.gz'", "}"); + assertThat(lines).containsSequence("dependencies {", " implementation 'com.example:acme:test-jar@tar.gz'", + "}"); } @Test diff --git a/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/gradle/KotlinDslGradleBuildWriterTests.java b/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/gradle/KotlinDslGradleBuildWriterTests.java index 8a025c7a36..7be12aa012 100644 --- a/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/gradle/KotlinDslGradleBuildWriterTests.java +++ b/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/gradle/KotlinDslGradleBuildWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -313,16 +313,6 @@ void gradleBuildWithCompileDependency() { " implementation(\"org.springframework.boot:spring-boot-starter\")", "}"); } - @Test - void gradleBuildWithClassifierDependency() { - GradleBuild build = new GradleBuild(); - build.dependencies().add("root", Dependency.withCoordinates("org.springframework.boot", "spring-boot-starter") - .scope(DependencyScope.COMPILE).classifier("classifier")); - List lines = generateBuild(build); - assertThat(lines).containsSequence("dependencies {", - " implementation(\"org.springframework.boot:spring-boot-starter:classifier\")", "}"); - } - @Test void gradleBuildWithNoScopeDependencyDefaultsToCompile() { GradleBuild build = new GradleBuild(); @@ -381,6 +371,15 @@ void gradleBuildWithTestRuntimeDependency() { " testRuntimeOnly(\"de.flapdoodle.embed:de.flapdoodle.embed.mongo\")", "}"); } + @Test + void gradleBuildWithClassifierDependency() { + GradleBuild build = new GradleBuild(); + build.dependencies().add("root", Dependency.withCoordinates("com.example", "acme") + .scope(DependencyScope.COMPILE).classifier("test-jar")); + List lines = generateBuild(build); + assertThat(lines).containsSequence("dependencies {", " implementation(\"com.example:acme:test-jar\")", "}"); + } + @Test void gradleBuildWithExclusions() { GradleBuild build = new GradleBuild(); @@ -418,11 +417,11 @@ void gradleBuildWithNonNullArtifactTypeDependency() { @Test void gradleBuildWithNonNullArtifactTypeAndClassifierDependency() { GradleBuild build = new GradleBuild(); - build.dependencies().add("root", Dependency.withCoordinates("org.springframework.boot", "spring-boot-starter") - .scope(DependencyScope.COMPILE).type("tar.gz").classifier("classifier")); + build.dependencies().add("root", Dependency.withCoordinates("com.example", "acme") + .scope(DependencyScope.COMPILE).type("tar.gz").classifier("test-jar")); List lines = generateBuild(build); - assertThat(lines).containsSequence("dependencies {", - " implementation(\"org.springframework.boot:spring-boot-starter:classifier@tar.gz\")", "}"); + assertThat(lines).containsSequence("dependencies {", " implementation(\"com.example:acme:test-jar@tar.gz\")", + "}"); } @Test diff --git a/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/maven/MavenBuildWriterTests.java b/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/maven/MavenBuildWriterTests.java index be22cf76d7..96eaf3522c 100644 --- a/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/maven/MavenBuildWriterTests.java +++ b/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/maven/MavenBuildWriterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -223,20 +223,6 @@ void pomWithAnnotationProcessorDependency() { }); } - @Test - void pomWithClassifierDependency() { - MavenBuild build = new MavenBuild(); - build.settings().coordinates("com.example.demo", "demo"); - build.dependencies().add("foo-bar", Dependency - .withCoordinates("org.springframework.boot", "spring-boot-foo-bar").classifier("myClassifier")); - generatePom(build, (pom) -> { - NodeAssert dependency = pom.nodeAtPath("/project/dependencies/dependency"); - assertThat(dependency).textAtPath("groupId").isEqualTo("org.springframework.boot"); - assertThat(dependency).textAtPath("artifactId").isEqualTo("spring-boot-foo-bar"); - assertThat(dependency).textAtPath("classifier").isEqualTo("myClassifier"); - }); - } - @Test void pomWithCompileOnlyDependency() { MavenBuild build = new MavenBuild(); @@ -346,6 +332,19 @@ void pomWithTestRuntimeDependency() { }); } + @Test + void pomWithClassifierDependency() { + MavenBuild build = new MavenBuild(); + build.settings().coordinates("com.example.demo", "demo"); + build.dependencies().add("foo-bar", Dependency.withCoordinates("com.example", "acme").classifier("test-jar")); + generatePom(build, (pom) -> { + NodeAssert dependency = pom.nodeAtPath("/project/dependencies/dependency"); + assertThat(dependency).textAtPath("groupId").isEqualTo("com.example"); + assertThat(dependency).textAtPath("artifactId").isEqualTo("acme"); + assertThat(dependency).textAtPath("classifier").isEqualTo("test-jar"); + }); + } + @Test void pomWithExclusions() { MavenBuild build = new MavenBuild(); diff --git a/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/maven/MavenDependencyTests.java b/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/maven/MavenDependencyTests.java index 3d2ed5e805..df66560b44 100644 --- a/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/maven/MavenDependencyTests.java +++ b/initializr-generator/src/test/java/io/spring/initializr/generator/buildsystem/maven/MavenDependencyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -33,24 +33,24 @@ class MavenDependencyTests { @Test void initializeFromStandardDependency() { Dependency original = Dependency.withCoordinates("com.example", "test") - .version(VersionReference.ofValue("1.0.0")).scope(DependencyScope.RUNTIME).type("zip") - .classifier("classifier").build(); + .version(VersionReference.ofValue("1.0.0")).scope(DependencyScope.RUNTIME).classifier("test-jar") + .type("zip").build(); MavenDependency dependency = MavenDependency.from(original).build(); assertThat(original).isNotSameAs(dependency); assertThat(dependency.getGroupId()).isEqualTo("com.example"); assertThat(dependency.getArtifactId()).isEqualTo("test"); assertThat(dependency.getVersion()).isEqualTo(VersionReference.ofValue("1.0.0")); assertThat(dependency.getScope()).isEqualTo(DependencyScope.RUNTIME); + assertThat(dependency.getClassifier()).isEqualTo("test-jar"); assertThat(dependency.getType()).isEqualTo("zip"); - assertThat(dependency.getClassifier()).isEqualTo("classifier"); assertThat(dependency.isOptional()).isFalse(); } @Test void initializeFromMavenDependency() { Dependency original = MavenDependency.withCoordinates("com.example", "test") - .version(VersionReference.ofValue("1.0.0")).scope(DependencyScope.RUNTIME).type("zip").optional(true) - .classifier("classifier").build(); + .version(VersionReference.ofValue("1.0.0")).scope(DependencyScope.RUNTIME).classifier("test-jar") + .type("zip").optional(true).build(); MavenDependency dependency = MavenDependency.from(original).build(); assertThat(original).isNotSameAs(dependency); assertThat(dependency.getGroupId()).isEqualTo("com.example"); @@ -58,18 +58,8 @@ void initializeFromMavenDependency() { assertThat(dependency.getVersion()).isEqualTo(VersionReference.ofValue("1.0.0")); assertThat(dependency.getScope()).isEqualTo(DependencyScope.RUNTIME); assertThat(dependency.getType()).isEqualTo("zip"); - assertThat(dependency.getClassifier()).isEqualTo("classifier"); + assertThat(dependency.getClassifier()).isEqualTo("test-jar"); assertThat(dependency.isOptional()).isTrue(); } - @Test - void cloneUsingFromMethodOfMavenDependency() { - Dependency original = Dependency.withCoordinates("com.example", "test").classifier("classifier").build(); - Dependency dependency = MavenDependency.from(original).build(); - assertThat(original).isNotSameAs(dependency); - assertThat(dependency.getGroupId()).isEqualTo("com.example"); - assertThat(dependency.getArtifactId()).isEqualTo("test"); - assertThat(dependency.getClassifier()).isEqualTo("classifier"); - } - } diff --git a/initializr-metadata/src/main/java/io/spring/initializr/metadata/Dependency.java b/initializr-metadata/src/main/java/io/spring/initializr/metadata/Dependency.java index 767cef9e5a..824e2f7409 100644 --- a/initializr-metadata/src/main/java/io/spring/initializr/metadata/Dependency.java +++ b/initializr-metadata/src/main/java/io/spring/initializr/metadata/Dependency.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -87,10 +87,10 @@ public class Dependency extends MetadataElement implements Describable { private String version; - private String type; - private String classifier; + private String type; + private List mappings = new ArrayList<>(); private String scope = SCOPE_COMPILE; @@ -132,6 +132,7 @@ public Dependency(Dependency dependency) { this.groupId = dependency.groupId; this.artifactId = dependency.artifactId; this.version = dependency.version; + this.classifier = dependency.classifier; this.type = dependency.type; this.mappings.addAll(dependency.mappings); this.scope = dependency.scope; @@ -145,7 +146,6 @@ public Dependency(Dependency dependency) { this.starter = dependency.starter; this.keywords.addAll(dependency.keywords); this.links.addAll(dependency.links); - this.classifier = dependency.classifier; } public void setScope(String scope) { @@ -328,6 +328,11 @@ public void setVersion(String version) { this.version = version; } + /** + * Return the classifier, can be {@code null} to indicate that no classifier is + * available. + * @return the classifier or {@code null} + */ public String getClassifier() { return this.classifier; } @@ -469,18 +474,12 @@ public static Dependency createSpringBootStarter(String name, String scope) { } public static Dependency withId(String id, String groupId, String artifactId, String version, String scope) { - return withId(id, groupId, artifactId, version, scope, null); - } - - public static Dependency withId(String id, String groupId, String artifactId, String version, String scope, - String classifier) { Dependency dependency = new Dependency(); dependency.setId(id); dependency.groupId = groupId; dependency.artifactId = artifactId; dependency.version = version; dependency.scope = (scope != null) ? scope : SCOPE_COMPILE; - dependency.classifier = classifier; return dependency; } @@ -527,8 +526,6 @@ public static class Mapping { */ private String version; - private String classifier; - /** * The starter setting to use for the mapping or {@code null} to use the default. */ @@ -561,14 +558,6 @@ public void setVersion(String version) { this.version = version; } - public String getClassifier() { - return this.classifier; - } - - public void setClassifier(String classifier) { - this.classifier = classifier; - } - public Boolean getStarter() { return this.starter; } diff --git a/initializr-metadata/src/main/java/io/spring/initializr/metadata/support/MetadataBuildItemMapper.java b/initializr-metadata/src/main/java/io/spring/initializr/metadata/support/MetadataBuildItemMapper.java index c4742e2c45..d8dbd80f10 100644 --- a/initializr-metadata/src/main/java/io/spring/initializr/metadata/support/MetadataBuildItemMapper.java +++ b/initializr-metadata/src/main/java/io/spring/initializr/metadata/support/MetadataBuildItemMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -46,8 +46,8 @@ public static io.spring.initializr.generator.buildsystem.Dependency toDependency ? VersionReference.ofValue(dependency.getVersion()) : null; return io.spring.initializr.generator.buildsystem.Dependency .withCoordinates(dependency.getGroupId(), dependency.getArtifactId()).version(versionReference) - .scope(toDependencyScope(dependency.getScope())).type(dependency.getType()) - .classifier(dependency.getClassifier()).build(); + .scope(toDependencyScope(dependency.getScope())).classifier(dependency.getClassifier()) + .type(dependency.getType()).build(); } private static DependencyScope toDependencyScope(String scope) { diff --git a/initializr-metadata/src/test/java/io/spring/initializr/metadata/support/MetadataBuildItemResolverTests.java b/initializr-metadata/src/test/java/io/spring/initializr/metadata/support/MetadataBuildItemResolverTests.java index 9e64c02110..c30210d3a8 100644 --- a/initializr-metadata/src/test/java/io/spring/initializr/metadata/support/MetadataBuildItemResolverTests.java +++ b/initializr-metadata/src/test/java/io/spring/initializr/metadata/support/MetadataBuildItemResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -45,7 +45,9 @@ class MetadataBuildItemResolverTests { void resoleDependencyWithMatchingEntry() { InitializrMetadata metadata = new InitializrMetadata(); DependencyGroup group = DependencyGroup.create("test"); - group.getContent().add(Dependency.withId("test-dep", "com.example", "test", "1.0.0", "runtime", "classifier")); + Dependency target = Dependency.withId("test-dep", "com.example", "test", "1.0.0", "runtime"); + target.setClassifier("test-jar"); + group.getContent().add(target); metadata.getDependencies().getContent().add(group); metadata.validate(); MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0); @@ -53,7 +55,7 @@ void resoleDependencyWithMatchingEntry() { assertThat(dependency.getGroupId()).isEqualTo("com.example"); assertThat(dependency.getArtifactId()).isEqualTo("test"); assertThat(dependency.getVersion()).hasToString("1.0.0"); - assertThat(dependency.getClassifier()).hasToString("classifier"); + assertThat(dependency.getClassifier()).hasToString("test-jar"); assertThat(dependency.getScope()).isEqualTo(DependencyScope.RUNTIME); }