Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Initial extensions support. Relates to #929
- Loading branch information
Showing
106 changed files
with
1,521 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
project_description = JReleaser logger API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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. | ||
*/ | ||
dependencies { | ||
api project(':jreleaser-model-api') | ||
api project(':jreleaser-resource-bundle') | ||
|
||
compileOnly "org.kordamp.jipsy:jipsy-annotations:${jipsyVersion}" | ||
annotationProcessor "org.kordamp.jipsy:jipsy-processor:${jipsyVersion}" | ||
|
||
api('kr.motd.maven:os-maven-plugin:1.7.0') { transitive = false } | ||
api "com.github.spullara.mustache.java:compiler:$mustacheVersion" | ||
api "com.fasterxml.jackson.core:jackson-core:$jacksonVersion" | ||
api "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion" | ||
api "org.bouncycastle:bcpg-jdk15on:$bouncyCastleVersion" | ||
// checksum | ||
api "commons-codec:commons-codec:$commonsCodecVersion" | ||
api "org.apache.commons:commons-compress:$commonsCompressVersion" | ||
api "org.slf4j:jcl-over-slf4j:$slf4jVersion" | ||
api "org.zeroturnaround:zt-exec:$ztexecVersion" | ||
api "com.github.veithen.cosmos.bootstrap:org.tukaani.xz:$xzVersion" | ||
api "org.commonmark:commonmark:$commonmarkVersion" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
project_description = JReleaser model API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
dependencies { | ||
api project(':jreleaser-resource-bundle') | ||
} |
30 changes: 30 additions & 0 deletions
30
api/jreleaser-model-api/src/main/java/org/jreleaser/extensions/api/Extension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* @author Andres Almiray | ||
* @since 1.3.0 | ||
*/ | ||
public interface Extension { | ||
String getName(); | ||
|
||
Set<? extends ExtensionPoint> provides(); | ||
} |
28 changes: 28 additions & 0 deletions
28
api/jreleaser-model-api/src/main/java/org/jreleaser/extensions/api/ExtensionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* 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; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* @author Andres Almiray | ||
* @since 1.3.0 | ||
*/ | ||
public interface ExtensionManager { | ||
<T extends ExtensionPoint> Set<T> findExtensionPoints(Class<T> extensionPointType); | ||
} |
76 changes: 76 additions & 0 deletions
76
...releaser-model-api/src/main/java/org/jreleaser/extensions/api/ExtensionManagerHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* 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; | ||
|
||
import org.jreleaser.bundle.RB; | ||
|
||
import java.util.List; | ||
import java.util.ServiceLoader; | ||
import java.util.function.Supplier; | ||
import java.util.stream.StreamSupport; | ||
|
||
import static java.util.stream.Collectors.toList; | ||
|
||
/** | ||
* @author Andres Almiray | ||
* @since 1.3.0 | ||
*/ | ||
@org.jreleaser.infra.nativeimage.annotations.NativeImage | ||
public final class ExtensionManagerHolder { | ||
private static final ThreadLocal<ExtensionManager> EXTENSION_MANAGER_THREAD_LOCAL = ThreadLocal.withInitial(new Supplier<ExtensionManager>() { | ||
@Override | ||
public ExtensionManager get() { | ||
List<ExtensionManager> extensionManagers = StreamSupport | ||
.stream(resolveServiceLoader().spliterator(), false) | ||
.collect(toList()); | ||
|
||
if (extensionManagers.size() == 0) { | ||
// Should never happen! | ||
throw new IllegalStateException(RB.$("ERROR_extension_manager_load")); | ||
} else if (extensionManagers.size() > 1) { | ||
throw new IllegalStateException(RB.$("ERROR_extension_manager_multiple_instances", extensionManagers.size())); | ||
} | ||
|
||
return extensionManagers.get(0); | ||
} | ||
}); | ||
|
||
public static ExtensionManager get() { | ||
return EXTENSION_MANAGER_THREAD_LOCAL.get(); | ||
} | ||
|
||
private static ServiceLoader<ExtensionManager> resolveServiceLoader() { | ||
// TODO: review when moving baseline to JDK11+ | ||
// Check if handlers must be loaded from a ModuleLayer | ||
// if (null != ExtensionManager.class.getModule().getLayer()) { | ||
// ServiceLoader<ExtensionManager> handlers = ServiceLoader.load(ExtensionManager.class.getModule().getLayer(), ExtensionManager.class); | ||
// if (handlers.stream().count() > 0) { | ||
// return handlers; | ||
// } | ||
// } | ||
|
||
// Check if the ExtensionManager.class.classLoader works | ||
ServiceLoader<ExtensionManager> handlers = ServiceLoader.load(ExtensionManager.class, ExtensionManager.class.getClassLoader()); | ||
if (handlers.iterator().hasNext()) { | ||
return handlers; | ||
} | ||
|
||
// If *nothing* else works | ||
return ServiceLoader.load(ExtensionManager.class); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
api/jreleaser-model-api/src/main/java/org/jreleaser/extensions/api/ExtensionPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* @author Andres Almiray | ||
* @since 1.3.0 | ||
*/ | ||
public interface ExtensionPoint { | ||
default void init(Map<String, Object> properties) { | ||
// noop | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...model-api/src/main/java/org/jreleaser/extensions/api/mustache/MustacheExtensionPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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.mustache; | ||
|
||
import org.jreleaser.extensions.api.ExtensionPoint; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* @author Andres Almiray | ||
* @since 1.3.0 | ||
*/ | ||
public interface MustacheExtensionPoint extends ExtensionPoint { | ||
void apply(Map<String, Object> props); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.