Revert "Prepare Maven Publisher API workflow."

This reverts commit d0742e1225.
This commit is contained in:
Jens Schauder
2024-07-12 14:51:03 +02:00
parent 98565b49f3
commit 7bccf3ea4a
8 changed files with 27 additions and 173 deletions

View File

@@ -253,7 +253,7 @@ public class BuildOperations {
? openStagingRepository(iteration) //
: StagingRepository.EMPTY;
BuildExecutor.Summary<DeploymentInformation> summary = executor.doWithBuildSystemOrdered(iteration.filter(it -> it.getProject() == BUILD || it.getProject() == COMMONS),
BuildExecutor.Summary<DeploymentInformation> summary = executor.doWithBuildSystemOrdered(iteration,
(buildSystem, moduleIteration) -> buildSystem.deploy(moduleIteration, stagingRepository));
Train train = iteration.getTrain();

View File

@@ -20,8 +20,8 @@ import org.springframework.data.release.deployment.StagingRepository;
import org.springframework.data.release.model.JavaVersion;
import org.springframework.data.release.model.ModuleIteration;
import org.springframework.data.release.model.Phase;
import org.springframework.data.release.model.ProjectAware;
import org.springframework.data.release.model.SupportedProject;
import org.springframework.data.release.model.ProjectAware;
import org.springframework.data.release.model.Train;
import org.springframework.data.release.model.TrainIteration;
import org.springframework.plugin.core.Plugin;
@@ -33,7 +33,7 @@ import org.springframework.plugin.core.Plugin;
* @author Mark Paluch
* @author Greg Turnquist
*/
public interface BuildSystem extends Plugin<SupportedProject> {
interface BuildSystem extends Plugin<SupportedProject> {
/**
* Updates the project descriptors for the given {@link ModuleIteration} using the given {@link UpdateInformation}.

View File

@@ -32,18 +32,14 @@ import java.io.InputStream;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.io.IOUtils;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import org.springframework.data.release.build.CommandLine.Argument;
@@ -62,7 +58,6 @@ import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.xmlbeam.ProjectionFactory;
import org.xmlbeam.XBProjector;
import org.xmlbeam.dom.DOMAccess;
@@ -85,19 +80,18 @@ class MavenBuildSystem implements BuildSystem {
ProjectionFactory projectionFactory;
Logger logger;
MavenRuntime mvn;
MavenProperties mavenProperties;
DeploymentProperties properties;
Gpg gpg;
Environment env;
DeploymentProperties deploymentProperties;
static final String REPO_OPENING_TAG = "<repository>";
static final String REPO_CLOSING_TAG = "</repository>";
@Override
public BuildSystem withJavaVersion(JavaVersion javaVersion) {
return new MavenBuildSystem(workspace, projectionFactory, logger, mvn.withJavaVersion(javaVersion), mavenProperties,
properties, gpg, env, deploymentProperties);
return new MavenBuildSystem(workspace, projectionFactory, logger, mvn.withJavaVersion(javaVersion), properties, gpg,
env);
}
/*
@@ -192,30 +186,14 @@ class MavenBuildSystem implements BuildSystem {
@Override
public StagingRepository open(Train train) {
MavenCentral properties = this.properties.getMavenCentral();
Assert.notNull(properties, "Maven Central properties must not be null");
Assert.hasText(properties.getStagingProfileId(), "Staging Profile Identifier must not be empty");
if (properties.getProcess() == MavenCentral.Publishing.OSSRH) {
return openRemoteStagingRepository(train, properties);
}
String instance = UUID.randomUUID().toString();
File stagingRoot = new File(mavenProperties.getLocalStaging(), instance);
stagingRoot.mkdirs();
return StagingRepository.ofFile(stagingRoot.getPath());
}
private StagingRepository openRemoteStagingRepository(Train train, MavenCentral properties) {
Assert.notNull(properties.getMavenCentral(), "Maven Central properties must not be null");
Assert.hasText(properties.getMavenCentral().getStagingProfileId(), "Staging Profile Identifier must not be empty");
CommandLine arguments = CommandLine.of(goal("nexus-staging:rc-open"), //
profile("central"), //
arg("stagingProfileId").withValue(properties.getStagingProfileId()), //
arg("stagingProfileId").withValue(properties.getMavenCentral().getStagingProfileId()), //
arg("openedRepositoryMessageFormat").withValue("'" + REPO_OPENING_TAG + "%s" + REPO_CLOSING_TAG + "'"))
.andIf(!ObjectUtils.isEmpty(this.properties.getSettingsXml()),
() -> settingsXml(this.properties.getSettingsXml()));
.andIf(!ObjectUtils.isEmpty(properties.getSettingsXml()), () -> settingsXml(properties.getSettingsXml()));
MavenRuntime.MavenInvocationResult invocationResult = mvn.execute(train.getSupportedProject(BUILD), arguments);
@@ -243,16 +221,12 @@ class MavenBuildSystem implements BuildSystem {
Assert.notNull(stagingRepository, "StagingRepository must not be null");
Assert.isTrue(stagingRepository.isPresent(), "StagingRepository must be present");
if (deploymentProperties.getMavenCentral().getProcess() == MavenCentral.Publishing.OSSRH
&& stagingRepository.isRemote()) {
CommandLine arguments = CommandLine.of(goal("nexus-staging:rc-close"), //
profile("central"), //
arg("stagingRepositoryId").withValue(stagingRepository.getId()))
.andIf(!ObjectUtils.isEmpty(properties.getSettingsXml()), () -> settingsXml(properties.getSettingsXml()));
CommandLine arguments = CommandLine.of(goal("nexus-staging:rc-close"), //
profile("central"), //
arg("stagingRepositoryId").withValue(stagingRepository.getId()))
.andIf(!ObjectUtils.isEmpty(properties.getSettingsXml()), () -> settingsXml(properties.getSettingsXml()));
mvn.execute(train.getSupportedProject(BUILD), arguments);
}
mvn.execute(train.getSupportedProject(BUILD), arguments);
}
/*
@@ -353,8 +327,7 @@ class MavenBuildSystem implements BuildSystem {
arg("gpg.keyname").withValue(gpg.getKeyname()), //
arg("gpg.passphrase").withValue(gpg.getPassphrase())) //
.andIf(!ObjectUtils.isEmpty(properties.getSettingsXml()), settingsXml(properties.getSettingsXml()))
.andIf(StringUtils.hasText(information.getProject()),
() -> arg("artifactory.project").withValue(information.getProject()));
.andIf(StringUtils.hasText(information.getProject()), () -> arg("artifactory.project").withValue(information.getProject()));
mvn.execute(module.getSupportedProject(), arguments);
}
@@ -380,7 +353,6 @@ class MavenBuildSystem implements BuildSystem {
Gpg gpg = getGpg();
StagingRepository stagingRepository = deploymentInformation.getStagingRepositoryId();
CommandLine arguments = CommandLine.of(Goal.CLEAN, Goal.DEPLOY, //
profile("ci,release,central"), //
SKIP_TESTS, //
@@ -388,10 +360,8 @@ class MavenBuildSystem implements BuildSystem {
arg("gpg.keyname").withValue(gpg.getKeyname()), //
arg("gpg.passphrase").withValue(gpg.getPassphrase())) //
.andIf(!ObjectUtils.isEmpty(properties.getSettingsXml()), settingsXml(properties.getSettingsXml()))
.andIf(stagingRepository.isPresent() && stagingRepository.isRemote(),
() -> arg("stagingRepositoryId").withValue(stagingRepository.getId()))
.andIf(stagingRepository.isPresent() && stagingRepository.isFile(),
() -> arg("altDeploymentRepository").withValue("staging::default::file:" + stagingRepository.getId()))
.andIf(deploymentInformation.getStagingRepositoryId().isPresent(),
() -> arg("stagingRepositoryId").withValue(deploymentInformation.getStagingRepositoryId()))
.andIf(gpg.hasSecretKeyring(), () -> arg("gpg.secretKeyring").withValue(gpg.getSecretKeyring()));
mvn.execute(module.getSupportedProject(), arguments);
@@ -415,17 +385,16 @@ class MavenBuildSystem implements BuildSystem {
doWithProjection(workspace.getFile(POM_XML, smokeTests), pom -> {
Version version = module.getVersion();
String targetBootVersion = version.getMajor() == 2 ? "2.7.8" : "3.2.2";
String targetBootVersion = version.getMajor() == 2 ? "2.7.8" : "3.0.2";
pom.setParentVersion(ArtifactVersion.of(Version.parse(targetBootVersion), true));
});
CommandLine arguments = CommandLine.of(Goal.CLEAN, VERIFY, //
profile(profile), //
settingsXml("settings.xml"), //
arg("s").withValue("settings.xml"), //
arg("spring-data-bom.version").withValue(iteration.getReleaseTrainNameAndVersion())) //
.andIf(mavenCentral && stagingRepository.isPresent() && stagingRepository.isRemote(),
arg("stagingRepository").withValue(stagingRepository.getId()));
.andIf(mavenCentral, arg("stagingRepository").withValue(stagingRepository.getId()));
mvn.execute(smokeTests, arguments);
@@ -441,84 +410,6 @@ class MavenBuildSystem implements BuildSystem {
Assert.notNull(stagingRepository, "StagingRepository must not be null");
Assert.isTrue(stagingRepository.isPresent(), "StagingRepository must be present");
MavenCentral.Publishing process = deploymentProperties.getMavenCentral().getProcess();
if (process == MavenCentral.Publishing.OSSRH && stagingRepository.isRemote()) {
releaseRemoteRepository(train, stagingRepository);
return;
}
if (process == MavenCentral.Publishing.PUBLISHER && stagingRepository.isFile()) {
publishRelease(stagingRepository);
return;
}
throw new UnsupportedOperationException(
String.format("Cannot release train using %s and staging repository %s", process, stagingRepository));
}
private void publishRelease(StagingRepository stagingRepository) {
File root = new File(mavenProperties.getLocalStaging(), stagingRepository.getId());
Assert.isTrue(root.exists(), "StagingRepository " + root + " does not exist");
try {
File releaseBundle = createReleaseBundle(root);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private File createReleaseBundle(File root) throws IOException {
String deploymentIdentifier = root.getName();
String deploymentBundle = deploymentIdentifier + ".zip";
File zip = new File(root, deploymentBundle);
File[] files = root.listFiles();
Assert.notEmpty(files, "StagingRepository " + root + " is empty");
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zip))) {
// consider only directories on the root level.
for (File file : files) {
if (file.isDirectory()) {
zipRecursively("", file, zos);
}
}
}
return zip;
}
private void zipRecursively(String prefix, File file, ZipOutputStream zos) throws IOException {
String prefixToUse = (StringUtils.hasText(prefix) ? prefix + "/" : "");
if (file.isDirectory()) {
File[] files = file
.listFiles((dir, name) -> !name.startsWith(".") && !name.startsWith("_") && !name.endsWith(".lastUpdated"));
if (!ObjectUtils.isEmpty(files)) {
for (File nested : files) {
zipRecursively(prefixToUse + file.getName(), nested, zos);
}
}
return;
}
ZipEntry entry = new ZipEntry(prefixToUse + file.getName());
zos.putNextEntry(entry);
FileInputStream in = new FileInputStream(file);
IOUtils.copy(in, zos);
IOUtils.closeQuietly(in);
}
private void releaseRemoteRepository(Train train, StagingRepository stagingRepository) {
CommandLine arguments = CommandLine.of(goal("nexus-staging:rc-release"), //
profile("central"), //
arg("stagingRepositoryId").withValue(stagingRepository.getId()))
@@ -693,9 +584,9 @@ class MavenBuildSystem implements BuildSystem {
@Override
public void verifyStagingAuthentication(Train train) {
if (train.isOpenSource() && properties.getMavenCentral().getProcess() == MavenCentral.Publishing.OSSRH) {
if (train.isOpenSource()) {
logger.log(BUILD, "Verifying Maven OSSRH Staging Authentication…");
logger.log(BUILD, "Verifying Maven Staging Authentication…");
mvn.execute(train.getSupportedProject(BUILD), //
CommandLine.of(goal("nexus-staging:rc-list-profiles"), //
@@ -705,6 +596,7 @@ class MavenBuildSystem implements BuildSystem {
"Maven Central properties are not set (deployment.maven-central.staging-profile-id=…)");
Assert.hasText(properties.getMavenCentral().getStagingProfileId(),
"Staging Profile Id is not set (deployment.maven-central.staging-profile-id=…)");
return;
}
}

View File

@@ -41,7 +41,6 @@ public class MavenProperties {
private File mavenHome;
private File localRepository;
private File localStaging;
private Map<String, String> plugins;
private boolean consoleLogger = true;
private boolean parallelize = false;
@@ -74,19 +73,6 @@ public class MavenProperties {
}
}
public void setLocalStaging(String localStaging) {
Assert.hasText(localStaging, "Local staging must not be null!");
log.info("Using {} as local Maven local staging!", localStaging);
this.localStaging = new File(localStaging.replace("~", FileUtils.getUserDirectoryPath()));
if (!this.localStaging.exists()) {
this.localStaging.mkdirs();
}
}
/**
* Returns the fully-qualified plugin goal for the given local one.
*

View File

@@ -27,7 +27,6 @@ import java.util.Set;
import org.springframework.data.release.CliComponent;
import org.springframework.data.release.TimedCommand;
import org.springframework.data.release.build.BuildOperations;
import org.springframework.data.release.build.BuildSystem;
import org.springframework.data.release.deployment.DeploymentInformation;
import org.springframework.data.release.deployment.DeploymentOperations;
import org.springframework.data.release.deployment.StagingRepository;
@@ -59,8 +58,6 @@ class ReleaseCommands extends TimedCommand {
@NonNull BuildOperations build;
@NonNull IssueTrackerCommands tracker;
@NonNull GitHubCommands gitHub;
@NonNull
BuildSystem bs;
/**
* Composite command to prepare a release.

View File

@@ -101,8 +101,6 @@ public class DeploymentProperties implements InitializingBean {
private String stagingProfileId;
private Publishing process;
private Gpg gpg;
public boolean hasGpgConfiguration() {
@@ -115,10 +113,6 @@ public class DeploymentProperties implements InitializingBean {
throw new IllegalArgumentException("No staging profile Id for Maven Central");
}
}
public enum Publishing {
OSSRH, PUBLISHER
}
}
@Data

View File

@@ -24,21 +24,12 @@ import org.springframework.util.ObjectUtils;
*
* @author Mark Paluch
*/
@Value
@Value(staticConstructor = "of")
public class StagingRepository {
public static final StagingRepository EMPTY = new StagingRepository("", false);
public static final StagingRepository EMPTY = StagingRepository.of("");
String id;
boolean file;
public static StagingRepository of(String id) {
return new StagingRepository(id, false);
}
public static StagingRepository ofFile(String id) {
return new StagingRepository(id, true);
}
public boolean isEmpty() {
return ObjectUtils.isEmpty(id);
@@ -48,15 +39,10 @@ public class StagingRepository {
return !isEmpty();
}
public boolean isRemote() {
return !isEmpty() && !isFile();
}
@Override
public String toString() {
if (isPresent()) {
return (isFile() ? "file:" : "remote:") + id;
return id;
}
return "(empty)";

View File

@@ -4,7 +4,6 @@ io.logs=logs
# Maven setup
maven.local-repository=~/temp/spring-data-shell/repository
maven.local-staging=~/temp/spring-data-shell/staging
maven.plugins.versions=org.codehaus.mojo:versions-maven-plugin:2.16.2
maven.console-logger=true