diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22f1728..cb323b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest] - java-version: [ '8', '11', '17' ] + os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} env: @@ -29,12 +28,12 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: ${{ matrix.java-version }} + java-version: '17' - name: "[Setup] - Install Ruby" uses: ruby/setup-ruby@v1 with: - ruby-version: 3.0 # Not needed with a .ruby-version file + ruby-version: '3.0' # Not needed with a .ruby-version file bundler-cache: true - name: "[Setup] - Install CycloneDX CLI" @@ -44,7 +43,6 @@ jobs: chmod a+x cyclonedx-linux-x64 mv cyclonedx-linux-x64 cyclonedx echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH - - name: "[Lint] - run linters" run: | diff --git a/Gemfile.lock b/Gemfile.lock index b2e49fe..6eba63b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,6 +44,7 @@ GEM mime-types (3.4.1) mime-types-data (~> 3.2015) mime-types-data (3.2022.0105) + mini_portile2 (2.8.0) multi_test (1.1.0) parallel (1.22.1) parser (3.1.2.1) @@ -68,10 +69,8 @@ GEM rubocop-ast (1.23.0) parser (>= 3.1.1.0) ruby-progressbar (1.11.0) - sqlite3 (1.5.3-arm64-darwin) - sqlite3 (1.5.3-x64-mingw-ucrt) - sqlite3 (1.5.3-x64-mingw32) - sqlite3 (1.5.3-x86_64-linux) + sqlite3 (1.5.3) + mini_portile2 (~> 2.8.0) sys-uname (1.2.2) ffi (~> 1.1) thor (1.2.1) @@ -81,6 +80,7 @@ PLATFORMS arm64-darwin-21 x64-mingw-ucrt x64-mingw32 + x86_64-darwin-19 x86_64-linux DEPENDENCIES diff --git a/README.md b/README.md index d6883f8..30ec76b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Freshli Agent: Java -This application is used by the [`freshli` CLI](https://github.com/corgibytes/freshli-cli) to detect and process manifest files from the Java ecosystem. +This application is used by the [`freshli` CLI](https://github.com/corgibytes/freshli-cli) to detect and process manifest files from the Java ecosystem. It runs on Java 8 or newer, and is tested against Java 8, 11, and 17 on both Windows and Linux. ## Building @@ -33,21 +33,21 @@ ruby .\bin\build.rb #### Using Gradle -Make sure you have JDK version 17 or later installed and have your `JAVA_HOME` environment varibale set appropriately. +Make sure you have JDK version 17 or later installed and have your `JAVA_HOME` environment variable set appropriately. Run the following command to create a complete deployable distribution for the project. On macOS or Linux: ```bash -./gradlew installDist +./gradlew jpackageImage ``` On Windows: ```pwsh -.\gradlew.bat installDist +.\gradlew.bat jpackageImage ``` -This will create `build/install/freshli-agent-java`. Within that folder, the `bin` directory contains wrappers for running the application. Adding the full path to that `bin` directory to the `PATH` environment variable will enable you to run `freshli-agent-java` from any directory. +This will create `build/jpackage/freshli-agent-java`. Adding that directory to the `PATH` environment variable will enable you to run `freshli-agent-java` from outside of that directory. ## Running @@ -75,18 +75,18 @@ On Windows: `.\gradlew.bat run --args="--help" ``` -#### Running from Distribution Directory +#### Running from build image directory -You can run the program from the distribution that's created by the `installDist` Gradle task. +You can run the program from the directory that's created by the `jpackgaeImage` Gradle task. On macOS and Linux: ```bash -./build/install/freshli-agent-java/bin/freshli-agent-java.bat --help +./build/jpackage/freshli-agent-java/freshli-agent-java --help ``` On Windows: ```pwsh -.\build\install\freshli-agent-java\bin\freshli-agent-java --help +.\build\jpackage\freshli-agent-java\freshli-agent-java.exe --help ``` ### Running Tests diff --git a/bin/build.rb b/bin/build.rb index 09752b8..a1ee623 100755 --- a/bin/build.rb +++ b/bin/build.rb @@ -7,6 +7,6 @@ enable_dotnet_command_colors -status = execute('./gradlew installDist') +status = execute('./gradlew jpackageImage') exit(status.exitstatus) diff --git a/build.gradle.kts b/build.gradle.kts index 2893a7d..2a3b7f7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,17 +1,39 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -plugins { - kotlin("jvm") version "1.7.22" - application -} +import org.apache.tools.ant.taskdefs.condition.Os group = "com.corgibytes" -version = "1.0-SNAPSHOT" + +buildscript { + repositories { + mavenLocal() // for local testing of shipkit + gradlePluginPortal() + mavenCentral() + } + dependencies { + classpath("org.shipkit:shipkit-auto-version:1.+") + classpath("org.shipkit:shipkit-changelog:1.+") + } +} repositories { + mavenLocal() mavenCentral() } +extensions.findByName("buildScan")?.withGroovyBuilder { + setProperty("termsOfServiceUrl", "https://gradle.com/terms-of-service") + setProperty("termsOfServiceAgree", "yes") +} + +apply("gradle/release.gradle") +apply("gradle/ide.gradle") + +plugins { + kotlin("jvm") version "1.7.22" + id("org.beryx.runtime") version "1.12.7" + application +} + dependencies { implementation("com.github.ajalt.clikt:clikt:3.5.0") implementation("com.corgibytes:dependency-history-maven:2.0.17") @@ -28,9 +50,24 @@ tasks.test { } tasks.withType { - kotlinOptions.jvmTarget = "1.8" + kotlinOptions.jvmTarget = "17" } application { mainClass.set("com.corgibytes.freshli.agent.java.MainKt") } + +runtime { + options.set(listOf("--strip-debug", "--compress", "2", "--no-header-files", "--no-man-pages")) + modules.set(listOf( + "java.base", + "java.xml", + "jdk.crypto.ec" + )) + + jpackage { + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + imageOptions = listOf("--win-console") + } + } +} diff --git a/features/support/aruba.rb b/features/support/aruba.rb index eae7766..55f1f09 100644 --- a/features/support/aruba.rb +++ b/features/support/aruba.rb @@ -8,8 +8,8 @@ config.exit_timeout = 300 # Use aruba working directory config.home_directory = File.join(config.root_directory, config.working_directory) - # include the `freshli-agent-java` run scripts from the build directory in the path - config.command_search_paths << File.expand_path('../../build/install/freshli-agent-java/bin', __dir__) + # include the `freshli-agent-java` native image from the build directory in the path + config.command_search_paths << File.expand_path('../../build/jpackage/freshli-agent-java', __dir__) end # Contains helper methods for coping with platform specific differences @@ -19,7 +19,10 @@ def self.null_output_target end def self.normalize_file_separators(value) - separator = File::ALT_SEPARATOR || File::SEPARATOR - value.gsub('/', separator) + value.gsub('/', file_separator) + end + + def self.file_separator + File::ALT_SEPARATOR || File::SEPARATOR end end diff --git a/gradle/ide.gradle b/gradle/ide.gradle new file mode 100644 index 0000000..df8dd21 --- /dev/null +++ b/gradle/ide.gradle @@ -0,0 +1,8 @@ +// Based on: https://github.com/shipkit/shipkit-demo/blob/f604dbf393f9549cc78c7c57b05dc69f9c7ab0fc/gradle/ide.gradle +assert rootProject == project + +allprojects { + apply plugin: 'idea' +} + +idea.project.vcs = 'Git' diff --git a/gradle/release.gradle b/gradle/release.gradle new file mode 100644 index 0000000..393fb6b --- /dev/null +++ b/gradle/release.gradle @@ -0,0 +1,20 @@ +// Based on: https://github.com/shipkit/shipkit-demo/blob/f604dbf393f9549cc78c7c57b05dc69f9c7ab0fc/gradle/release.gradle + +//Plugin jars are added to the buildscript classpath in the root build.gradle file +apply plugin: "org.shipkit.shipkit-auto-version" + +apply plugin: "org.shipkit.shipkit-changelog" +tasks.named("generateChangelog") { + previousRevision = project.ext.'shipkit-auto-version.previous-tag' + githubToken = System.getenv("GITHUB_TOKEN") + repository = "corgibytes/dependency-history-maven" +} + +apply plugin: "org.shipkit.shipkit-github-release" +tasks.named("githubRelease") { + dependsOn tasks.named("generateChangelog") + repository = "corgibytes/dependency-history-maven" + changelog = tasks.named("generateChangelog").get().outputFile + githubToken = System.getenv("GITHUB_TOKEN") + newTagRevision = System.getenv("GITHUB_SHA") +} diff --git a/version.properties b/version.properties new file mode 100644 index 0000000..96f1419 --- /dev/null +++ b/version.properties @@ -0,0 +1,5 @@ +# shipkit-auto-version Gradle plugin uses this version spec to deduct the version to build +# it increments patch version based on most recent tag. +# You can put explicit version here if needed, e.g. "1.0.0" +# More information: https://github.com/shipkit/shipkit-auto-version/blob/master/README.md +version=1.0.*