From 24f92e66d3f5597c425b92ed444de8a2950539eb Mon Sep 17 00:00:00 2001 From: Andres Almiray Date: Tue, 21 Jan 2025 17:02:56 +0100 Subject: [PATCH] Add operations matching all CLI commands --- ...ctJReleaserDistributionModelOperation.java | 48 ++++ .../AbstractJReleaserModelOperation.java | 92 +++++++ .../extension/AbstractJReleaserOperation.java | 241 ++++++++++++++++++ ...stractJReleaserPackagerModelOperation.java | 48 ++++ ...tJReleaserPlatformAwareModelOperation.java | 58 +++++ .../extension/JReleaserAnnounceOperation.java | 48 ++++ .../extension/JReleaserAssembleOperation.java | 48 ++++ .../extension/JReleaserCatalogOperation.java | 92 +++++++ .../JReleaserChangelogOperation.java | 36 +++ .../extension/JReleaserChecksumOperation.java | 26 ++ .../extension/JReleaserConfigOperation.java | 76 ++++++ .../extension/JReleaserDeployOperation.java | 70 +++++ .../extension/JReleaserDownloadOperation.java | 70 +++++ .../bld/extension/JReleaserEnvOperation.java | 26 ++ .../JReleaserFullReleaseOperation.java | 158 ++++++++++++ .../bld/extension/JReleaserInitOperation.java | 202 +-------------- .../JReleaserJsonSchemaOperation.java | 26 ++ .../extension/JReleaserPackageOperation.java | 36 +++ .../extension/JReleaserPrepareOperation.java | 26 ++ .../extension/JReleaserPublishOperation.java | 36 +++ .../extension/JReleaserReleaseOperation.java | 136 ++++++++++ .../bld/extension/JReleaserSignOperation.java | 26 ++ .../JReleaserTemplateEvalOperation.java | 172 +++++++++++++ .../JReleaserTemplateGenerateOperation.java | 124 +++++++++ .../extension/JReleaserUploadOperation.java | 92 +++++++ 25 files changed, 1816 insertions(+), 197 deletions(-) create mode 100644 src/main/java/rife/bld/extension/AbstractJReleaserDistributionModelOperation.java create mode 100644 src/main/java/rife/bld/extension/AbstractJReleaserModelOperation.java create mode 100644 src/main/java/rife/bld/extension/AbstractJReleaserOperation.java create mode 100644 src/main/java/rife/bld/extension/AbstractJReleaserPackagerModelOperation.java create mode 100644 src/main/java/rife/bld/extension/AbstractJReleaserPlatformAwareModelOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserAnnounceOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserAssembleOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserCatalogOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserChangelogOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserChecksumOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserConfigOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserDeployOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserDownloadOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserEnvOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserFullReleaseOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserJsonSchemaOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserPackageOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserPrepareOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserPublishOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserReleaseOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserSignOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserTemplateEvalOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserTemplateGenerateOperation.java create mode 100644 src/main/java/rife/bld/extension/JReleaserUploadOperation.java diff --git a/src/main/java/rife/bld/extension/AbstractJReleaserDistributionModelOperation.java b/src/main/java/rife/bld/extension/AbstractJReleaserDistributionModelOperation.java new file mode 100644 index 0000000..ba2649c --- /dev/null +++ b/src/main/java/rife/bld/extension/AbstractJReleaserDistributionModelOperation.java @@ -0,0 +1,48 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Base class for JReleaser operations that rely on distributions. + */ +public class AbstractJReleaserDistributionModelOperation> extends AbstractJReleaserPlatformAwareModelOperation { + public AbstractJReleaserDistributionModelOperation(String command) { + super(command); + } + + /** + * Includes the given distribution. + * + * @param distribution the distribution name + * @return this operation instance + */ + public S distribution(String distribution) { + setOption("--distribution", distribution); + return self(); + } + + /** + * Excludes the given distribution. + * + * @param distribution the distribution name + * @return this operation instance + */ + public S excludeDistribution(String distribution) { + setOption("--exclude-distribution", distribution); + return self(); + } +} diff --git a/src/main/java/rife/bld/extension/AbstractJReleaserModelOperation.java b/src/main/java/rife/bld/extension/AbstractJReleaserModelOperation.java new file mode 100644 index 0000000..df8b35c --- /dev/null +++ b/src/main/java/rife/bld/extension/AbstractJReleaserModelOperation.java @@ -0,0 +1,92 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +import java.io.File; +import java.nio.file.Path; + +/** + * Base class for JReleaser operations that resolve a model. + */ +public class AbstractJReleaserModelOperation> extends AbstractJReleaserOperation { + public AbstractJReleaserModelOperation(String command) { + super(command); + } + + /** + * Input configFile. + * + * @param configFile the input configFile + * @return this operation instance + */ + public S configFile(String configFile) { + setOption("--config-file", configFile); + return self(); + } + + /** + * Input configFile. + * + * @param configFile the input configFile + * @return this operation instance + */ + public S configFile(File configFile) { + return configFile(configFile.getAbsolutePath()); + } + + /** + * Input configFile. + * + * @param configFile the input configFile + * @return this operation instance + */ + public S configFile(Path configFile) { + return configFile(configFile.toFile()); + } + + /** + * Searches for a .git directory at the project's root directory. + * + * @return this operation instance + */ + public S gitRootSearch() { + setOption("--git-root-search", EMPTY); + return self(); + } + + /** + * Sets strict mode. + * + * @return this operation instance + */ + public S strict() { + setOption("--strict", EMPTY); + return self(); + } + + /** + * Sets a project property. + * + * @param key the property key + * @param value the property value + * @return this operation instance + */ + public S projectProperty(String key, String value) { + setOption("-P", key + '=' + value); + return self(); + } +} diff --git a/src/main/java/rife/bld/extension/AbstractJReleaserOperation.java b/src/main/java/rife/bld/extension/AbstractJReleaserOperation.java new file mode 100644 index 0000000..d26af8e --- /dev/null +++ b/src/main/java/rife/bld/extension/AbstractJReleaserOperation.java @@ -0,0 +1,241 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +import rife.bld.BaseProject; +import rife.bld.operations.AbstractProcessOperation; +import rife.bld.operations.exceptions.ExitStatusException; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.logging.Level; +import java.util.logging.Logger; + + +/** + * Base class for all JReleaser operations. + */ +public abstract class AbstractJReleaserOperation> extends AbstractProcessOperation { + private static final Logger LOGGER = Logger.getLogger(AbstractJReleaserOperation.class.getName()); + protected static final String EMPTY = ""; + + private final Map options_ = new ConcurrentHashMap<>(); + private final String command_; + + private BaseProject project_; + + protected AbstractJReleaserOperation(String command) { + command_ = command; + } + + protected final S self() { + return (S) this; + } + + protected String getCommand() { + return command_; + } + + protected BaseProject getProject() { + return project_; + } + + protected void setOption(String key, String value) { + options_.put(key, value); + } + + /** + * Sets the base directory. + * + * @param directory the base directory + * @return this operation instance + */ + public S basedir(String directory) { + setOption("--basedir", directory); + return self(); + } + + /** + * Sets the base directory. + * + * @param directory the base directory + * @return this operation instance + */ + public S basedir(File directory) { + return basedir(directory.getAbsolutePath()); + } + + /** + * Sets the base directory. + * + * @param directory the base directory + * @return this operation instance + */ + public S basedir(Path directory) { + return basedir(directory.toFile()); + } + + /** + * Set log level to debug. + * + * @return this operation instance + */ + public S debug() { + setOption("--debug", EMPTY); + return self(); + } + + @Override + public void execute() throws IOException, InterruptedException, ExitStatusException { + if (project_ == null) { + if (LOGGER.isLoggable(Level.SEVERE) && !silent()) { + LOGGER.severe("A project must be specified."); + } + throw new ExitStatusException(ExitStatusException.EXIT_FAILURE); + } else { + super.execute(); + } + } + + /** + * Part of the {@link #execute} operation, constructs the command list + * to use for building the process. + */ + @Override + protected List executeConstructProcessCommandList() { + List args = new ArrayList<>(); + + if (project_ != null) { + args.add(javaTool()); + args.add("-cp"); + args.add(String.format("%s:%s:%s:%s", new File(project_.libTestDirectory(), "*"), + new File(project_.libCompileDirectory(), "*"), project_.buildMainDirectory(), + project_.buildTestDirectory())); + args.add("org.jreleaser.cli.Main"); + args.add(getCommand()); + + options_.forEach((k, v) -> { + if (!v.isEmpty()) { + args.add(k + '=' + v); + } else { + args.add(k); + } + }); + } + + return args; + } + + /** + * Configures the operation from a {@link BaseProject}. + * + * @param project the project to configure the operation from + */ + @Override + public S fromProject(BaseProject project) { + project_ = project; + return self(); + } + + /** + * Show the help message. + * + * @return this operation instance + */ + public S help() { + setOption("--help", EMPTY); + return self(); + } + + /** + * Set log level to info. + * + * @return this operation instance + */ + public S info() { + setOption("--info", EMPTY); + return self(); + } + + /** + * Output directory. + * + * @param directory the output directory + * @return this operation instance + */ + public S outputDirectory(String directory) { + setOption("--output-directory", directory); + return self(); + } + + /** + * Output directory. + * + * @param directory the output directory + * @return this operation instance + */ + public S outputDirectory(File directory) { + return outputDirectory(directory.getAbsolutePath()); + } + + /** + * Output directory. + * + * @param directory the output directory + * @return this operation instance + */ + public S outputDirectory(Path directory) { + return outputDirectory(directory.toFile()); + } + + /** + * Sets a System property. + * + * @param key the property key + * @param value the property value + * @return this operation instance + */ + public S systemProperty(String key, String value) { + setOption("-D", key + '=' + value); + return self(); + } + + /** + * Print version information. + * + * @return this operation instance + */ + public S version() { + setOption("--version", EMPTY); + return self(); + } + + /** + * Set log level to warn. + * + * @return this operation instance + */ + public S warn() { + setOption("--warn", EMPTY); + return self(); + } +} diff --git a/src/main/java/rife/bld/extension/AbstractJReleaserPackagerModelOperation.java b/src/main/java/rife/bld/extension/AbstractJReleaserPackagerModelOperation.java new file mode 100644 index 0000000..dad9776 --- /dev/null +++ b/src/main/java/rife/bld/extension/AbstractJReleaserPackagerModelOperation.java @@ -0,0 +1,48 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Base class for JReleaser operations that rely on packagers. + */ +public class AbstractJReleaserPackagerModelOperation> extends AbstractJReleaserDistributionModelOperation { + public AbstractJReleaserPackagerModelOperation(String command) { + super(command); + } + + /** + * Includes the given packager. + * + * @param packager the packager name + * @return this operation instance + */ + public S packager(String packager) { + setOption("--packager", packager); + return self(); + } + + /** + * Excludes the given packager. + * + * @param packager the packager name + * @return this operation instance + */ + public S excludePackager(String packager) { + setOption("--exclude-packager", packager); + return self(); + } +} diff --git a/src/main/java/rife/bld/extension/AbstractJReleaserPlatformAwareModelOperation.java b/src/main/java/rife/bld/extension/AbstractJReleaserPlatformAwareModelOperation.java new file mode 100644 index 0000000..c9a89ce --- /dev/null +++ b/src/main/java/rife/bld/extension/AbstractJReleaserPlatformAwareModelOperation.java @@ -0,0 +1,58 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Base class for JReleaser operations that are platform aware. + */ +public class AbstractJReleaserPlatformAwareModelOperation> extends AbstractJReleaserModelOperation { + public AbstractJReleaserPlatformAwareModelOperation(String command) { + super(command); + } + + /** + * Limits artifact selection to the current platform. + * + * @return this operation instance + */ + public S selectCurrentPlatform() { + setOption("--select-current-platform", EMPTY); + return self(); + } + + /** + * Limits artifact selection to the given platform. + * + * @param platform the platform value + * @return this operation instance + */ + public S selectPlatform(String platform) { + setOption("--select-platform", platform); + return self(); + } + + /** + * Excludes artifact selection from the given platform. + * + * @param platform the platform value + * @return this operation instance + */ + public S rejectPlatform(String platform) { + setOption("--reject-platform", platform); + return self(); + } +} diff --git a/src/main/java/rife/bld/extension/JReleaserAnnounceOperation.java b/src/main/java/rife/bld/extension/JReleaserAnnounceOperation.java new file mode 100644 index 0000000..371ea7a --- /dev/null +++ b/src/main/java/rife/bld/extension/JReleaserAnnounceOperation.java @@ -0,0 +1,48 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Announce a release. + */ +public class JReleaserAnnounceOperation extends AbstractJReleaserModelOperation { + public JReleaserAnnounceOperation() { + super("announce"); + } + + /** + * Includes the given announcer. + * + * @param announcer the announcer name + * @return this operation instance + */ + public JReleaserAnnounceOperation announcer(String announcer) { + setOption("--announcer", announcer); + return this; + } + + /** + * Excludes the given announcer. + * + * @param announcer the announcer name + * @return this operation instance + */ + public JReleaserAnnounceOperation excludeAnnouncer(String announcer) { + setOption("--exclude-announcer", announcer); + return this; + } +} diff --git a/src/main/java/rife/bld/extension/JReleaserAssembleOperation.java b/src/main/java/rife/bld/extension/JReleaserAssembleOperation.java new file mode 100644 index 0000000..3c92070 --- /dev/null +++ b/src/main/java/rife/bld/extension/JReleaserAssembleOperation.java @@ -0,0 +1,48 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Assemble distributions. + */ +public class JReleaserAssembleOperation extends AbstractJReleaserDistributionModelOperation { + public JReleaserAssembleOperation() { + super("assemble"); + } + + /** + * Includes the given assembler. + * + * @param assembler the assembler name + * @return this operation instance + */ + public JReleaserAssembleOperation assembler(String assembler) { + setOption("--assembler", assembler); + return this; + } + + /** + * Excludes the given assembler. + * + * @param assembler the assembler name + * @return this operation instance + */ + public JReleaserAssembleOperation excludeAssembler(String assembler) { + setOption("--exclude-assembler", assembler); + return this; + } +} diff --git a/src/main/java/rife/bld/extension/JReleaserCatalogOperation.java b/src/main/java/rife/bld/extension/JReleaserCatalogOperation.java new file mode 100644 index 0000000..c13eef3 --- /dev/null +++ b/src/main/java/rife/bld/extension/JReleaserCatalogOperation.java @@ -0,0 +1,92 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Catalog release assets. + */ +public class JReleaserCatalogOperation extends AbstractJReleaserDistributionModelOperation { + public JReleaserCatalogOperation() { + super("catalog"); + } + + /** + * Includes the given cataloger. + * + * @param cataloger the cataloger name + * @return this operation instance + */ + public JReleaserCatalogOperation cataloger(String cataloger) { + setOption("--cataloger", cataloger); + return this; + } + + /** + * Excludes the given cataloger. + * + * @param cataloger the cataloger name + * @return this operation instance + */ + public JReleaserCatalogOperation excludeCataloger(String cataloger) { + setOption("--exclude-cataloger", cataloger); + return this; + } + + /** + * Includes the given deployer by type. + * + * @param deployer the deployer type + * @return this operation instance + */ + public JReleaserCatalogOperation deployerByType(String deployer) { + setOption("--deployer", deployer); + return this; + } + + /** + * Excludes the given deployer by type. + * + * @param deployer the deployer type + * @return this operation instance + */ + public JReleaserCatalogOperation excludeDeployerByType(String deployer) { + setOption("--exclude-deployer", deployer); + return this; + } + + /** + * Includes the given deployer by name. + * + * @param name the deployer name + * @return this operation instance + */ + public JReleaserCatalogOperation deployerByName(String name) { + setOption("--deployer-name", name); + return this; + } + + /** + * Excludes the given deployer by name. + * + * @param name the deployer name + * @return this operation instance + */ + public JReleaserCatalogOperation excludeDeployerByName(String name) { + setOption("--exclude-deployer-name", name); + return this; + } +} diff --git a/src/main/java/rife/bld/extension/JReleaserChangelogOperation.java b/src/main/java/rife/bld/extension/JReleaserChangelogOperation.java new file mode 100644 index 0000000..b4eba03 --- /dev/null +++ b/src/main/java/rife/bld/extension/JReleaserChangelogOperation.java @@ -0,0 +1,36 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Generates a changelog. + */ +public class JReleaserChangelogOperation extends AbstractJReleaserModelOperation { + public JReleaserChangelogOperation() { + super("changelog"); + } + + /** + * Enables dry-run mode. + * + * @return this operation instance + */ + public JReleaserChangelogOperation dryRun() { + setOption("--dry-run", EMPTY); + return this; + } +} diff --git a/src/main/java/rife/bld/extension/JReleaserChecksumOperation.java b/src/main/java/rife/bld/extension/JReleaserChecksumOperation.java new file mode 100644 index 0000000..988374d --- /dev/null +++ b/src/main/java/rife/bld/extension/JReleaserChecksumOperation.java @@ -0,0 +1,26 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Calculate checksum files. + */ +public class JReleaserChecksumOperation extends AbstractJReleaserDistributionModelOperation { + public JReleaserChecksumOperation() { + super("checksum"); + } +} diff --git a/src/main/java/rife/bld/extension/JReleaserConfigOperation.java b/src/main/java/rife/bld/extension/JReleaserConfigOperation.java new file mode 100644 index 0000000..ea52ca5 --- /dev/null +++ b/src/main/java/rife/bld/extension/JReleaserConfigOperation.java @@ -0,0 +1,76 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Create a JReleaser config file. + */ +public class JReleaserConfigOperation extends AbstractJReleaserPlatformAwareModelOperation { + public JReleaserConfigOperation() { + super("config"); + } + + /** + * Display full configuration. + * + * @return this operation instance + */ + public JReleaserConfigOperation full() { + setOption("--full", EMPTY); + return this; + } + + /** + * Display announce configuration. + * + * @return this operation instance + */ + public JReleaserConfigOperation announce() { + setOption("--announce", EMPTY); + return this; + } + + /** + * Display assembly configuration. + * + * @return this operation instance + */ + public JReleaserConfigOperation assembly() { + setOption("--assembly", EMPTY); + return this; + } + + /** + * Display changelog configuration. + * + * @return this operation instance + */ + public JReleaserConfigOperation changelog() { + setOption("--changelog", EMPTY); + return this; + } + + /** + * Display download configuration. + * + * @return this operation instance + */ + public JReleaserConfigOperation download() { + setOption("--download", EMPTY); + return this; + } +} diff --git a/src/main/java/rife/bld/extension/JReleaserDeployOperation.java b/src/main/java/rife/bld/extension/JReleaserDeployOperation.java new file mode 100644 index 0000000..ef52496 --- /dev/null +++ b/src/main/java/rife/bld/extension/JReleaserDeployOperation.java @@ -0,0 +1,70 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Deploy assets. + */ +public class JReleaserDeployOperation extends AbstractJReleaserModelOperation { + public JReleaserDeployOperation() { + super("deploy"); + } + + /** + * Includes the given deployer by type. + * + * @param deployer the deployer type + * @return this operation instance + */ + public JReleaserDeployOperation deployerByType(String deployer) { + setOption("--deployer", deployer); + return this; + } + + /** + * Excludes the given deployer by type. + * + * @param deployer the deployer type + * @return this operation instance + */ + public JReleaserDeployOperation excludeDeployerByType(String deployer) { + setOption("--exclude-deployer", deployer); + return this; + } + + /** + * Includes the given deployer by name. + * + * @param name the deployer name + * @return this operation instance + */ + public JReleaserDeployOperation deployerByName(String name) { + setOption("--deployer-name", name); + return this; + } + + /** + * Excludes the given deployer by name. + * + * @param name the deployer name + * @return this operation instance + */ + public JReleaserDeployOperation excludeDeployerByName(String name) { + setOption("--exclude-deployer-name", name); + return this; + } +} diff --git a/src/main/java/rife/bld/extension/JReleaserDownloadOperation.java b/src/main/java/rife/bld/extension/JReleaserDownloadOperation.java new file mode 100644 index 0000000..a2239d9 --- /dev/null +++ b/src/main/java/rife/bld/extension/JReleaserDownloadOperation.java @@ -0,0 +1,70 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Download assets. + */ +public class JReleaserDownloadOperation extends AbstractJReleaserModelOperation { + public JReleaserDownloadOperation() { + super("download"); + } + + /** + * Includes the given downloader by type. + * + * @param downloader the downloader type + * @return this operation instance + */ + public JReleaserDownloadOperation downloaderByType(String downloader) { + setOption("--downloader", downloader); + return this; + } + + /** + * Excludes the given downloader by type. + * + * @param downloader the downloader type + * @return this operation instance + */ + public JReleaserDownloadOperation excludeDownloaderByType(String downloader) { + setOption("--exclude-downloader", downloader); + return this; + } + + /** + * Includes the given downloader by name. + * + * @param name the downloader name + * @return this operation instance + */ + public JReleaserDownloadOperation downloaderByName(String name) { + setOption("--downloader-name", name); + return this; + } + + /** + * Excludes the given downloader by name. + * + * @param name the downloader name + * @return this operation instance + */ + public JReleaserDownloadOperation excludeDownloaderByName(String name) { + setOption("--exclude-downloader-name", name); + return this; + } +} diff --git a/src/main/java/rife/bld/extension/JReleaserEnvOperation.java b/src/main/java/rife/bld/extension/JReleaserEnvOperation.java new file mode 100644 index 0000000..b86abbe --- /dev/null +++ b/src/main/java/rife/bld/extension/JReleaserEnvOperation.java @@ -0,0 +1,26 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Displays environment settings. + */ +public class JReleaserEnvOperation extends AbstractJReleaserOperation { + public JReleaserEnvOperation() { + super("env"); + } +} diff --git a/src/main/java/rife/bld/extension/JReleaserFullReleaseOperation.java b/src/main/java/rife/bld/extension/JReleaserFullReleaseOperation.java new file mode 100644 index 0000000..21aafd4 --- /dev/null +++ b/src/main/java/rife/bld/extension/JReleaserFullReleaseOperation.java @@ -0,0 +1,158 @@ +/* + * Copyright 2025 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 + * + * https://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 rife.bld.extension; + +/** + * Perform a full release. + */ +public class JReleaserFullReleaseOperation extends AbstractJReleaserDistributionModelOperation { + public JReleaserFullReleaseOperation() { + super("full-release"); + } + + /** + * Includes the given uploader by type. + * + * @param uploader the uploader type + * @return this operation instance + */ + public JReleaserFullReleaseOperation uploaderByType(String uploader) { + setOption("--uploader", uploader); + return this; + } + + /** + * Excludes the given uploader by type. + * + * @param uploader the uploader type + * @return this operation instance + */ + public JReleaserFullReleaseOperation excludeUploaderByType(String uploader) { + setOption("--exclude-uploader", uploader); + return this; + } + + /** + * Includes the given uploader by name. + * + * @param name the uploader name + * @return this operation instance + */ + public JReleaserFullReleaseOperation uploaderByName(String name) { + setOption("--uploader-name", name); + return this; + } + + /** + * Excludes the given uploader by name. + * + * @param name the uploader name + * @return this operation instance + */ + public JReleaserFullReleaseOperation excludeUploaderByName(String name) { + setOption("--exclude-uploader-name", name); + return this; + } + + /** + * Includes the given cataloger. + * + * @param cataloger the cataloger name + * @return this operation instance + */ + public JReleaserFullReleaseOperation cataloger(String cataloger) { + setOption("--cataloger", cataloger); + return this; + } + + /** + * Excludes the given cataloger. + * + * @param cataloger the cataloger name + * @return this operation instance + */ + public JReleaserFullReleaseOperation excludeCataloger(String cataloger) { + setOption("--exclude-cataloger", cataloger); + return this; + } + + /** + * Includes the given deployer by type. + * + * @param deployer the deployer type + * @return this operation instance + */ + public JReleaserFullReleaseOperation deployerByType(String deployer) { + setOption("--deployer", deployer); + return this; + } + + /** + * Excludes the given deployer by type. + * + * @param deployer the deployer type + * @return this operation instance + */ + public JReleaserFullReleaseOperation excludeDeployerByType(String deployer) { + setOption("--exclude-deployer", deployer); + return this; + } + + /** + * Includes the given deployer by name. + * + * @param name the deployer name + * @return this operation instance + */ + public JReleaserFullReleaseOperation deployerByName(String name) { + setOption("--deployer-name", name); + return this; + } + + /** + * Excludes the given deployer by name. + * + * @param name the deployer name + * @return this operation instance + */ + public JReleaserFullReleaseOperation excludeDeployerByName(String name) { + setOption("--exclude-deployer-name", name); + return this; + } + + /** + * Includes the given announcer. + * + * @param announcer the announcer name + * @return this operation instance + */ + public JReleaserFullReleaseOperation announcer(String announcer) { + setOption("--announcer", announcer); + return this; + } + + /** + * Excludes the given announcer. + * + * @param announcer the announcer name + * @return this operation instance + */ + public JReleaserFullReleaseOperation excludeAnnouncer(String announcer) { + setOption("--exclude-announcer", announcer); + return this; + } +} diff --git a/src/main/java/rife/bld/extension/JReleaserInitOperation.java b/src/main/java/rife/bld/extension/JReleaserInitOperation.java index 5387162..b002ad4 100644 --- a/src/main/java/rife/bld/extension/JReleaserInitOperation.java +++ b/src/main/java/rife/bld/extension/JReleaserInitOperation.java @@ -16,121 +16,12 @@ package rife.bld.extension; -import rife.bld.BaseProject; -import rife.bld.operations.AbstractProcessOperation; -import rife.bld.operations.exceptions.ExitStatusException; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Level; -import java.util.logging.Logger; - - /** * Create a JReleaser config file. */ -public class JReleaserInitOperation extends AbstractProcessOperation { - private static final String EMPTY = ""; - private static final Logger LOGGER = Logger.getLogger(JReleaserInitOperation.class.getName()); - private final Map options_ = new ConcurrentHashMap<>(); - private BaseProject project_; - - /** - * Sets the base directory. - * - * @param directory the base directory - * @return this operation instance - */ - public JReleaserInitOperation basedir(String directory) { - options_.put("--basedir", directory); - return this; - } - - /** - * Sets the base directory. - * - * @param directory the base directory - * @return this operation instance - */ - public JReleaserInitOperation basedir(File directory) { - return basedir(directory.getAbsolutePath()); - } - - /** - * Sets the base directory. - * - * @param directory the base directory - * @return this operation instance - */ - public JReleaserInitOperation basedir(Path directory) { - return basedir(directory.toFile()); - } - - /** - * Set log level to debug. - * - * @return this operation instance - */ - public JReleaserInitOperation debug() { - options_.put("--debug", EMPTY); - return this; - } - - @Override - public void execute() throws IOException, InterruptedException, ExitStatusException { - if (project_ == null) { - if (LOGGER.isLoggable(Level.SEVERE) && !silent()) { - LOGGER.severe("A project must be specified."); - } - throw new ExitStatusException(ExitStatusException.EXIT_FAILURE); - } else { - super.execute(); - } - } - - /** - * Part of the {@link #execute} operation, constructs the command list - * to use for building the process. - */ - @Override - protected List executeConstructProcessCommandList() { - List args = new ArrayList<>(); - - if (project_ != null) { - args.add(javaTool()); - args.add("-cp"); - args.add(String.format("%s:%s:%s:%s", new File(project_.libTestDirectory(), "*"), - new File(project_.libCompileDirectory(), "*"), project_.buildMainDirectory(), - project_.buildTestDirectory())); - args.add("org.jreleaser.cli.Main"); - args.add("init"); - - options_.forEach((k, v) -> { - if (!v.isEmpty()) { - args.add(k + '=' + v); - } else { - args.add(k); - } - }); - } - - return args; - } - - /** - * Configures the operation from a {@link BaseProject}. - * - * @param project the project to configure the operation from - */ - @Override - public JReleaserInitOperation fromProject(BaseProject project) { - project_ = project; - return this; +public class JReleaserInitOperation extends AbstractJReleaserOperation { + public JReleaserInitOperation() { + super("init"); } /** @@ -140,100 +31,17 @@ public class JReleaserInitOperation extends AbstractProcessOperation