mirror of
https://gitee.com/dcren/initializr.git
synced 2025-07-15 23:13:30 +08:00
Polish "Add distributionManagement support for Maven pom"
See gh-1038
This commit is contained in:
parent
10deca608d
commit
d190e6860e
@ -57,10 +57,20 @@ public class MavenBuild extends Build {
|
||||
return this.settings.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a builder to configure the {@linkplain MavenDistributionManagement
|
||||
* distribution management} of this build.
|
||||
* @return a builder for {@link MavenDistributionManagement}
|
||||
*/
|
||||
public MavenDistributionManagement.Builder distributionManagement() {
|
||||
return this.distributionManagement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@linkplain MavenDistributionManagement distribution management} of this
|
||||
* build.
|
||||
* @return the {@link MavenDistributionManagement}
|
||||
*/
|
||||
public MavenDistributionManagement getDistributionManagement() {
|
||||
return this.distributionManagement.build();
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ package io.spring.initializr.generator.buildsystem.maven;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -38,7 +37,6 @@ import io.spring.initializr.generator.buildsystem.MavenRepository;
|
||||
import io.spring.initializr.generator.buildsystem.PropertyContainer;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenDistributionManagement.DeploymentRepository;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenDistributionManagement.Relocation;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenDistributionManagement.RepositoryPolicy;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenDistributionManagement.Site;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenPlugin.Configuration;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenPlugin.Execution;
|
||||
@ -434,32 +432,31 @@ public class MavenBuildWriter {
|
||||
|
||||
private void writeDistributionManagement(IndentingWriter writer, MavenBuild build) {
|
||||
MavenDistributionManagement distributionManagement = build.getDistributionManagement();
|
||||
if (!distributionManagement.isEmpty()) {
|
||||
writeElement(writer, "distributionManagement", () -> {
|
||||
writeSingleElement(writer, "downloadUrl", distributionManagement.getDownloadUrl());
|
||||
this.writeDeploymentRepository(writer, "repository", distributionManagement.getRepository());
|
||||
this.writeDeploymentRepository(writer, "snapshotRepository",
|
||||
distributionManagement.getSnapshotRepository());
|
||||
if (!distributionManagement.getRelocation().isEmpty()) {
|
||||
Relocation relocation = distributionManagement.getRelocation();
|
||||
writeElement(writer, "relocation", () -> {
|
||||
writeSingleElement(writer, "groupId", relocation.getGroupId());
|
||||
writeSingleElement(writer, "artifactId", relocation.getArtifactId());
|
||||
writeSingleElement(writer, "version", relocation.getVersion());
|
||||
writeSingleElement(writer, "message", relocation.getMessage());
|
||||
});
|
||||
}
|
||||
if (!distributionManagement.getSite().isEmpty()) {
|
||||
Site site = distributionManagement.getSite();
|
||||
writeElementWithAttributes(writer, "site", () -> {
|
||||
writeSingleElement(writer, "id", site.getId());
|
||||
writeSingleElement(writer, "name", site.getName());
|
||||
writeSingleElement(writer, "url", site.getUrl());
|
||||
}, Collections.singletonMap("child.site.url.inherit.append.path",
|
||||
site.getChildSiteUrlInheritAppendPath()));
|
||||
}
|
||||
});
|
||||
if (distributionManagement.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
writeElement(writer, "distributionManagement", () -> {
|
||||
writeSingleElement(writer, "downloadUrl", distributionManagement.getDownloadUrl());
|
||||
writeDeploymentRepository(writer, "repository", distributionManagement.getRepository());
|
||||
writeDeploymentRepository(writer, "snapshotRepository", distributionManagement.getSnapshotRepository());
|
||||
Site site = distributionManagement.getSite();
|
||||
if (!site.isEmpty()) {
|
||||
writeElement(writer, "site", () -> {
|
||||
writeSingleElement(writer, "id", site.getId());
|
||||
writeSingleElement(writer, "name", site.getName());
|
||||
writeSingleElement(writer, "url", site.getUrl());
|
||||
});
|
||||
}
|
||||
Relocation relocation = distributionManagement.getRelocation();
|
||||
if (!relocation.isEmpty()) {
|
||||
writeElement(writer, "relocation", () -> {
|
||||
writeSingleElement(writer, "groupId", relocation.getGroupId());
|
||||
writeSingleElement(writer, "artifactId", relocation.getArtifactId());
|
||||
writeSingleElement(writer, "version", relocation.getVersion());
|
||||
writeSingleElement(writer, "message", relocation.getMessage());
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void writeDeploymentRepository(IndentingWriter writer, String name, DeploymentRepository repository) {
|
||||
@ -469,19 +466,9 @@ public class MavenBuildWriter {
|
||||
writeSingleElement(writer, "name", repository.getName());
|
||||
writeSingleElement(writer, "url", repository.getUrl());
|
||||
writeSingleElement(writer, "layout", repository.getLayout());
|
||||
writeSingleElement(writer, "uniqueVersion", repository.getUniqueVersion().toString());
|
||||
this.writeRepositoryPolicy(writer, "releases", repository.getReleases());
|
||||
this.writeRepositoryPolicy(writer, "snapshots", repository.getSnapshots());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void writeRepositoryPolicy(IndentingWriter writer, String name, RepositoryPolicy policy) {
|
||||
if (!policy.isEmpty()) {
|
||||
writeElement(writer, name, () -> {
|
||||
writeSingleElement(writer, "enabled", policy.isEnabled().toString());
|
||||
writeSingleElement(writer, "updatePolicy", policy.getUpdatePolicy());
|
||||
writeSingleElement(writer, "checksumPolicy", policy.getChecksumPolicy());
|
||||
if (repository.getUniqueVersion() != null) {
|
||||
writeSingleElement(writer, "uniqueVersion", Boolean.toString(repository.getUniqueVersion()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -494,16 +481,6 @@ public class MavenBuildWriter {
|
||||
}
|
||||
}
|
||||
|
||||
private void writeElementWithAttributes(IndentingWriter writer, String name, Runnable withContent,
|
||||
Map<String, Object> attributeMap) {
|
||||
writer.print(String.format("<%s", name));
|
||||
attributeMap.entrySet().stream().filter((entry) -> entry.getValue() != null).forEach(
|
||||
(entry) -> writer.print(String.format(" %s=\"%s\"", entry.getKey(), entry.getValue().toString())));
|
||||
writer.println(">");
|
||||
writer.indented(withContent);
|
||||
writer.println(String.format("</%s>", name));
|
||||
}
|
||||
|
||||
private void writeElement(IndentingWriter writer, String name, Runnable withContent) {
|
||||
writer.println(String.format("<%s>", name));
|
||||
writer.indented(withContent);
|
||||
|
@ -16,17 +16,13 @@
|
||||
|
||||
package io.spring.initializr.generator.buildsystem.maven;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Maven DistributionManagement as defined in the Maven XSD: <a href=
|
||||
* "https://maven.apache.org/xsd/maven-4.0.0.xsd">https://maven.apache.org/xsd/maven-4.0.0.xsd</a>.
|
||||
* For further documentation see
|
||||
* <a href="https://maven.apache.org/pom.html#Distribution_Management">
|
||||
* https://maven.apache.org/pom.html#Distribution_Management </a>
|
||||
* Maven {@code <distributionManagement>} section.
|
||||
*
|
||||
* @author Joachim Pasquali
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class MavenDistributionManagement {
|
||||
|
||||
@ -40,7 +36,7 @@ public class MavenDistributionManagement {
|
||||
|
||||
private final Relocation relocation;
|
||||
|
||||
protected MavenDistributionManagement(final Builder builder) {
|
||||
MavenDistributionManagement(Builder builder) {
|
||||
this.downloadUrl = builder.downloadUrl;
|
||||
this.repository = builder.repository.build();
|
||||
this.snapshotRepository = builder.snapshotRepository.build();
|
||||
@ -53,22 +49,45 @@ public class MavenDistributionManagement {
|
||||
&& this.site.isEmpty() && this.relocation.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the URL where this project can be downloaded from.
|
||||
* @return the URL of the project's download page
|
||||
*/
|
||||
public String getDownloadUrl() {
|
||||
return this.downloadUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the information needed to deploy the artifacts generated by the project to a
|
||||
* remote repository.
|
||||
* @return the {@link DeploymentRepository} for released artifacts
|
||||
*/
|
||||
public DeploymentRepository getRepository() {
|
||||
return this.repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the information needed to deploy the snapshot artifacts generated by the
|
||||
* project to a remote repository.
|
||||
* @return the {@link DeploymentRepository} for snapshot artifacts
|
||||
*/
|
||||
public DeploymentRepository getSnapshotRepository() {
|
||||
return this.snapshotRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the information needed for deploying the web site of the project.
|
||||
* @return the {@link Site}
|
||||
*/
|
||||
public Site getSite() {
|
||||
return this.site;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the relocation information of the artifact if it has been moved to a new
|
||||
* groupId and/or artifactId.
|
||||
* @return the {@link Relocation}
|
||||
*/
|
||||
public Relocation getRelocation() {
|
||||
return this.relocation;
|
||||
}
|
||||
@ -77,211 +96,80 @@ public class MavenDistributionManagement {
|
||||
|
||||
private String downloadUrl;
|
||||
|
||||
private DeploymentRepositoryBuilder repository = new DeploymentRepositoryBuilder();
|
||||
private DeploymentRepository.Builder repository = new DeploymentRepository.Builder();
|
||||
|
||||
private DeploymentRepositoryBuilder snapshotRepository = new DeploymentRepositoryBuilder();
|
||||
private DeploymentRepository.Builder snapshotRepository = new DeploymentRepository.Builder();
|
||||
|
||||
private SiteBuilder site = new SiteBuilder();
|
||||
private Site.Builder site = new Site.Builder();
|
||||
|
||||
private RelocationBuilder relocation = new RelocationBuilder();
|
||||
private Relocation.Builder relocation = new Relocation.Builder();
|
||||
|
||||
public Builder downloadUrl(final String downloadUrl) {
|
||||
/**
|
||||
* Specify the URL where this project can be downloaded from.
|
||||
* @param downloadUrl the URL of the project's download page
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder downloadUrl(String downloadUrl) {
|
||||
this.downloadUrl = downloadUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder repository(Consumer<DeploymentRepositoryBuilder> repository) {
|
||||
/**
|
||||
* Customize the {@code repository} using the specified consumer.
|
||||
* @param repository a consumer of the current repository
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder repository(Consumer<DeploymentRepository.Builder> repository) {
|
||||
repository.accept(this.repository);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder snapshotRepository(Consumer<DeploymentRepositoryBuilder> snapshotRepository) {
|
||||
/**
|
||||
* Customize the {@code snapshotRepository} using the specified consumer.
|
||||
* @param snapshotRepository a consumer of the current snapshot repository
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder snapshotRepository(Consumer<DeploymentRepository.Builder> snapshotRepository) {
|
||||
snapshotRepository.accept(this.snapshotRepository);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder site(Consumer<SiteBuilder> site) {
|
||||
/**
|
||||
* Customize the {@code site} using the specified consumer.
|
||||
* @param site a consumer of the current site
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder site(Consumer<Site.Builder> site) {
|
||||
site.accept(this.site);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder relocation(Consumer<RelocationBuilder> relocation) {
|
||||
/**
|
||||
* Customize the {@code relocation} using the specified consumer.
|
||||
* @param relocation a consumer of the current relocation
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder relocation(Consumer<Relocation.Builder> relocation) {
|
||||
relocation.accept(this.relocation);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a {@link MavenDistributionManagement} with the current state of this
|
||||
* builder.
|
||||
* @return a {@link MavenDistributionManagement}
|
||||
*/
|
||||
public MavenDistributionManagement build() {
|
||||
return new MavenDistributionManagement(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class DeploymentRepositoryBuilder {
|
||||
|
||||
private Boolean uniqueVersion;
|
||||
|
||||
private RepositoryPolicyBuilder releases = new RepositoryPolicyBuilder();
|
||||
|
||||
private RepositoryPolicyBuilder snapshots = new RepositoryPolicyBuilder();
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String url;
|
||||
|
||||
private String layout;
|
||||
|
||||
public DeploymentRepositoryBuilder uniqueVersion(Boolean uniqueVersion) {
|
||||
this.uniqueVersion = uniqueVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeploymentRepositoryBuilder releases(Consumer<RepositoryPolicyBuilder> releases) {
|
||||
releases.accept(this.releases);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeploymentRepositoryBuilder snapshots(Consumer<RepositoryPolicyBuilder> snapshots) {
|
||||
snapshots.accept(this.snapshots);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeploymentRepositoryBuilder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeploymentRepositoryBuilder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeploymentRepositoryBuilder url(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeploymentRepositoryBuilder layout(String layout) {
|
||||
this.layout = layout;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DeploymentRepository build() {
|
||||
return new DeploymentRepository(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class RepositoryPolicyBuilder {
|
||||
|
||||
private Boolean enabled;
|
||||
|
||||
private String updatePolicy;
|
||||
|
||||
private String checksumPolicy;
|
||||
|
||||
public RepositoryPolicyBuilder enabled(Boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RepositoryPolicyBuilder updatePolicy(String updatePolicy) {
|
||||
this.updatePolicy = updatePolicy;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RepositoryPolicyBuilder checksumPolicy(String checksumPolicy) {
|
||||
this.checksumPolicy = checksumPolicy;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RepositoryPolicy build() {
|
||||
return new RepositoryPolicy(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class SiteBuilder {
|
||||
|
||||
private String id;
|
||||
|
||||
private String url;
|
||||
|
||||
private String name;
|
||||
|
||||
private Boolean childSiteUrlInheritAppendPath;
|
||||
|
||||
public SiteBuilder childSiteUrlInheritAppendPath(Boolean childSiteUrlInheritAppendPath) {
|
||||
this.childSiteUrlInheritAppendPath = childSiteUrlInheritAppendPath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SiteBuilder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SiteBuilder url(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SiteBuilder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Site build() {
|
||||
return new Site(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class RelocationBuilder {
|
||||
|
||||
private String groupId;
|
||||
|
||||
private String artifactId;
|
||||
|
||||
private String version;
|
||||
|
||||
private String message;
|
||||
|
||||
public RelocationBuilder groupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RelocationBuilder artifactId(String artifactId) {
|
||||
this.artifactId = artifactId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RelocationBuilder version(String version) {
|
||||
this.version = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RelocationBuilder message(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Relocation build() {
|
||||
return new Relocation(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Describe where to deploy artifacts.
|
||||
*/
|
||||
public static class DeploymentRepository {
|
||||
|
||||
private final Boolean uniqueVersion;
|
||||
|
||||
private final RepositoryPolicy releases;
|
||||
|
||||
private final RepositoryPolicy snapshots;
|
||||
|
||||
private final String id;
|
||||
|
||||
private final String name;
|
||||
@ -290,122 +178,240 @@ public class MavenDistributionManagement {
|
||||
|
||||
private final String layout;
|
||||
|
||||
protected DeploymentRepository(DeploymentRepositoryBuilder builder) {
|
||||
this.uniqueVersion = builder.uniqueVersion;
|
||||
this.releases = builder.releases.build();
|
||||
this.snapshots = builder.snapshots.build();
|
||||
private final Boolean uniqueVersion;
|
||||
|
||||
DeploymentRepository(Builder builder) {
|
||||
this.id = builder.id;
|
||||
this.name = builder.name;
|
||||
this.url = builder.url;
|
||||
this.layout = builder.layout;
|
||||
this.uniqueVersion = builder.uniqueVersion;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.uniqueVersion == null && this.id == null && this.name == null && this.url == null
|
||||
&& this.layout == null && this.releases.isEmpty() && this.snapshots.isEmpty();
|
||||
}
|
||||
|
||||
public Boolean getUniqueVersion() {
|
||||
return Optional.ofNullable(this.uniqueVersion).orElse(Boolean.TRUE);
|
||||
}
|
||||
|
||||
public RepositoryPolicy getReleases() {
|
||||
return this.releases;
|
||||
}
|
||||
|
||||
public RepositoryPolicy getSnapshots() {
|
||||
return this.snapshots;
|
||||
return this.id == null && this.name == null && this.url == null && this.layout == null
|
||||
&& this.uniqueVersion == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the identifier of the repository.
|
||||
* @return the repository ID
|
||||
*/
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the repository.
|
||||
* @return the repository name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the url of the repository to use to upload artifacts.
|
||||
* @return the repository url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the repository layout. Can be {@code default} or {@code legacy}.
|
||||
* @return the repository layout
|
||||
*/
|
||||
public String getLayout() {
|
||||
return this.layout;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class RepositoryPolicy {
|
||||
|
||||
private final Boolean enabled;
|
||||
|
||||
private final String updatePolicy;
|
||||
|
||||
private final String checksumPolicy;
|
||||
|
||||
protected RepositoryPolicy(RepositoryPolicyBuilder builder) {
|
||||
this.enabled = builder.enabled;
|
||||
this.updatePolicy = builder.updatePolicy;
|
||||
this.checksumPolicy = builder.checksumPolicy;
|
||||
/**
|
||||
* Return whether to assign snapshots a unique version comprised of the timestamp
|
||||
* and build number, or to use the same version each time.
|
||||
* @return {@code true} to assign each snapshot a unique version
|
||||
*/
|
||||
public Boolean getUniqueVersion() {
|
||||
return this.uniqueVersion;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.enabled == null && this.updatePolicy == null && this.checksumPolicy == null;
|
||||
}
|
||||
public static class Builder {
|
||||
|
||||
public Boolean isEnabled() {
|
||||
return Optional.ofNullable(this.enabled).orElse(Boolean.TRUE);
|
||||
}
|
||||
private String id;
|
||||
|
||||
public String getUpdatePolicy() {
|
||||
return this.updatePolicy;
|
||||
}
|
||||
private String name;
|
||||
|
||||
private String url;
|
||||
|
||||
private String layout;
|
||||
|
||||
private Boolean uniqueVersion;
|
||||
|
||||
/**
|
||||
* Set the id of the repository.
|
||||
* @param id the identifier
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the repository.
|
||||
* @param name the name
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the url of the repository to use to upload artifacts. Specify both the
|
||||
* location and the transport protocol used to transfer a built artifact to
|
||||
* the repository.
|
||||
* @param url the url
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder url(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the repository layout, can be {@code default} or {@code legacy}.
|
||||
* @param layout the layout
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder layout(String layout) {
|
||||
this.layout = layout;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether snapshots should be assigned a unique version comprised of the
|
||||
* timestamp and build number.
|
||||
* @param uniqueVersion {@code true} to use unique version for snapshots
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder uniqueVersion(Boolean uniqueVersion) {
|
||||
this.uniqueVersion = uniqueVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a {@link DeploymentRepository} with the current state of this
|
||||
* builder.
|
||||
* @return a {@link DeploymentRepository}
|
||||
*/
|
||||
public DeploymentRepository build() {
|
||||
return new DeploymentRepository(this);
|
||||
}
|
||||
|
||||
public String getChecksumPolicy() {
|
||||
return this.checksumPolicy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Information needed for deploying the web site of the project.
|
||||
*/
|
||||
public static class Site {
|
||||
|
||||
private final String id;
|
||||
|
||||
private final String url;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final Boolean childSiteUrlInheritAppendPath;
|
||||
private final String url;
|
||||
|
||||
public Site(SiteBuilder builder) {
|
||||
Site(Builder builder) {
|
||||
this.id = builder.id;
|
||||
this.url = builder.url;
|
||||
this.name = builder.name;
|
||||
this.childSiteUrlInheritAppendPath = builder.childSiteUrlInheritAppendPath;
|
||||
this.url = builder.url;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.id == null && this.url == null && this.name == null;
|
||||
return this.id == null && this.name == null && this.url == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the identifier of the repository.
|
||||
* @return the repository ID
|
||||
*/
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the repository.
|
||||
* @return the repository name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Boolean getChildSiteUrlInheritAppendPath() {
|
||||
return this.childSiteUrlInheritAppendPath;
|
||||
/**
|
||||
* Return the url of the repository to use to upload the site.
|
||||
* @return the repository url
|
||||
*/
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* Set the id of the repository.
|
||||
* @param id the identifier
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the repository.
|
||||
* @param name the name
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the url of the repository to use to upload the site. Specify both the
|
||||
* location and the transport protocol to use.
|
||||
* @param url the url
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder url(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a {@link Site} with the current state of this builder.
|
||||
* @return a {@link Site}
|
||||
*/
|
||||
public Site build() {
|
||||
return new Site(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Relocation information of the artifact if it has been moved to a new groupId and/or
|
||||
* artifactId.
|
||||
*/
|
||||
public static class Relocation {
|
||||
|
||||
private final String groupId;
|
||||
@ -416,7 +422,7 @@ public class MavenDistributionManagement {
|
||||
|
||||
private final String message;
|
||||
|
||||
public Relocation(RelocationBuilder builder) {
|
||||
Relocation(Builder builder) {
|
||||
this.groupId = builder.groupId;
|
||||
this.artifactId = builder.artifactId;
|
||||
this.version = builder.version;
|
||||
@ -427,22 +433,98 @@ public class MavenDistributionManagement {
|
||||
return this.groupId == null && this.artifactId == null && this.version == null && this.message == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the new group ID of the dependency.
|
||||
* @return the relocated group ID
|
||||
*/
|
||||
public String getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the new artifact ID of the dependency.
|
||||
* @return the relocated artifact ID
|
||||
*/
|
||||
public String getArtifactId() {
|
||||
return this.artifactId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the new version of the dependency.
|
||||
* @return the relocated version
|
||||
*/
|
||||
public String getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a message that provides more details about the relocation.
|
||||
* @return the relocation message
|
||||
*/
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private String groupId;
|
||||
|
||||
private String artifactId;
|
||||
|
||||
private String version;
|
||||
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* Specify the new group ID of the dependency.
|
||||
* @param groupId the new group ID of the dependency
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder groupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the new artifact ID of the dependency.
|
||||
* @param artifactId the new artifact ID of the dependency
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder artifactId(String artifactId) {
|
||||
this.artifactId = artifactId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the new version of the dependency.
|
||||
* @param version the new version of the dependency
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder version(String version) {
|
||||
this.version = version;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a message that provides more details about the relocation.
|
||||
* @param message the relocation message
|
||||
* @return this for method chaining
|
||||
*/
|
||||
public Builder message(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a {@link Relocation} with the current state of this builder.
|
||||
* @return a {@link Relocation}
|
||||
*/
|
||||
public Relocation build() {
|
||||
return new Relocation(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -659,74 +659,98 @@ class MavenBuildWriterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void pomWithDistributionManagement() {
|
||||
void powWithDistributionManagementEmpty() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
generatePom(build, (pom) -> assertThat(pom).nodeAtPath("/project/distributionManagement").isNull());
|
||||
}
|
||||
|
||||
build.distributionManagement().downloadUrl("downloadUrl")
|
||||
.relocation((relocation) -> relocation.groupId("groupId").artifactId("my.artifact").version("version")
|
||||
.message("message"))
|
||||
.repository((repository) -> repository.id("id").layout("layout").name("name")
|
||||
.releases((releases) -> releases.checksumPolicy("checksumPolicy").updatePolicy("updatePolicy"))
|
||||
.snapshots(
|
||||
(snapshots) -> snapshots.checksumPolicy("checksumPolicy").updatePolicy("updatePolicy"))
|
||||
.url("url"))
|
||||
.site((site) -> site.id("id").name("name").url("url").childSiteUrlInheritAppendPath(Boolean.TRUE))
|
||||
.snapshotRepository((snapshotRepository) -> snapshotRepository.id("id").layout("layout").name("name")
|
||||
.releases((releases) -> releases.checksumPolicy("checksumPolicy").updatePolicy("updatePolicy"))
|
||||
.snapshots(
|
||||
(snapshots) -> snapshots.checksumPolicy("checksumPolicy").updatePolicy("updatePolicy"))
|
||||
.url("url"));
|
||||
|
||||
@Test
|
||||
void powWithDistributionManagementDownloadUrl() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
build.distributionManagement().downloadUrl("https://example.com/download");
|
||||
generatePom(build, (pom) -> {
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/downloadUrl").isEqualTo("downloadUrl");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/relocation/groupId").isEqualTo("groupId");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/relocation/artifactId")
|
||||
.isEqualTo("my.artifact");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/relocation/version").isEqualTo("version");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/relocation/message").isEqualTo("message");
|
||||
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/repository/id").isEqualTo("id");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/repository/layout").isEqualTo("layout");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/repository/name").isEqualTo("name");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/repository/url").isEqualTo("url");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/repository/releases/checksumPolicy")
|
||||
.isEqualTo("checksumPolicy");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/repository/releases/updatePolicy")
|
||||
.isEqualTo("updatePolicy");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/repository/snapshots/checksumPolicy")
|
||||
.isEqualTo("checksumPolicy");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/repository/snapshots/updatePolicy")
|
||||
.isEqualTo("updatePolicy");
|
||||
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/snapshotRepository/id").isEqualTo("id");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/snapshotRepository/layout").isEqualTo("layout");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/snapshotRepository/name").isEqualTo("name");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/snapshotRepository/url").isEqualTo("url");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/snapshotRepository/releases/checksumPolicy")
|
||||
.isEqualTo("checksumPolicy");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/snapshotRepository/releases/updatePolicy")
|
||||
.isEqualTo("updatePolicy");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/snapshotRepository/snapshots/checksumPolicy")
|
||||
.isEqualTo("checksumPolicy");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/snapshotRepository/snapshots/updatePolicy")
|
||||
.isEqualTo("updatePolicy");
|
||||
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/site/id").isEqualTo("id");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/site/name").isEqualTo("name");
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/site/url").isEqualTo("url");
|
||||
assertThat(pom).nodeAtPath("/project/distributionManagement/site").matches((node) -> node.getAttributes()
|
||||
.getNamedItem("child.site.url.inherit.append.path").getTextContent().equals("true"));
|
||||
NodeAssert distributionManagement = pom.nodeAtPath("/project/distributionManagement");
|
||||
assertThat(distributionManagement).textAtPath("downloadUrl").isEqualTo("https://example.com/download");
|
||||
assertThat(distributionManagement).nodeAtPath("repository").isNull();
|
||||
assertThat(distributionManagement).nodeAtPath("snapshotRepository").isNull();
|
||||
assertThat(distributionManagement).nodeAtPath("site").isNull();
|
||||
assertThat(distributionManagement).nodeAtPath("relocation").isNull();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void pomWithDistributionManagementWithNullAttributeValue() {
|
||||
void powWithDistributionManagementRepository() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
build.distributionManagement().site((site) -> site.id("id").childSiteUrlInheritAppendPath(null));
|
||||
build.distributionManagement().repository((repository) -> repository.id("released-repo").name("released repo")
|
||||
.url("https://upload.example.com/releases"));
|
||||
generatePom(build, (pom) -> {
|
||||
assertThat(pom).textAtPath("/project/distributionManagement/site/id").isEqualTo("id");
|
||||
assertThat(pom).nodeAtPath("/project/distributionManagement/site")
|
||||
.matches((node) -> node.getAttributes().getNamedItem("child.site.url.inherit.append.path") == null);
|
||||
NodeAssert distributionManagement = pom.nodeAtPath("/project/distributionManagement");
|
||||
assertThat(distributionManagement).textAtPath("downloadUrl").isNullOrEmpty();
|
||||
assertThat(distributionManagement).textAtPath("repository/id").isEqualTo("released-repo");
|
||||
assertThat(distributionManagement).textAtPath("repository/name").isEqualTo("released repo");
|
||||
assertThat(distributionManagement).textAtPath("repository/url")
|
||||
.isEqualTo("https://upload.example.com/releases");
|
||||
assertThat(distributionManagement).textAtPath("repository/layout").isNullOrEmpty();
|
||||
assertThat(distributionManagement).textAtPath("repository/uniqueVersion").isNullOrEmpty();
|
||||
assertThat(distributionManagement).nodeAtPath("snapshotRepository").isNull();
|
||||
assertThat(distributionManagement).nodeAtPath("site").isNull();
|
||||
assertThat(distributionManagement).nodeAtPath("relocation").isNull();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void powWithDistributionManagementSnapshotRepository() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
build.distributionManagement().snapshotRepository((repository) -> repository.id("snapshot-repo")
|
||||
.name("snapshot repo").url("scp://upload.example.com/snapshots").layout("legacy").uniqueVersion(true));
|
||||
generatePom(build, (pom) -> {
|
||||
NodeAssert distributionManagement = pom.nodeAtPath("/project/distributionManagement");
|
||||
assertThat(distributionManagement).textAtPath("downloadUrl").isNullOrEmpty();
|
||||
assertThat(distributionManagement).nodeAtPath("repository").isNull();
|
||||
assertThat(distributionManagement).textAtPath("snapshotRepository/id").isEqualTo("snapshot-repo");
|
||||
assertThat(distributionManagement).textAtPath("snapshotRepository/name").isEqualTo("snapshot repo");
|
||||
assertThat(distributionManagement).textAtPath("snapshotRepository/url")
|
||||
.isEqualTo("scp://upload.example.com/snapshots");
|
||||
assertThat(distributionManagement).textAtPath("snapshotRepository/layout").isEqualTo("legacy");
|
||||
assertThat(distributionManagement).textAtPath("snapshotRepository/uniqueVersion").isEqualTo("true");
|
||||
assertThat(distributionManagement).nodeAtPath("site").isNull();
|
||||
assertThat(distributionManagement).nodeAtPath("relocation").isNull();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void powWithDistributionManagementSite() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
build.distributionManagement().site((site) -> site.id("website").name("web site"))
|
||||
.site((site) -> site.url("scp://www.example.com/www/docs/project"));
|
||||
generatePom(build, (pom) -> {
|
||||
NodeAssert distributionManagement = pom.nodeAtPath("/project/distributionManagement");
|
||||
assertThat(distributionManagement).textAtPath("downloadUrl").isNullOrEmpty();
|
||||
assertThat(distributionManagement).nodeAtPath("repository").isNull();
|
||||
assertThat(distributionManagement).nodeAtPath("snapshotRepository").isNull();
|
||||
assertThat(distributionManagement).textAtPath("site/id").isEqualTo("website");
|
||||
assertThat(distributionManagement).textAtPath("site/name").isEqualTo("web site");
|
||||
assertThat(distributionManagement).textAtPath("site/url")
|
||||
.isEqualTo("scp://www.example.com/www/docs/project");
|
||||
assertThat(distributionManagement).nodeAtPath("relocation").isNull();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void powWithDistributionManagementRelocation() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
build.distributionManagement().relocation((relocation) -> relocation.groupId("com.example.new")
|
||||
.artifactId("project").version("1.0.0").message("moved"));
|
||||
generatePom(build, (pom) -> {
|
||||
NodeAssert distributionManagement = pom.nodeAtPath("/project/distributionManagement");
|
||||
assertThat(distributionManagement).textAtPath("downloadUrl").isNullOrEmpty();
|
||||
assertThat(distributionManagement).nodeAtPath("repository").isNull();
|
||||
assertThat(distributionManagement).nodeAtPath("snapshotRepository").isNull();
|
||||
assertThat(distributionManagement).nodeAtPath("site").isNull();
|
||||
assertThat(distributionManagement).textAtPath("relocation/groupId").isEqualTo("com.example.new");
|
||||
assertThat(distributionManagement).textAtPath("relocation/artifactId").isEqualTo("project");
|
||||
assertThat(distributionManagement).textAtPath("relocation/version").isEqualTo("1.0.0");
|
||||
assertThat(distributionManagement).textAtPath("relocation/message").isEqualTo("moved");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -16,21 +16,22 @@
|
||||
|
||||
package io.spring.initializr.generator.buildsystem.maven;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenDistributionManagement.DeploymentRepository;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenDistributionManagement.Site;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link MavenDistributionManagement}
|
||||
* Tests for {@link MavenDistributionManagement}.
|
||||
*
|
||||
* @author Joachim Pasquali
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class MavenDistributionManagementTests {
|
||||
|
||||
private static final String TEST_URL = "testURL";
|
||||
|
||||
@Test
|
||||
void emptyDistributionManagement() {
|
||||
void distributionManagementEmpty() {
|
||||
MavenDistributionManagement result = builder().build();
|
||||
assertThat(result.isEmpty()).isTrue();
|
||||
assertThat(result.getRelocation().isEmpty()).isTrue();
|
||||
@ -40,75 +41,59 @@ class MavenDistributionManagementTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void addDownloadUrl() {
|
||||
MavenDistributionManagement result = builder().downloadUrl(TEST_URL).build();
|
||||
assertThat(result.getDownloadUrl()).isEqualTo(TEST_URL);
|
||||
void distributionManagementWithDownloadUrl() {
|
||||
MavenDistributionManagement mdm = builder().downloadUrl("https://example.com/download").build();
|
||||
assertThat(mdm.getDownloadUrl()).isEqualTo("https://example.com/download");
|
||||
}
|
||||
|
||||
@Test
|
||||
void addRelocation() {
|
||||
MavenDistributionManagement result = builder().relocation((relocation) -> relocation.artifactId("artifactId")
|
||||
.groupId("groupId").version("version").message("message")).build();
|
||||
assertThat(result.getRelocation().getArtifactId()).isEqualTo("artifactId");
|
||||
assertThat(result.getRelocation().getGroupId()).isEqualTo("groupId");
|
||||
assertThat(result.getRelocation().getVersion()).isEqualTo("version");
|
||||
assertThat(result.getRelocation().getMessage()).isEqualTo("message");
|
||||
void distributionManagementWithRepository() {
|
||||
MavenDistributionManagement mdm = builder()
|
||||
.repository((repository) -> repository.id("released-repo").name("released repo")
|
||||
.url("https://upload.example.com/releases"))
|
||||
.repository((repository) -> repository.layout("default")).build();
|
||||
DeploymentRepository repository = mdm.getRepository();
|
||||
assertThat(repository.getId()).isEqualTo("released-repo");
|
||||
assertThat(repository.getName()).isEqualTo("released repo");
|
||||
assertThat(repository.getUrl()).isEqualTo("https://upload.example.com/releases");
|
||||
assertThat(repository.getLayout()).isEqualTo("default");
|
||||
assertThat(repository.getUniqueVersion()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void addRepository() {
|
||||
MavenDistributionManagement result = builder().repository((repository) -> repository.id("id").layout("layout")
|
||||
.name("name")
|
||||
.releases((releases) -> releases.checksumPolicy("checksumPolicy").enabled(Boolean.FALSE)
|
||||
.updatePolicy("updatePolicy"))
|
||||
.snapshots((snapshots) -> snapshots.checksumPolicy("checksumPolicy").updatePolicy("updatePolicy"))
|
||||
.uniqueVersion(Boolean.FALSE).url("url")).build();
|
||||
assertThat(result.getRepository().getId()).isEqualTo("id");
|
||||
assertThat(result.getRepository().getUrl()).isEqualTo("url");
|
||||
assertThat(result.getRepository().getUniqueVersion()).isFalse();
|
||||
assertThat(result.getRepository().getLayout()).isEqualTo("layout");
|
||||
assertThat(result.getRepository().getName()).isEqualTo("name");
|
||||
assertThat(result.getRepository().getReleases().isEnabled()).isFalse();
|
||||
assertThat(result.getRepository().getReleases().getChecksumPolicy()).isEqualTo("checksumPolicy");
|
||||
assertThat(result.getRepository().getReleases().getUpdatePolicy()).isEqualTo("updatePolicy");
|
||||
|
||||
assertThat(result.getRepository().getSnapshots().getChecksumPolicy()).isEqualTo("checksumPolicy");
|
||||
assertThat(result.getRepository().getSnapshots().getUpdatePolicy()).isEqualTo("updatePolicy");
|
||||
assertThat(result.getRepository().getSnapshots().isEnabled()).isTrue();
|
||||
|
||||
void distributionManagementWithSnapshotRepository() {
|
||||
MavenDistributionManagement mdm = builder()
|
||||
.snapshotRepository((repository) -> repository.id("snapshot-repo").name("snapshot repo")
|
||||
.url("scp://upload.example.com/snapshots"))
|
||||
.snapshotRepository((repository) -> repository.uniqueVersion(true)).build();
|
||||
DeploymentRepository snapshotRepository = mdm.getSnapshotRepository();
|
||||
assertThat(snapshotRepository.getId()).isEqualTo("snapshot-repo");
|
||||
assertThat(snapshotRepository.getName()).isEqualTo("snapshot repo");
|
||||
assertThat(snapshotRepository.getUrl()).isEqualTo("scp://upload.example.com/snapshots");
|
||||
assertThat(snapshotRepository.getLayout()).isNull();
|
||||
assertThat(snapshotRepository.getUniqueVersion()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void addSnapshotRepository() {
|
||||
MavenDistributionManagement result = builder().snapshotRepository((repository) -> repository.id("id")
|
||||
.layout("layout").name("name").releases((releases) -> releases.checksumPolicy("checksumPolicy")
|
||||
.enabled(Boolean.TRUE).updatePolicy("updatePolicy"))
|
||||
.uniqueVersion(Boolean.FALSE).url("url")).build();
|
||||
assertThat(result.getSnapshotRepository().getId()).isEqualTo("id");
|
||||
assertThat(result.getSnapshotRepository().getLayout()).isEqualTo("layout");
|
||||
assertThat(result.getSnapshotRepository().getName()).isEqualTo("name");
|
||||
assertThat(result.getSnapshotRepository().getReleases().getChecksumPolicy()).isEqualTo("checksumPolicy");
|
||||
assertThat(result.getSnapshotRepository().getReleases().getUpdatePolicy()).isEqualTo("updatePolicy");
|
||||
|
||||
assertThat(result.getSnapshotRepository().getSnapshots().isEmpty()).isTrue();
|
||||
|
||||
void distributionManagementWithSite() {
|
||||
MavenDistributionManagement mdm = builder().site((site) -> site.id("website").name("web site"))
|
||||
.site((site) -> site.url("scp://www.example.com/www/docs/project")).build();
|
||||
Site site = mdm.getSite();
|
||||
assertThat(site.getId()).isEqualTo("website");
|
||||
assertThat(site.getName()).isEqualTo("web site");
|
||||
assertThat(site.getUrl()).isEqualTo("scp://www.example.com/www/docs/project");
|
||||
}
|
||||
|
||||
@Test
|
||||
void addSite() {
|
||||
MavenDistributionManagement result = builder()
|
||||
.site((site) -> site.id("id").name("name").url("url").childSiteUrlInheritAppendPath(Boolean.FALSE))
|
||||
.build();
|
||||
assertThat(result.getSite().getId()).isEqualTo("id");
|
||||
assertThat(result.getSite().getName()).isEqualTo("name");
|
||||
assertThat(result.getSite().getUrl()).isEqualTo("url");
|
||||
assertThat(result.getSite().getChildSiteUrlInheritAppendPath()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void addSiteWithNullAttribute() {
|
||||
MavenDistributionManagement result = builder().site((site) -> site.id("id")).build();
|
||||
assertThat(result.getSite().getChildSiteUrlInheritAppendPath()).isNull();
|
||||
void distributionManagementWithRelocation() {
|
||||
MavenDistributionManagement mdm = builder()
|
||||
.relocation(
|
||||
(relocation) -> relocation.groupId("com.example.new").artifactId("project").version("1.0.0"))
|
||||
.relocation((relocation) -> relocation.message("Moved to com.example.new")).build();
|
||||
assertThat(mdm.getRelocation().getGroupId()).isEqualTo("com.example.new");
|
||||
assertThat(mdm.getRelocation().getArtifactId()).isEqualTo("project");
|
||||
assertThat(mdm.getRelocation().getVersion()).isEqualTo("1.0.0");
|
||||
assertThat(mdm.getRelocation().getMessage()).isEqualTo("Moved to com.example.new");
|
||||
}
|
||||
|
||||
private MavenDistributionManagement.Builder builder() {
|
||||
|
Loading…
Reference in New Issue
Block a user