Merge pull request #1 from jreleaser/main

Add operations matching all CLI commands
This commit is contained in:
Erik C. Thauvin 2025-01-21 08:37:44 -08:00 committed by GitHub
commit 082fd7d277
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 1816 additions and 197 deletions

View file

@ -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<S extends AbstractJReleaserDistributionModelOperation<S>> extends AbstractJReleaserPlatformAwareModelOperation<S> {
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();
}
}

View file

@ -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<S extends AbstractJReleaserModelOperation<S>> extends AbstractJReleaserOperation<S> {
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();
}
}

View file

@ -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<S extends AbstractJReleaserOperation<S>> extends AbstractProcessOperation<S> {
private static final Logger LOGGER = Logger.getLogger(AbstractJReleaserOperation.class.getName());
protected static final String EMPTY = "";
private final Map<String, String> 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<String> executeConstructProcessCommandList() {
List<String> 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();
}
}

View file

@ -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<S extends AbstractJReleaserPackagerModelOperation<S>> extends AbstractJReleaserDistributionModelOperation<S> {
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();
}
}

View file

@ -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<S extends AbstractJReleaserPlatformAwareModelOperation<S>> extends AbstractJReleaserModelOperation<S> {
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();
}
}

View file

@ -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<JReleaserAnnounceOperation> {
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;
}
}

View file

@ -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<JReleaserAssembleOperation> {
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;
}
}

View file

@ -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<JReleaserCatalogOperation> {
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;
}
}

View file

@ -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<JReleaserChangelogOperation> {
public JReleaserChangelogOperation() {
super("changelog");
}
/**
* Enables dry-run mode.
*
* @return this operation instance
*/
public JReleaserChangelogOperation dryRun() {
setOption("--dry-run", EMPTY);
return this;
}
}

View file

@ -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<JReleaserChecksumOperation> {
public JReleaserChecksumOperation() {
super("checksum");
}
}

View file

@ -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<JReleaserConfigOperation> {
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;
}
}

View file

@ -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<JReleaserDeployOperation> {
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;
}
}

View file

@ -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<JReleaserDownloadOperation> {
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;
}
}

View file

@ -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<JReleaserEnvOperation> {
public JReleaserEnvOperation() {
super("env");
}
}

View file

@ -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<JReleaserFullReleaseOperation> {
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;
}
}

View file

@ -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<JReleaserInitOperation> {
private static final String EMPTY = "";
private static final Logger LOGGER = Logger.getLogger(JReleaserInitOperation.class.getName());
private final Map<String, String> 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<String> executeConstructProcessCommandList() {
List<String> 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<JReleaserInitOperation> {
public JReleaserInitOperation() {
super("init");
}
/**
@ -140,100 +31,17 @@ public class JReleaserInitOperation extends AbstractProcessOperation<JReleaserIn
* @return this operation instance
*/
public JReleaserInitOperation format(Format format) {
options_.put("--format", format.getFormat());
setOption("--format", format.getFormat());
return this;
}
/**
* Show the help message.
*
* @return this operation instance
*/
public JReleaserInitOperation help() {
options_.put("--help", EMPTY);
return this;
}
/**
* Set log level to info.
*
* @return this operation instance
*/
public JReleaserInitOperation info() {
options_.put("--info", EMPTY);
return this;
}
/**
* Output directory.
*
* @param directory the output directory
* @return this operation instance
*/
public JReleaserInitOperation outputDirectory(String directory) {
options_.put("-output-directory", directory);
return this;
}
/**
* Output directory.
*
* @param directory the output directory
* @return this operation instance
*/
public JReleaserInitOperation outputDirectory(File directory) {
return outputDirectory(directory.getAbsolutePath());
}
/**
* Output directory.
*
* @param directory the output directory
* @return this operation instance
*/
public JReleaserInitOperation outputDirectory(Path directory) {
return outputDirectory(directory.toFile());
}
/**
* Overwrite existing files.
*
* @return this operation instance
*/
public JReleaserInitOperation overwrite() {
options_.put("--overwrite", EMPTY);
return this;
}
/**
* Sets a System property.
*
* @param key the property key
* @param value the property value
* @return this operation instance
*/
public JReleaserInitOperation systemProperty(String key, String value) {
options_.put("-D", key + '=' + value);
return this;
}
/**
* Print version information.
*
* @return this operation instance
*/
public JReleaserInitOperation version() {
options_.put("--version", EMPTY);
return this;
}
/**
* Set log level to warn.
*
* @return this operation instance
*/
public JReleaserInitOperation warn() {
options_.put("--warn", EMPTY);
setOption("--overwrite", EMPTY);
return this;
}

View file

@ -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;
/**
* Generates a JSON schema file.
*/
public class JReleaserJsonSchemaOperation extends AbstractJReleaserOperation<JReleaserJsonSchemaOperation> {
public JReleaserJsonSchemaOperation() {
super("json-schema");
}
}

View file

@ -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;
/**
* Calculate checksum files.
*/
public class JReleaserPackageOperation extends AbstractJReleaserPackagerModelOperation<JReleaserPackageOperation> {
public JReleaserPackageOperation() {
super("package");
}
/**
* Enables dry-run mode.
*
* @return this operation instance
*/
public JReleaserPackageOperation dryRun() {
setOption("--dry-run", EMPTY);
return this;
}
}

View file

@ -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 JReleaserPrepareOperation extends AbstractJReleaserPackagerModelOperation<JReleaserPrepareOperation> {
public JReleaserPrepareOperation() {
super("prepare");
}
}

View file

@ -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;
/**
* Calculate checksum files.
*/
public class JReleaserPublishOperation extends AbstractJReleaserPackagerModelOperation<JReleaserPublishOperation> {
public JReleaserPublishOperation() {
super("publish");
}
/**
* Enables dry-run mode.
*
* @return this operation instance
*/
public JReleaserPublishOperation dryRun() {
setOption("--dry-run", EMPTY);
return this;
}
}

View file

@ -0,0 +1,136 @@
/*
* 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 release.
*/
public class JReleaserReleaseOperation extends AbstractJReleaserDistributionModelOperation<JReleaserReleaseOperation> {
public JReleaserReleaseOperation() {
super("release");
}
/**
* Includes the given uploader by type.
*
* @param uploader the uploader type
* @return this operation instance
*/
public JReleaserReleaseOperation uploaderByType(String uploader) {
setOption("--uploader", uploader);
return this;
}
/**
* Excludes the given uploader by type.
*
* @param uploader the uploader type
* @return this operation instance
*/
public JReleaserReleaseOperation 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 JReleaserReleaseOperation 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 JReleaserReleaseOperation excludeUploaderByName(String name) {
setOption("--exclude-uploader-name", name);
return this;
}
/**
* Includes the given cataloger.
*
* @param cataloger the cataloger name
* @return this operation instance
*/
public JReleaserReleaseOperation cataloger(String cataloger) {
setOption("--cataloger", cataloger);
return this;
}
/**
* Excludes the given cataloger.
*
* @param cataloger the cataloger name
* @return this operation instance
*/
public JReleaserReleaseOperation 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 JReleaserReleaseOperation deployerByType(String deployer) {
setOption("--deployer", deployer);
return this;
}
/**
* Excludes the given deployer by type.
*
* @param deployer the deployer type
* @return this operation instance
*/
public JReleaserReleaseOperation 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 JReleaserReleaseOperation 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 JReleaserReleaseOperation excludeDeployerByName(String name) {
setOption("--exclude-deployer-name", name);
return this;
}
}

View file

@ -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;
/**
* Generate digital signatures.
*/
public class JReleaserSignOperation extends AbstractJReleaserDistributionModelOperation<JReleaserSignOperation> {
public JReleaserSignOperation() {
super("sign");
}
}

View file

@ -0,0 +1,172 @@
/*
* 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;
/**
* Create a JReleaser config file.
*/
public class JReleaserTemplateEvalOperation extends AbstractJReleaserPlatformAwareModelOperation<JReleaserTemplateEvalOperation> {
public JReleaserTemplateEvalOperation() {
super("template eval");
}
/**
* Overwrite existing files.
*
* @return this operation instance
*/
public JReleaserTemplateEvalOperation overwrite() {
setOption("--overwrite", EMPTY);
return this;
}
/**
* Display announce configuration.
*
* @return this operation instance
*/
public JReleaserTemplateEvalOperation announce() {
setOption("--announce", EMPTY);
return this;
}
/**
* Display assembly configuration.
*
* @return this operation instance
*/
public JReleaserTemplateEvalOperation assembly() {
setOption("--assembly", EMPTY);
return this;
}
/**
* Display changelog configuration.
*
* @return this operation instance
*/
public JReleaserTemplateEvalOperation changelog() {
setOption("--changelog", EMPTY);
return this;
}
/**
* Display download configuration.
*
* @return this operation instance
*/
public JReleaserTemplateEvalOperation download() {
setOption("--download", EMPTY);
return this;
}
/**
* Input file.
*
* @param file the input file
* @return this operation instance
*/
public JReleaserTemplateEvalOperation inputFile(String file) {
setOption("--input-file", file);
return this;
}
/**
* Input file.
*
* @param file the input file
* @return this operation instance
*/
public JReleaserTemplateEvalOperation inputFile(File file) {
return inputFile(file.getAbsolutePath());
}
/**
* Input file.
*
* @param file the input file
* @return this operation instance
*/
public JReleaserTemplateEvalOperation inputFile(Path file) {
return inputFile(file.toFile());
}
/**
* Input directory.
*
* @param directory the input directory
* @return this operation instance
*/
public JReleaserTemplateEvalOperation inputDirectory(String directory) {
setOption("--input-directory", directory);
return this;
}
/**
* Input directory.
*
* @param directory the input directory
* @return this operation instance
*/
public JReleaserTemplateEvalOperation inputDirectory(File directory) {
return inputDirectory(directory.getAbsolutePath());
}
/**
* Input directory.
*
* @param directory the input directory
* @return this operation instance
*/
public JReleaserTemplateEvalOperation inputDirectory(Path directory) {
return inputDirectory(directory.toFile());
}
/**
* Target directory.
*
* @param directory the target directory
* @return this operation instance
*/
public JReleaserTemplateEvalOperation targetDirectory(String directory) {
setOption("--target-directory", directory);
return this;
}
/**
* Target directory.
*
* @param directory the target directory
* @return this operation instance
*/
public JReleaserTemplateEvalOperation targetDirectory(File directory) {
return targetDirectory(directory.getAbsolutePath());
}
/**
* Target directory.
*
* @param directory the target directory
* @return this operation instance
*/
public JReleaserTemplateEvalOperation targetDirectory(Path directory) {
return targetDirectory(directory.toFile());
}
}

View file

@ -0,0 +1,124 @@
/*
* 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 JReleaserTemplateGenerateOperation extends AbstractJReleaserOperation<JReleaserTemplateGenerateOperation> {
public JReleaserTemplateGenerateOperation() {
super("template generate");
}
/**
* Use snapshot templates.
*
* @return this operation instance
*/
public JReleaserTemplateGenerateOperation snapshot() {
setOption("--snapshot", EMPTY);
return this;
}
/**
* Includes the given distribution.
*
* @param distribution the distribution name
* @return this operation instance
*/
public JReleaserTemplateGenerateOperation distribution(String distribution) {
setOption("--distribution", distribution);
return self();
}
/**
* Includes the given distribution by type.
*
* @param type the distribution type
* @return this operation instance
*/
public JReleaserTemplateGenerateOperation distributionByType(String type) {
setOption("--distribution-type", type);
return this;
}
/**
* Excludes the given distribution.
*
* @param distribution the distribution name
* @return this operation instance
*/
public JReleaserTemplateGenerateOperation excludeDistribution(String distribution) {
setOption("--exclude-distribution", distribution);
return self();
}
/**
* Includes the given announcer.
*
* @param announcer the announcer name
* @return this operation instance
*/
public JReleaserTemplateGenerateOperation announcer(String announcer) {
setOption("--announcer", announcer);
return this;
}
/**
* Includes the given assembler by name.
*
* @param assembler the assembler name
* @return this operation instance
*/
public JReleaserTemplateGenerateOperation assemblerByName(String assembler) {
setOption("--assembler", assembler);
return this;
}
/**
* Includes the given assembler by type.
*
* @param type the assembler type
* @return this operation instance
*/
public JReleaserTemplateGenerateOperation assemblerByType(String type) {
setOption("--assembler-type", type);
return this;
}
/**
* Includes the given packager.
*
* @param packager the packager name
* @return this operation instance
*/
public JReleaserTemplateGenerateOperation packager(String packager) {
setOption("--packager", packager);
return self();
}
/**
* Excludes the given packager.
*
* @param packager the packager name
* @return this operation instance
*/
public JReleaserTemplateGenerateOperation excludePackager(String packager) {
setOption("--exclude-packager", packager);
return self();
}
}

View file

@ -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;
/**
* Upload assets.
*/
public class JReleaserUploadOperation extends AbstractJReleaserDistributionModelOperation<JReleaserUploadOperation> {
public JReleaserUploadOperation() {
super("upload");
}
/**
* Includes the given uploader by type.
*
* @param uploader the uploader type
* @return this operation instance
*/
public JReleaserUploadOperation uploaderByType(String uploader) {
setOption("--uploader", uploader);
return this;
}
/**
* Excludes the given uploader by type.
*
* @param uploader the uploader type
* @return this operation instance
*/
public JReleaserUploadOperation 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 JReleaserUploadOperation 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 JReleaserUploadOperation excludeUploaderByName(String name) {
setOption("--exclude-uploader-name", name);
return this;
}
/**
* Includes the given cataloger.
*
* @param cataloger the cataloger name
* @return this operation instance
*/
public JReleaserUploadOperation cataloger(String cataloger) {
setOption("--cataloger", cataloger);
return this;
}
/**
* Excludes the given cataloger.
*
* @param cataloger the cataloger name
* @return this operation instance
*/
public JReleaserUploadOperation excludeCataloger(String cataloger) {
setOption("--exclude-cataloger", cataloger);
return this;
}
}