diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 91e7e22..1f11692 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: bundler-cache: true - name: Build with Gradle run: | - ./gradlew --no-daemon -s build buildDeb installDist + ./gradlew --no-daemon -s build buildDeb installBootDist - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx @@ -64,7 +64,7 @@ jobs: prerelease: false - name: Get the ZIP id: get_zip - run: echo ::set-output name=filename::$(basename $(find build/distributions -name "*.zip")) + run: echo ::set-output name=filename::$(basename $(find build/distributions -name "*-boot-*.zip")) - name: Upload Release ZIP id: upload-release-asset-zip uses: actions/upload-release-asset@v1 diff --git a/Dockerfile b/Dockerfile index 9cad327..ee2a3c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM eclipse-temurin:17-jre-focal WORKDIR /opt/googolplex-theater -COPY build/install/googolplex-theater/ . +COPY build/install/googolplex-theater-boot/ . EXPOSE 8000 EXPOSE 5353/udp VOLUME ["/opt/googolplex-theater/conf"] diff --git a/build.gradle b/build.gradle index 9ab927f..0687355 100644 --- a/build.gradle +++ b/build.gradle @@ -114,50 +114,26 @@ test { finalizedBy jacocoTestReport } -def getGitHash = { -> - def stdout = new ByteArrayOutputStream() - exec { - commandLine 'git', 'rev-parse', 'HEAD' - standardOutput = stdout - } - return stdout.toString().trim() -} - application { mainClass = 'com.jyuzawa.googolplex_theater.GoogolplexTheater' } -jar { - doFirst { - manifest { - attributes( - 'Built-By' : System.properties['user.name'], - 'Build-Timestamp' : new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()), - 'Implementation-Version' : project.version, - 'Implementation-Title' : project.name, - 'Specification-Version' : "${-> getGitHash()}", - 'Created-By' : "Gradle ${gradle.gradleVersion}", - 'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})", - 'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}" - ) - } - } -} -jar.dependsOn(generateLicenseReport) +bootJar.dependsOn(generateLicenseReport) distributions { - main { + boot { contents { from 'LICENSE' from 'README.md' from "${project.buildDir}/reports/dependency-license/THIRD-PARTY-NOTICES.txt" + from "${projectDir}/src/dist" } } } buildDeb { release '1' - dependsOn installDist + dependsOn installBootDist license "MIT" url "https://github.com/yuzawa-san/googolplex-theater" packager "James Yuzawa" @@ -165,12 +141,12 @@ buildDeb { user 'googolplex-theater' permissionGroup 'googolplex-theater' requires("default-jre-headless") - from("${project.buildDir}/install/googolplex-theater") { + from("${project.buildDir}/install/googolplex-theater-boot") { exclude 'conf' exclude 'service' fileMode 0755 } - from("${project.buildDir}/install/googolplex-theater/conf") { + from("${project.buildDir}/install/googolplex-theater-boot/conf") { fileType CONFIG | NOREPLACE fileMode 0644 into 'conf' diff --git a/src/main/java/com/jyuzawa/googolplex_theater/GoogolplexService.java b/src/main/java/com/jyuzawa/googolplex_theater/GoogolplexService.java index 9c1f5d8..93b9c8b 100644 --- a/src/main/java/com/jyuzawa/googolplex_theater/GoogolplexService.java +++ b/src/main/java/com/jyuzawa/googolplex_theater/GoogolplexService.java @@ -47,8 +47,6 @@ public class GoogolplexService implements Closeable { static { log.info("Website: " + PROJECT_WEBSITE); - Package thePackage = GoogolplexTheater.class.getPackage(); - log.info("Revision: {}", thePackage.getSpecificationVersion()); for (String property : DIAGNOSTIC_PROPERTIES) { log.info("Runtime[{}]: {}", property, System.getProperty(property)); } diff --git a/src/main/java/com/jyuzawa/googolplex_theater/GoogolplexTheater.java b/src/main/java/com/jyuzawa/googolplex_theater/GoogolplexTheater.java index 2f13b9a..7c7a809 100644 --- a/src/main/java/com/jyuzawa/googolplex_theater/GoogolplexTheater.java +++ b/src/main/java/com/jyuzawa/googolplex_theater/GoogolplexTheater.java @@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.system.ApplicationHome; import org.springframework.context.annotation.Bean; /** @@ -27,20 +28,12 @@ public Path appHome(@Value("${googolplex-theater.app-home}") Path appHome) { public static void main(String[] args) throws Exception { Path appHome = Paths.get("src/dist").toAbsolutePath(); - try { - Path jarPath = Paths.get(GoogolplexTheater.class - .getProtectionDomain() - .getCodeSource() - .getLocation() - .toURI()); - if (Files.isRegularFile(jarPath)) { - appHome = jarPath.resolve("../../").normalize().toAbsolutePath(); - System.setProperty( - "spring.config.import", - appHome.resolve("./conf/config.yml").toString()); - } - } catch (Exception e) { - // pass + ApplicationHome home = new ApplicationHome(GoogolplexTheater.class); + Path jarPath = home.getSource().toPath(); + if (Files.isRegularFile(jarPath)) { + appHome = jarPath.resolve("../../").normalize().toAbsolutePath(); + System.setProperty( + "spring.config.import", appHome.resolve("conf/config.yml").toString()); } System.setProperty("googolplex-theater.app-home", appHome.toString()); SpringApplication.run(GoogolplexTheater.class, args);