Compare commits

..

6 Commits

Author SHA1 Message Date
1d999ddc96 make sure includeLibraries only includes jar files
All checks were successful
CI / build (push) Successful in 1m57s
2025-03-12 23:27:55 +08:00
c2112b9e16 bump lys version
All checks were successful
CI / build (push) Successful in 49s
2025-01-21 15:30:24 +08:00
5cfc65c35a fixed bug with package listing in JPMS modules
All checks were successful
CI / build (push) Successful in 1m32s
2025-01-08 09:35:37 +08:00
d5c93708c5 updated Gradle version
All checks were successful
CI / build (push) Successful in 1m1s
2024-12-31 22:44:53 +08:00
c75afe1073 bumped Gradle version
All checks were successful
CI / build (push) Successful in 26s
2024-12-15 20:35:22 +08:00
dbf99afe2f moved to gitea
All checks were successful
CI / build (push) Successful in 14s
2024-04-04 06:38:19 +08:00
12 changed files with 101 additions and 48 deletions

View File

@@ -0,0 +1,21 @@
name: CI
on:
push:
branches: [ master ]
jobs:
build:
runs-on: hostinger
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: graalvm
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Execute Gradle build
env:
PUBLISHER_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
run: ./gradlew publish

View File

@@ -15,12 +15,12 @@ Declare the plugin in your build's `settings.gradle` like this
pluginManagement { pluginManagement {
repositories { repositories {
maven { maven {
url = 'https://woggioni.net/mvn/' url = 'https://gitea.woggioni.net/api/packages/woggioni/maven'
} }
} }
plugins { plugins {
id "net.woggioni.gradle.envelope" version "2023.09.25" id "net.woggioni.gradle.envelope" version "2025.01.21"
} }
} }
``` ```
@@ -80,10 +80,12 @@ ${sys:user.home}/plugins
``` ```
###### javaAgent ###### javaAgent
This is a method accepting 2 strings, the first is the Java agent classname and the second one is the java agent arguments. This is a method accepting 2 strings, the first is the Java agent class name and the second one is the java agent arguments.
It can be invoked multiple times to setup multiple java agents for the same JAR file. It can be invoked multiple times to setup multiple java agents for the same JAR file.
All the java agents will be invoked before the application startup. All the java agents will be invoked before the application startup.
Java agents configured in this way will always run together with the application and cannot be disabled.
### Example ### Example
```groovy ```groovy
@@ -107,7 +109,14 @@ envelopeJar {
### Limitations ### Limitations
This plugin requires Gradle >= 6.0 and Java >=0 8 to build the executable jar file. - This plugin requires Gradle >= 6.0 and Java >=0 8 to build the executable jar file.
The assembled envelope jar requires and Java >= 8 to run, if only `mainClass` is specified, The assembled envelope jar requires and Java >= 8 to run, if only `mainClass` is specified,
if both `mainModule` and `mainClass` are specified the generated jar file will (try to) run in classpath mode on Java 8 if both `mainModule` and `mainClass` are specified the generated jar file will (try to) run in classpath mode on Java 8
and in JPMS mode on Java > 8. and in JPMS mode on Java > 8.
- When running in JPMS mode (when the `mainModule` property is set), command line arguments like
`--add-opens`, `--add-exports`, `--add-reads` won't work as JPMS is initialized after application startup
- When running in JPMS mode custom stream handler need to added installed using `URL.setURLStreamHandlerFactory`,
setting the `java.protocol.handler.pkgs` system property does not work as it tries to load
the respective handler using the system classloader which, in an envelope application, can only load envelope own classes

View File

@@ -16,7 +16,7 @@ allprojects {
java { java {
toolchain { toolchain {
languageVersion = JavaLanguageVersion.of(17) languageVersion = JavaLanguageVersion.of(21)
} }
} }
@@ -45,7 +45,18 @@ allprojects {
publishing { publishing {
repositories { repositories {
maven { maven {
url = publishMavenRepositoryUrl name = "Gitea"
url = uri(getProperty('gitea.maven.url'))
credentials(HttpHeaderCredentials) {
name = "Authorization"
value = "token ${System.getenv()["PUBLISHER_TOKEN"]}"
}
authentication {
header(HttpHeaderAuthentication)
}
} }
} }
} }
@@ -104,11 +115,6 @@ gradlePlugin {
} }
} }
wrapper {
gradleVersion = getProperty('version.gradle')
distributionType = Wrapper.DistributionType.ALL
}
tasks.named('processTestResources') { ProcessResources it -> tasks.named('processTestResources') { ProcessResources it ->
doLast { doLast {
Files.newBufferedWriter(it.destinationDir.toPath().resolve('test-resources.txt')).withCloseable { writer -> Files.newBufferedWriter(it.destinationDir.toPath().resolve('test-resources.txt')).withCloseable { writer ->

View File

@@ -1,7 +1,7 @@
woggioniMavenRepositoryUrl=https://woggioni.net/mvn/ gitea.maven.url = https://gitea.woggioni.net/api/packages/woggioni/maven
publishMavenRepositoryUrl=https://mvn.woggioni.net/
lys.version = 2024.02.24 lys.version = 2025.03.08
version.envelope=2024.02.28 version.envelope=2025.03.12
version.gradle=7.6
org.gradle.caching=true

Binary file not shown.

View File

@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

34
gradlew vendored
View File

@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
# SPDX-License-Identifier: Apache-2.0
#
############################################################################## ##############################################################################
# #
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,10 +85,9 @@ done
# This is normally unused # This is normally unused
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. ' "$PWD" ) || exit
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -133,10 +134,13 @@ location of your Java installation."
fi fi
else else
JAVACMD=java JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
@@ -144,7 +148,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045 # shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
@@ -152,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045 # shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@@ -197,11 +201,15 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
# shell script including quotes and variable substitutions, so put them in DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded. # Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \ set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \ "-Dorg.gradle.appname=$APP_BASE_NAME" \

22
gradlew.bat vendored
View File

@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and @rem See the License for the specific language governing permissions and
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute if exist "%JAVA_EXE%" goto execute
echo. echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. echo location of your Java installation. 1>&2
goto fail goto fail

View File

@@ -192,7 +192,7 @@ public class JarFileModuleFinder implements ModuleFinder {
private static Set<String> collectPackageNames(JarFile jarFile) { private static Set<String> collectPackageNames(JarFile jarFile) {
Set<String> result = jarFile Set<String> result = jarFile
.versionedStream() .versionedStream()
.filter(entry -> entry.getName().endsWith(".class")) .filter(zipEntry -> !zipEntry.isDirectory())
.map(entry -> { .map(entry -> {
String entryName = entry.getName(); String entryName = entry.getName();
int lastSlash = entryName.lastIndexOf('/'); int lastSlash = entryName.lastIndexOf('/');
@@ -459,7 +459,8 @@ public class JarFileModuleFinder implements ModuleFinder {
/** /**
* Returns {@code true} if the given name is a legal type name. * Returns {@code true} if the given name is a legal type name.
*/ private static boolean isPackageName(String name) { */
private static boolean isPackageName(String name) {
return isTypeName(name); return isTypeName(name);
} }

View File

@@ -9,7 +9,7 @@ pluginManagement {
includeModule 'net.woggioni.gradle', 'multi-release-jar' includeModule 'net.woggioni.gradle', 'multi-release-jar'
includeModule 'net.woggioni.gradle.multi-release-jar', 'net.woggioni.gradle.multi-release-jar.gradle.plugin' includeModule 'net.woggioni.gradle.multi-release-jar', 'net.woggioni.gradle.multi-release-jar.gradle.plugin'
} }
url = 'https://woggioni.net/mvn/' url = getProperty('gitea.maven.url')
} }
} }
} }
@@ -17,7 +17,7 @@ pluginManagement {
dependencyResolutionManagement { dependencyResolutionManagement {
repositories { repositories {
maven { maven {
url = 'https://woggioni.net/mvn/' url = getProperty('gitea.maven.url')
content { content {
includeGroup 'com.lys' includeGroup 'com.lys'
} }

View File

@@ -135,7 +135,10 @@ public abstract class EnvelopeJarTask extends AbstractArchiveTask {
} }
public void includeLibraries(Object... files) { public void includeLibraries(Object... files) {
into(Constants.LIBRARIES_FOLDER, (copySpec) -> copySpec.from(files)); into(Constants.LIBRARIES_FOLDER, (copySpec) -> {
copySpec.include("*.jar");
copySpec.from(files);
});
} }

View File

@@ -12,11 +12,13 @@ import org.gradle.api.tasks.bundling.Jar;
public class EnvelopePlugin implements Plugin<Project> { public class EnvelopePlugin implements Plugin<Project> {
public static final String ENVELOPE_GROUP_NAME = "envelope"; public static final String ENVELOPE_GROUP_NAME = "envelope";
public static final String ENVELOPE_JAR_TASK_NAME = "envelopeJar";
public static final String ENVELOPE_RUN_TASK_NAME = "envelopeRun";
@Override @Override
public void apply(Project project) { public void apply(Project project) {
project.getPluginManager().apply(JavaPlugin.class); project.getPluginManager().apply(JavaPlugin.class);
Provider<EnvelopeJarTask> envelopeJarTaskProvider = project.getTasks().register("envelopeJar", EnvelopeJarTask.class, t -> { Provider<EnvelopeJarTask> envelopeJarTaskProvider = project.getTasks().register(ENVELOPE_JAR_TASK_NAME, EnvelopeJarTask.class, t -> {
t.setGroup(ENVELOPE_GROUP_NAME); t.setGroup(ENVELOPE_GROUP_NAME);
t.setDescription("Package the application in a single executable jar file"); t.setDescription("Package the application in a single executable jar file");
t.includeLibraries(project.getConfigurations().named(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)); t.includeLibraries(project.getConfigurations().named(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
@@ -25,7 +27,7 @@ public class EnvelopePlugin implements Plugin<Project> {
project.getTasks().named(BasePlugin.ASSEMBLE_TASK_NAME, DefaultTask.class, assembleTask -> { project.getTasks().named(BasePlugin.ASSEMBLE_TASK_NAME, DefaultTask.class, assembleTask -> {
assembleTask.dependsOn(envelopeJarTaskProvider); assembleTask.dependsOn(envelopeJarTaskProvider);
}); });
Provider<JavaExec> envelopeRunTaskProvider = project.getTasks().register("envelopeRun", JavaExec.class, t -> { Provider<JavaExec> envelopeRunTaskProvider = project.getTasks().register(ENVELOPE_RUN_TASK_NAME, JavaExec.class, t -> {
t.getInputs().files(envelopeJarTaskProvider); t.getInputs().files(envelopeJarTaskProvider);
t.setGroup(ENVELOPE_GROUP_NAME); t.setGroup(ENVELOPE_GROUP_NAME);
t.setDescription("Run the application in the envelope jar"); t.setDescription("Run the application in the envelope jar");