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 {
repositories {
maven {
url = 'https://woggioni.net/mvn/'
url = 'https://gitea.woggioni.net/api/packages/woggioni/maven'
}
}
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
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.
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
```groovy
@@ -107,7 +109,14 @@ envelopeJar {
### 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,
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 {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(21)
}
}
@@ -45,7 +45,18 @@ allprojects {
publishing {
repositories {
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 ->
doLast {
Files.newBufferedWriter(it.destinationDir.toPath().resolve('test-resources.txt')).withCloseable { writer ->

View File

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

Binary file not shown.

View File

@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
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
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

34
gradlew vendored
View File

@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (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.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,10 +85,9 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# 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
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,10 +134,13 @@ location of your Java installation."
fi
else
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
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@@ -144,7 +148,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# 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 ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -152,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# 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" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -197,11 +201,15 @@ if "$cygwin" || "$msys" ; then
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# 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 -- \
"-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 limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail

View File

@@ -192,7 +192,7 @@ public class JarFileModuleFinder implements ModuleFinder {
private static Set<String> collectPackageNames(JarFile jarFile) {
Set<String> result = jarFile
.versionedStream()
.filter(entry -> entry.getName().endsWith(".class"))
.filter(zipEntry -> !zipEntry.isDirectory())
.map(entry -> {
String entryName = entry.getName();
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.
*/ private static boolean isPackageName(String name) {
*/
private static boolean isPackageName(String 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', 'net.woggioni.gradle.multi-release-jar.gradle.plugin'
}
url = 'https://woggioni.net/mvn/'
url = getProperty('gitea.maven.url')
}
}
}
@@ -17,7 +17,7 @@ pluginManagement {
dependencyResolutionManagement {
repositories {
maven {
url = 'https://woggioni.net/mvn/'
url = getProperty('gitea.maven.url')
content {
includeGroup 'com.lys'
}

View File

@@ -135,7 +135,10 @@ public abstract class EnvelopeJarTask extends AbstractArchiveTask {
}
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 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
public void apply(Project project) {
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.setDescription("Package the application in a single executable jar file");
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 -> {
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.setGroup(ENVELOPE_GROUP_NAME);
t.setDescription("Run the application in the envelope jar");