#20 - Turned DeploymentInformation into an interface.
This commit is contained in:
@@ -21,6 +21,7 @@ import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.data.release.deployment.DefaultDeploymentInformation;
|
||||
import org.springframework.data.release.deployment.DeploymentInformation;
|
||||
import org.springframework.data.release.deployment.DeploymentProperties;
|
||||
import org.springframework.data.release.io.Workspace;
|
||||
@@ -146,7 +147,7 @@ class GradleBuildSystem implements BuildSystem {
|
||||
*/
|
||||
@Override
|
||||
public DeploymentInformation deploy(ModuleIteration module) {
|
||||
return new DeploymentInformation(module, properties);
|
||||
return new DefaultDeploymentInformation(module, properties);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.data.release.deployment.DefaultDeploymentInformation;
|
||||
import org.springframework.data.release.deployment.DeploymentInformation;
|
||||
import org.springframework.data.release.deployment.DeploymentProperties;
|
||||
import org.springframework.data.release.deployment.DeploymentProperties.Gpg;
|
||||
@@ -242,7 +243,7 @@ class MavenBuildSystem implements BuildSystem {
|
||||
|
||||
Assert.notNull(module, "Module must not be null!");
|
||||
|
||||
DeploymentInformation information = new DeploymentInformation(module, properties);
|
||||
DeploymentInformation information = new DefaultDeploymentInformation(module, properties);
|
||||
|
||||
deployToArtifactory(module, information);
|
||||
deployToMavenCentral(module);
|
||||
|
||||
@@ -80,7 +80,7 @@ class ArtifactoryClient {
|
||||
}
|
||||
}
|
||||
|
||||
private void handle(String log, HttpClientErrorException o_O, ModuleIteration module) {
|
||||
void handle(String log, HttpClientErrorException o_O, ModuleIteration module) {
|
||||
|
||||
try {
|
||||
|
||||
@@ -115,7 +115,7 @@ class ArtifactoryClient {
|
||||
}
|
||||
|
||||
@Value
|
||||
private static class PromotionRequest {
|
||||
static class PromotionRequest {
|
||||
String targetRepo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright 2015-2016 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.release.deployment;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.release.model.ModuleIteration;
|
||||
import org.springframework.web.util.UriTemplate;
|
||||
|
||||
/**
|
||||
* Information about a deployment.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||
public class DefaultDeploymentInformation implements DeploymentInformation {
|
||||
|
||||
private static UriTemplate REPOSITORY_TEMPLATE = new UriTemplate(
|
||||
"artifactory::default::{server};build.number={buildNumber};build.name={buildName}");
|
||||
|
||||
private final @Getter @NonNull ModuleIteration module;
|
||||
private final @NonNull DeploymentProperties properties;
|
||||
private final @Getter String buildNumber;
|
||||
|
||||
public DefaultDeploymentInformation(ModuleIteration module, DeploymentProperties properties) {
|
||||
this(module, properties, String.valueOf(LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.release.deployment.DeploymentInformation#getBuildName()
|
||||
*/
|
||||
@Override
|
||||
public String getBuildName() {
|
||||
return module.getProject().getFullName().concat(" - Release");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.release.deployment.DeploymentInformation#getTargetRepository()
|
||||
*/
|
||||
@Override
|
||||
public String getTargetRepository() {
|
||||
return properties.getRepositoryPrefix()
|
||||
.concat(module.getIteration().isPublic() ? "libs-release-local" : "libs-milestone-local");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.release.deployment.DeploymentInformation#getDeploymentTargetUrl()
|
||||
*/
|
||||
@Override
|
||||
public String getDeploymentTargetUrl() {
|
||||
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("server", properties.getStagingRepositoryUrl());
|
||||
parameters.putAll(getBuildInfoParameters());
|
||||
|
||||
return REPOSITORY_TEMPLATE.expand(parameters).toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.release.deployment.DeploymentInformation#getBuildInfoParameters()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getBuildInfoParameters() {
|
||||
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("buildNumber", getBuildNumber());
|
||||
parameters.put("buildName", getBuildName());
|
||||
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2016 the original author or authors.
|
||||
* Copyright 2016 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.
|
||||
@@ -15,81 +15,54 @@
|
||||
*/
|
||||
package org.springframework.data.release.deployment;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.release.model.ModuleIteration;
|
||||
import org.springframework.web.util.UriTemplate;
|
||||
|
||||
/**
|
||||
* Information about a deployment.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class DeploymentInformation {
|
||||
|
||||
private static UriTemplate REPOSITORY_TEMPLATE = new UriTemplate(
|
||||
"artifactory::default::{server};build.number={buildNumber};build.name={buildName}");
|
||||
|
||||
private final @Getter @NonNull ModuleIteration module;
|
||||
private final @NonNull DeploymentProperties properties;
|
||||
|
||||
/**
|
||||
* Returns a unique build number for this particular deployment.
|
||||
*/
|
||||
private final @Getter String buildNumber = String.valueOf(LocalDateTime.now().toEpochSecond(ZoneOffset.UTC));
|
||||
public interface DeploymentInformation {
|
||||
|
||||
/**
|
||||
* Returns the name of the build.
|
||||
*
|
||||
* @return
|
||||
* @return will never be {@literal null} or empty.
|
||||
*/
|
||||
public String getBuildName() {
|
||||
return module.getProject().getFullName().concat(" - Release");
|
||||
}
|
||||
String getBuildName();
|
||||
|
||||
/**
|
||||
* Returns the name of the repository to deploy to.
|
||||
* Returns a unique build number for this particular deployment.
|
||||
*
|
||||
* @return
|
||||
* @return will never be {@literal null} or empty.
|
||||
*/
|
||||
public String getTargetRepository() {
|
||||
return properties.getRepositoryPrefix()
|
||||
.concat(module.getIteration().isPublic() ? "libs-release-local" : "libs-milestone-local");
|
||||
}
|
||||
String getBuildNumber();
|
||||
|
||||
/**
|
||||
* Returns the full URL to be used as deployment target.
|
||||
*
|
||||
* @return will never be {@literal null} or empty.
|
||||
*/
|
||||
String getDeploymentTargetUrl();
|
||||
|
||||
/**
|
||||
* Returns the name of the repository to deploy to.
|
||||
*
|
||||
* @return will never be {@literal null} or empty.
|
||||
*/
|
||||
String getTargetRepository();
|
||||
|
||||
/**
|
||||
* Returns the {@link ModuleIteration} the deployment information was created for.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDeploymentTargetUrl() {
|
||||
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("server", properties.getStagingRepositoryUrl());
|
||||
parameters.putAll(getBuildInfoParameters());
|
||||
|
||||
return REPOSITORY_TEMPLATE.expand(parameters).toString();
|
||||
}
|
||||
ModuleIteration getModule();
|
||||
|
||||
/**
|
||||
* Returns a {@link Map} to expand a URI template to access the build information.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getBuildInfoParameters() {
|
||||
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("buildNumber", buildNumber);
|
||||
parameters.put("buildName", getBuildName());
|
||||
|
||||
return parameters;
|
||||
}
|
||||
Map<String, Object> getBuildInfoParameters();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.data.release.model.ReleaseTrains;
|
||||
import org.springframework.data.release.model.TrainIteration;
|
||||
|
||||
/**
|
||||
* Integration test for {@link DeploymentInformation}.
|
||||
* Integration test for {@link DefaultDeploymentInformation}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ public class DeploymentInformationIntegrationTests extends AbstractIntegrationTe
|
||||
TrainIteration iteration = new TrainIteration(ReleaseTrains.HOPPER, Iteration.M1);
|
||||
ModuleIteration buildModule = iteration.getModule(Projects.BUILD);
|
||||
|
||||
DeploymentInformation information = new DeploymentInformation(buildModule, properties);
|
||||
DeploymentInformation information = new DefaultDeploymentInformation(buildModule, properties);
|
||||
|
||||
assertThat(information.getDeploymentTargetUrl(), containsString(properties.getServer().getUri().toString()));
|
||||
assertThat(information.getBuildName(), is("Spring Data Build - Release"));
|
||||
|
||||
Reference in New Issue
Block a user