Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
5 changes: 5 additions & 0 deletions .github/project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: SmallRye Modules
# for this project, always set next-version to the next *minor* unless it's on a stable branch!
release:
current-version: 1.0.alpha1-SNAPSHOT
next-version: 1.0.alpha2-SNAPSHOT
79 changes: 79 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: SmallRye Build
env:
MAVEN_VERSION: 3.9.12
IO_TAKARI_MAVEN_WRAPPER_VERSION: 0.7.7

on:
push:
branches:
- main
- jakarta
paths-ignore:
- '.gitattributes'
- '.gitignore'
- 'LICENSE'
- 'NOTICE'
- 'README*'
pull_request:
paths-ignore:
- '.gitattributes'
- '.gitignore'
- 'LICENSE'
- 'NOTICE'
- 'README*'

jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
fail-fast: false
runs-on: ${{ matrix.os }}
name: build

steps:
- uses: actions/checkout@v6
name: checkout

- uses: actions/setup-java@v5
name: set up JDKs
with:
distribution: temurin
java-version: |
25
cache: 'maven'
cache-dependency-path: '**/pom.xml'

- name: build with maven
run: |
mvn -q -N "io.takari:maven:${{env.IO_TAKARI_MAVEN_WRAPPER_VERSION}}:wrapper" "-Dmaven=${{env.MAVEN_VERSION}}"
./mvnw -B -ntp formatter:validate verify javadoc:javadoc --file pom.xml "-Djava25.home=${{env.JAVA_HOME_25_X64}}${{env.JAVA_HOME_25_ARM64}}"

quality:
needs: [ build ]
if: false && github.event_name == 'push' && github.repository_owner == 'smallrye'
runs-on: ubuntu-latest
name: quality

steps:
- uses: actions/checkout@v6

- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 25
cache: 'maven'
cache-dependency-path: '**/pom.xml'

- name: build with coverage
run: |
mvn -q -N "io.takari:maven:${{env.IO_TAKARI_MAVEN_WRAPPER_VERSION}}:wrapper" "-Dmaven=${{env.MAVEN_VERSION}}"
./mvnw -B -ntp verify -Pcoverage

- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 25

- name: sonar
run: ./mvnw -B -ntp sonar:sonar -Dsonar.projectKey=smallrye_smallrye-modules -Dsonar.token=${{secrets.SONAR_TOKEN}}
31 changes: 31 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: SmallRye Pre Release

on:
pull_request:
paths:
- '.github/project.yml'

jobs:
release:
runs-on: ubuntu-latest
name: pre release

steps:
- uses: radcortez/project-metadata-action@main
name: retrieve project metadata
id: metadata
with:
github-token: ${{secrets.GITHUB_TOKEN}}
metadata-file-path: '.github/project.yml'

- name: Validate version
if: contains(steps.metadata.outputs.current-version, 'SNAPSHOT')
run: |
echo '::error::Cannot release a SNAPSHOT version.'
exit 1

- uses: radcortez/milestone-review-action@main
name: milestone review
with:
github-token: ${{secrets.GITHUB_TOKEN}}
milestone-title: ${{steps.metadata.outputs.current-version}}
29 changes: 29 additions & 0 deletions .github/workflows/release-perform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: SmallRye Release
run-name: Perform ${{github.event.inputs.tag || github.ref_name}} Release
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release'
required: true

permissions:
attestations: write
id-token: write
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
perform-release:
name: Perform Release
uses: smallrye/.github/.github/workflows/perform-release.yml@main
secrets: inherit
with:
version: ${{github.event.inputs.tag || github.ref_name}}
java_version: 25
21 changes: 21 additions & 0 deletions .github/workflows/release-prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: SmallRye Prepare Release

on:
workflow_dispatch:
pull_request:
types: [ closed ]
paths:
- '.github/project.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
prepare-release:
name: Prepare Release
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true}}
uses: smallrye/.github/.github/workflows/prepare-release.yml@main
secrets: inherit
with:
java_version: 25
17 changes: 17 additions & 0 deletions .github/workflows/update-milestone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Update Milestone

on:
pull_request_target:
types: [closed]

jobs:
update:
runs-on: ubuntu-latest
name: update-milestone
if: ${{github.event.pull_request.merged == true}}

steps:
- uses: radcortez/milestone-set-action@main
name: milestone set
with:
github-token: ${{secrets.GITHUB_TOKEN}}
65 changes: 55 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.github.dmlloyd.modules</groupId>
<artifactId>modules3</artifactId>
<version>1.0-SNAPSHOT</version>
<groupId>io.smallrye.modules</groupId>
<artifactId>smallrye-modules</artifactId>
<version>1.0-alpha1-SNAPSHOT</version>

<parent>
<groupId>org.jboss</groupId>
<artifactId>jboss-parent</artifactId>
<version>51</version>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-parent</artifactId>
<version>45</version>
</parent>

<properties>
Expand All @@ -24,7 +24,7 @@
<dependency>
<groupId>io.smallrye.common</groupId>
<artifactId>smallrye-common-bom</artifactId>
<version>2.15.0</version>
<version>2.17.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down Expand Up @@ -56,7 +56,7 @@
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<artifactId>junit-jupiter</artifactId>
<version>5.11.1</version>
<scope>test</scope>
</dependency>
Expand All @@ -67,19 +67,64 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-exports java.base/jdk.internal.module=io.github.dmlloyd.modules</argLine>
<argLine>--add-exports java.base/jdk.internal.module=io.smallrye.modules</argLine>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>io.github.dmlloyd.modules.Launcher</mainClass>
<mainClass>io.smallrye.modules.Launcher</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<version>1.13.0</version>
<dependencies>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
<version>3.28.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>sort-imports</id>
<goals>
<goal>sort</goal>
</goals>
<configuration>
<compliance>17</compliance>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<executions>
<execution>
<id>format-sources</id>
<phase>process-sources</phase>
<goals>
<goal>format</goal>
</goals>
<configuration>
<compilerCompliance>17</compilerCompliance>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<source>17</source>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.github.dmlloyd.modules;
package io.smallrye.modules;

import java.util.List;
import java.util.concurrent.locks.ReentrantLock;

import io.github.dmlloyd.modules.desc.ModuleDescriptor;
import io.smallrye.common.constraint.Assert;
import io.smallrye.common.resource.ResourceLoader;
import io.smallrye.modules.desc.ModuleDescriptor;

/**
* A defined module.
Expand All @@ -18,7 +18,8 @@ static final class New extends DefinedModule {
private final ReentrantLock loadLock = new ReentrantLock();
private volatile DefinedModule result;

New(final String moduleName, final List<ResourceLoaderOpener> resourceLoaderOpeners, final ModuleDescriptorLoader descriptorLoader) {
New(final String moduleName, final List<ResourceLoaderOpener> resourceLoaderOpeners,
final ModuleDescriptorLoader descriptorLoader) {
this.moduleName = moduleName;
this.resourceLoaderOpeners = List.copyOf(resourceLoaderOpeners);
this.descriptorLoader = descriptorLoader;
Expand All @@ -42,9 +43,11 @@ ModuleClassLoader moduleClassLoader(final ModuleLoader moduleLoader) {
for (int i = 0; i < cnt; i++) {
ResourceLoaderOpener opener = openers.get(i);
try {
loaderArray[i] = Assert.checkNotNullArrayParam("returned loader from openers", i, opener.open());
loaderArray[i] = Assert.checkNotNullArrayParam("returned loader from openers", i,
opener.open());
} catch (Throwable t) {
ModuleLoadException mle = new ModuleLoadException("Failed to open a resource loader for `" + moduleName + "`", t);
ModuleLoadException mle = new ModuleLoadException(
"Failed to open a resource loader for `" + moduleName + "`", t);
for (int j = i - 1; j >= 0; j--) {
try {
loaderArray[j].close();
Expand All @@ -58,14 +61,14 @@ ModuleClassLoader moduleClassLoader(final ModuleLoader moduleLoader) {
List<ResourceLoader> loaders = List.of(loaderArray);
try {
ModuleDescriptor desc = descriptorLoader.loadDescriptor(moduleName, loaders);
if (! desc.name().equals(moduleName)) {
throw new ModuleLoadException("Module descriptor for `" + moduleName + "` has unexpected name `" + desc.name() + "`");
if (!desc.name().equals(moduleName)) {
throw new ModuleLoadException(
"Module descriptor for `" + moduleName + "` has unexpected name `" + desc.name() + "`");
}
ModuleClassLoader.ClassLoaderConfiguration config = new ModuleClassLoader.ClassLoaderConfiguration(
moduleLoader,
loaders,
desc
);
moduleLoader,
loaders,
desc);
ModuleClassLoader mcl;
try {
mcl = moduleLoader.createClassLoader(config);
Expand All @@ -76,7 +79,8 @@ ModuleClassLoader moduleClassLoader(final ModuleLoader moduleLoader) {
this.result = result;
moduleLoader.replace(this, result);
} catch (Throwable t) {
ModuleLoadException mle = new ModuleLoadException("Failed to load module descriptor for for " + moduleName, t);
ModuleLoadException mle = new ModuleLoadException(
"Failed to load module descriptor for for " + moduleName, t);
for (int j = cnt - 1; j >= 0; j--) {
try {
loaders.get(j).close();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.dmlloyd.modules;
package io.smallrye.modules;

import java.util.function.Function;

Expand All @@ -17,7 +17,8 @@ public final class DelegatingModuleLoader extends ModuleLoader {
* @param moduleFinder the module finder (must not be {@code null})
* @param delegateFn the function which yields the delegate to use when the module is not found (must not be {@code null})
*/
public DelegatingModuleLoader(final String name, final ModuleFinder moduleFinder, final Function<String, ModuleLoader> delegateFn) {
public DelegatingModuleLoader(final String name, final ModuleFinder moduleFinder,
final Function<String, ModuleLoader> delegateFn) {
super(name, moduleFinder);
this.delegateFn = Assert.checkNotNullParam("delegateFn", delegateFn);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.dmlloyd.modules;
package io.smallrye.modules;

import java.util.List;

Expand Down
Loading
Loading