Skip to content

Commit

Permalink
feat(core): Add a WorkflowListener extension. Resolves #968
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Oct 27, 2022
1 parent b40a4dd commit 39f7c7b
Show file tree
Hide file tree
Showing 216 changed files with 2,164 additions and 506 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.jreleaser.extensions.api;

import org.jreleaser.model.api.JReleaserContext;

import java.util.Map;

/**
Expand All @@ -29,9 +31,10 @@ public interface ExtensionPoint {
/**
* Initializes the extension point with values defined in the configuration DSL.
*
* @param context the current execution context.
* @param properties a {@code Map} of key/value pairs.
*/
default void init(Map<String, Object> properties) {
default void init(JReleaserContext context, Map<String, Object> properties) {
// noop
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2022 The JReleaser 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 org.jreleaser.extensions.api.workflow;

import org.jreleaser.model.api.JReleaserContext;
import org.jreleaser.model.api.announce.Announcer;
import org.jreleaser.model.api.assemble.Assembler;
import org.jreleaser.model.api.deploy.Deployer;
import org.jreleaser.model.api.distributions.Distribution;
import org.jreleaser.model.api.download.Downloader;
import org.jreleaser.model.api.hooks.ExecutionEvent;
import org.jreleaser.model.api.packagers.Packager;
import org.jreleaser.model.api.release.Releaser;
import org.jreleaser.model.api.upload.Uploader;

/**
* Base implementation of the {@code WorkflowListener} interface.
*
* @author Andres Almiray
* @since 1.3.0
*/
public class WorkflowAdapter implements WorkflowListener {
@Override
public boolean isContinueOnError() {
return false;
}

@Override
public void onSessionStart(JReleaserContext context) {

}

@Override
public void onSessionEnd(JReleaserContext context) {

}

@Override
public void onWorkflowStep(ExecutionEvent event, JReleaserContext context) {

}

@Override
public void onAnnounceStep(ExecutionEvent event, JReleaserContext context, Announcer announcer) {

}

@Override
public void onAssembleStep(ExecutionEvent event, JReleaserContext context, Assembler assembler) {

}

@Override
public void onDeployStep(ExecutionEvent event, JReleaserContext context, Deployer deployer) {

}

@Override
public void onDownloadStep(ExecutionEvent event, JReleaserContext context, Downloader downloader) {

}

@Override
public void onUploadStep(ExecutionEvent event, JReleaserContext context, Uploader uploader) {

}

@Override
public void onReleaseStep(ExecutionEvent event, JReleaserContext context, Releaser releaser) {

}

@Override
public void onPackagerPrepareStep(ExecutionEvent event, JReleaserContext context, Distribution distribution, Packager packager) {

}

@Override
public void onPackagerPackageStep(ExecutionEvent event, JReleaserContext context, Distribution distribution, Packager packager) {

}

@Override
public void onPackagerPublishStep(ExecutionEvent event, JReleaserContext context, Distribution distribution, Packager packager) {

}

@Override
public void onDistributionStart(JReleaserContext context, Distribution distribution) {

}

@Override
public void onDistributionEnd(JReleaserContext context, Distribution distribution) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2022 The JReleaser 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 org.jreleaser.extensions.api.workflow;

import org.jreleaser.extensions.api.ExtensionPoint;
import org.jreleaser.model.api.JReleaserContext;
import org.jreleaser.model.api.announce.Announcer;
import org.jreleaser.model.api.assemble.Assembler;
import org.jreleaser.model.api.deploy.Deployer;
import org.jreleaser.model.api.distributions.Distribution;
import org.jreleaser.model.api.download.Downloader;
import org.jreleaser.model.api.hooks.ExecutionEvent;
import org.jreleaser.model.api.packagers.Packager;
import org.jreleaser.model.api.release.Releaser;
import org.jreleaser.model.api.upload.Uploader;

/**
* @author Andres Almiray
* @since 1.3.0
*/
public interface WorkflowListener extends ExtensionPoint {
/**
* Signals JReleaser to halt execution if this listener fails.
*
* @return {@code false} to halt execution on failure, {@code true} to continue.
*/
boolean isContinueOnError();

/**
* Triggered when the execution session starts.
*
* @param context the execution context.
*/
void onSessionStart(JReleaserContext context);

/**
* Triggered when the execution session ends.
*
* @param context the execution context.
*/
void onSessionEnd(JReleaserContext context);

/**
* Triggered when a workflow step starts/ends/fails.
*
* @param event event metadata.
* @param context the execution context.
*/
void onWorkflowStep(ExecutionEvent event, JReleaserContext context);

/**
* Triggered when an announcer starts/ends/fails.
*
* @param event event metadata.
* @param context the execution context.
* @param announcer the executing announcer.
*/
void onAnnounceStep(ExecutionEvent event, JReleaserContext context, Announcer announcer);

/**
* Triggered when an assembler starts/ends/fails.
*
* @param event event metadata.
* @param context the execution context.
* @param assembler the executing assembler.
*/
void onAssembleStep(ExecutionEvent event, JReleaserContext context, Assembler assembler);

/**
* Triggered when a deployer starts/ends/fails.
*
* @param event event metadata.
* @param context the execution context.
* @param deployer the executing deployer.
*/
void onDeployStep(ExecutionEvent event, JReleaserContext context, Deployer deployer);

/**
* Triggered when a downloader starts/ends/fails.
*
* @param event event metadata.
* @param context the execution context.
* @param downloader the executing downloader.
*/
void onDownloadStep(ExecutionEvent event, JReleaserContext context, Downloader downloader);

/**
* Triggered when an uploader starts/ends/fails.
*
* @param event event metadata.
* @param context the execution context.
* @param uploader the executing uploader.
*/
void onUploadStep(ExecutionEvent event, JReleaserContext context, Uploader uploader);

/**
* Triggered when a releaser starts/ends/fails.
*
* @param event event metadata.
* @param context the execution context.
* @param releaser the executing releaser.
*/
void onReleaseStep(ExecutionEvent event, JReleaserContext context, Releaser releaser);

/**
* Triggered when a distribution is about to be processed.
*
* @param context the execution context.
* @param distribution the distribution to be processed.
*/
void onDistributionStart(JReleaserContext context, Distribution distribution);

/**
* Triggered when a distribution has been processed.
*
* @param context the execution context.
* @param distribution the processed distribution.
*/
void onDistributionEnd(JReleaserContext context, Distribution distribution);

/**
* Triggered when a packager starts/ends/fails the preparing step.
*
* @param event event metadata.
* @param context the execution context.
* @param distribution the distribution to be processed.
* @param packager the executing packager.
*/
void onPackagerPrepareStep(ExecutionEvent event, JReleaserContext context, Distribution distribution, Packager packager);

/**
* Triggered when a packager starts/ends/fails the packaging step.
*
* @param event event metadata.
* @param context the execution context.
* @param distribution the distribution to be processed.
* @param packager the executing packager.
*/
void onPackagerPackageStep(ExecutionEvent event, JReleaserContext context, Distribution distribution, Packager packager);

/**
* Triggered when a packager starts/ends/fails the publishing step.
*
* @param event event metadata.
* @param context the execution context.
* @param distribution the distribution to be processed.
* @param packager the executing packager.
*/
void onPackagerPublishStep(ExecutionEvent event, JReleaserContext context, Distribution distribution, Packager packager);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2020-2022 The JReleaser 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 org.jreleaser.extensions.api.workflow;

/**
* @author Andres Almiray
* @since 1.3.0
*/
public class WorkflowListenerException extends Exception {
private final WorkflowListener listener;

public WorkflowListenerException(WorkflowListener listener, RuntimeException cause) {
super(cause);
this.listener = listener;
}

public WorkflowListener getListener() {
return listener;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
* @since 0.1.0
*/
public interface Announcer extends Domain, Activatable, TimeoutAware, ExtraProperties {
String getType();

String getName();

boolean isSnapshotSupported();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
* @since 1.3.0
*/
public interface Deployer extends Domain, Activatable, ExtraProperties {
String getGroup();

String getType();

String getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
* @since 1.3.0
*/
public interface MavenDeployer extends Deployer, TimeoutAware {
String GROUP = "maven";

String getUrl();

String getUsername();
Expand Down
Loading

0 comments on commit 39f7c7b

Please sign in to comment.