diff --git a/.github/workflows/bld.yml b/.github/workflows/bld.yml index 94c08ea..7d224f6 100644 --- a/.github/workflows/bld.yml +++ b/.github/workflows/bld.yml @@ -1,16 +1,18 @@ name: bld-ci -on: [ push, pull_request, workflow_dispatch ] +on: [push, pull_request, workflow_dispatch] + +env: + KOTLIN_HOME: /usr/share/kotlinc jobs: build-bld-project: + runs-on: ubuntu-latest + strategy: matrix: - java-version: [ 17, 21, 24 ] - kotlin-version: [ 1.9.25, 2.0.21, 2.1.20 ] - os: [ ubuntu-latest, windows-latest, macos-latest ] - - runs-on: ${{ matrix.os }} + java-version: [17, 21, 22] + kotlin-version: [ 1.19.24, 2.0.0 ] steps: - name: Checkout source repository @@ -24,16 +26,8 @@ jobs: distribution: "zulu" java-version: ${{ matrix.java-version }} - - name: Download dependencies [examples] - working-directory: examples - run: ./bld download - - - name: Compile and run [examples] - working-directory: examples - run: ./bld compile run - - name: Download dependencies run: ./bld download - name: Run tests - run: ./bld compile test \ No newline at end of file + run: ./bld compile test diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 508f6a5..bf43624 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -47,11 +47,11 @@ jobs: uses: actions/configure-pages@v3 - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v1 with: # Upload generated Javadocs repository path: "build/javadoc/" - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@v1 diff --git a/.idea/copyright/Apache_License.xml b/.idea/copyright/Apache_License.xml index 4446c15..ade80da 100644 --- a/.idea/copyright/Apache_License.xml +++ b/.idea/copyright/Apache_License.xml @@ -1,6 +1,6 @@ - - \ No newline at end of file + diff --git a/.idea/icon.svg b/.idea/icon.svg deleted file mode 100644 index 81220b4..0000000 --- a/.idea/icon.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/.idea/libraries/bld.xml b/.idea/libraries/bld.xml index 153a060..5c4010c 100644 --- a/.idea/libraries/bld.xml +++ b/.idea/libraries/bld.xml @@ -2,12 +2,12 @@ - + - + diff --git a/.vscode/settings.json b/.vscode/settings.json index ba429d0..4c33beb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,7 +9,7 @@ ], "java.configuration.updateBuildConfiguration": "automatic", "java.project.referencedLibraries": [ - "${HOME}/.bld/dist/bld-2.2.1.jar", + "${HOME}/.bld/dist/bld-2.1.0.jar", "lib/**/*.jar" ] } diff --git a/README.md b/README.md index 23c69a2..b151e19 100755 --- a/README.md +++ b/README.md @@ -3,20 +3,12 @@ [![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) -[![bld](https://img.shields.io/badge/2.2.1-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld) +[![bld](https://img.shields.io/badge/2.1.0-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld) [![Release](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/releases/com/uwyn/rife2/bld-generated-version/maven-metadata.xml?color=blue)](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-generated-version) [![Snapshot](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/snapshots/com/uwyn/rife2/bld-generated-version/maven-metadata.xml?label=snapshot)](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-generated-version) [![GitHub CI](https://github.com/rife2/bld-generated-version/actions/workflows/bld.yml/badge.svg)](https://github.com/rife2/bld-generated-version/actions/workflows/bld.yml) -To install the latest version, add the following to the `lib/bld/bld-wrapper.properties` file: - -```properties -bld.extension-generated-version=com.uwyn.rife2:bld-generated-version -``` - -For more information, please refer to the [extensions](https://github.com/rife2/bld/wiki/Extensions) documentation. - -## Generate Version Data Class +To install, please refer to the [extensions documentation](https://github.com/rife2/bld/wiki/Extensions). To automatically create a generated version class using the default template in your project on compile, add the following to your build file: ```java diff --git a/config/pmd.xml b/config/pmd.xml index 2641880..3d3203c 100644 --- a/config/pmd.xml +++ b/config/pmd.xml @@ -7,9 +7,9 @@ + + - - diff --git a/examples/.idea/libraries/bld.xml b/examples/.idea/libraries/bld.xml index 153a060..5c4010c 100644 --- a/examples/.idea/libraries/bld.xml +++ b/examples/.idea/libraries/bld.xml @@ -2,12 +2,12 @@ - + - + diff --git a/examples/.vscode/settings.json b/examples/.vscode/settings.json index ba429d0..4c33beb 100644 --- a/examples/.vscode/settings.json +++ b/examples/.vscode/settings.json @@ -9,7 +9,7 @@ ], "java.configuration.updateBuildConfiguration": "automatic", "java.project.referencedLibraries": [ - "${HOME}/.bld/dist/bld-2.2.1.jar", + "${HOME}/.bld/dist/bld-2.1.0.jar", "lib/**/*.jar" ] } diff --git a/examples/lib/bld/bld-wrapper.jar b/examples/lib/bld/bld-wrapper.jar index 3842a62..aa7fc11 100644 Binary files a/examples/lib/bld/bld-wrapper.jar and b/examples/lib/bld/bld-wrapper.jar differ diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index bc257d2..83ddd2a 100644 --- a/examples/lib/bld/bld-wrapper.properties +++ b/examples/lib/bld/bld-wrapper.properties @@ -1,6 +1,6 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true bld.downloadLocation= -bld.extension-gv=com.uwyn.rife2:bld-generated-version:1.0.1 +bld.extension-gv=com.uwyn.rife2:bld-generated-version:0.9.9 bld.repositories=MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES -bld.version=2.2.1 +bld.version=2.1.0 diff --git a/examples/src/bld/java/com/example/SampleBuild.java b/examples/src/bld/java/com/example/SampleBuild.java index c9303a6..f450b0c 100644 --- a/examples/src/bld/java/com/example/SampleBuild.java +++ b/examples/src/bld/java/com/example/SampleBuild.java @@ -27,8 +27,8 @@ public class SampleBuild extends Project { repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES); scope(test) - .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 1))) - .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 1))); + .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 0))) + .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 0))); } public static void main(String[] args) { diff --git a/examples/src/main/java/com/example/GeneratedVersion.java b/examples/src/main/java/com/example/GeneratedVersion.java index 64ecb97..02a3347 100644 --- a/examples/src/main/java/com/example/GeneratedVersion.java +++ b/examples/src/main/java/com/example/GeneratedVersion.java @@ -12,7 +12,7 @@ import java.util.Date; */ public final class GeneratedVersion { public static final String PROJECT = "Sample"; - public static final Date BUILD_DATE = new Date(1736843939053L); + public static final Date BUILD_DATE = new Date(1725050914888L); public static final int MAJOR = 1; public static final int MINOR = 0; public static final int REVISION = 1; diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar index e26a2ae..ca94ae4 100644 Binary files a/lib/bld/bld-wrapper.jar and b/lib/bld/bld-wrapper.jar differ diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index 42fad1d..c3b3e47 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -1,6 +1,6 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true bld.downloadLocation= -bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.2.2 +bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.1.5 bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES -bld.version=2.2.1 +bld.version=2.1.0 diff --git a/src/bld/java/rife/bld/extension/GeneratedVersionOperationBuild.java b/src/bld/java/rife/bld/extension/GeneratedVersionOperationBuild.java index d355d07..9f5158e 100644 --- a/src/bld/java/rife/bld/extension/GeneratedVersionOperationBuild.java +++ b/src/bld/java/rife/bld/extension/GeneratedVersionOperationBuild.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2025 the original author or authors. + * Copyright 2023-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ public class GeneratedVersionOperationBuild extends Project { public GeneratedVersionOperationBuild() { pkg = "rife.bld.extension"; name = "GeneratedVersionOperation"; - version = version(1, 0, 1); + version = version(0, 9, 9); javaRelease = 17; @@ -44,11 +44,11 @@ public class GeneratedVersionOperationBuild extends Project { repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES, RIFE2_SNAPSHOTS); scope(compile) - .include(dependency("com.uwyn.rife2", "bld", version(2, 2, 1))); + .include(dependency("com.uwyn.rife2", "bld", version(2, 1, 0))); scope(test) - .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 12, 1))) - .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 12, 1))) - .include(dependency("org.assertj", "assertj-core", version(3, 27, 3))); + .include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 0))) + .include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 0))) + .include(dependency("org.assertj", "assertj-core", version(3, 26, 3))); precompileOperation() .templateTypes(TXT); @@ -63,26 +63,28 @@ public class GeneratedVersionOperationBuild extends Project { publishOperation() .repositories(version.isSnapshot() ? repository("rife2-snapshot") : repository("rife2")) - .repository(repository("github")) .info() .groupId("com.uwyn.rife2") .artifactId("bld-generated-version") .description("bld Extension to Generate Project Version Data") .url("https://github.com/rife2/generated-version") - .developer(new PublishDeveloper() - .id("ethauvin") - .name("Erik C. Thauvin") - .email("erik@thauvin.net") - .url("https://erik.thauvin.net/") + .developer( + new PublishDeveloper() + .id("ethauvin") + .name("Erik C. Thauvin") + .email("erik@thauvin.net") + .url("https://erik.thauvin.net/") ) - .license(new PublishLicense() - .name("The Apache License, Version 2.0") - .url("https://www.apache.org/licenses/LICENSE-2.0.txt") + .license( + new PublishLicense() + .name("The Apache License, Version 2.0") + .url("https://www.apache.org/licenses/LICENSE-2.0.txt") ) - .scm(new PublishScm() - .connection("scm:git:https://github.com/rife2/generated-version.git") - .developerConnection("scm:git:git@github.com:rife2/generated-version.git") - .url("https://github.com/rife2/generated-version") + .scm( + new PublishScm() + .connection("scm:git:https://github.com/rife2/generated-version.git") + .developerConnection("scm:git:git@github.com:rife2/generated-version.git") + .url("https://github.com/rife2/generated-version") ) .signKey(property("sign.key")) .signPassphrase(property("sign.passphrase")); diff --git a/src/main/java/rife/bld/extension/GeneratedVersion.java b/src/main/java/rife/bld/extension/GeneratedVersion.java index 9ae40fb..c7f4bc1 100644 --- a/src/main/java/rife/bld/extension/GeneratedVersion.java +++ b/src/main/java/rife/bld/extension/GeneratedVersion.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2025 the original author or authors. + * Copyright 2023-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/java/rife/bld/extension/GeneratedVersionOperation.java b/src/main/java/rife/bld/extension/GeneratedVersionOperation.java index 6a5e065..8968413 100644 --- a/src/main/java/rife/bld/extension/GeneratedVersionOperation.java +++ b/src/main/java/rife/bld/extension/GeneratedVersionOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2025 the original author or authors. + * Copyright 2023-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/java/rife/bld/extension/GeneratedVersionTest.java b/src/test/java/rife/bld/extension/GeneratedVersionTest.java index 32e3508..d4334ff 100644 --- a/src/test/java/rife/bld/extension/GeneratedVersionTest.java +++ b/src/test/java/rife/bld/extension/GeneratedVersionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023-2025 the original author or authors. + * Copyright 2023-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ package rife.bld.extension; -import org.assertj.core.api.AutoCloseableSoftAssertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import rife.bld.BaseProject; @@ -71,30 +70,6 @@ class GeneratedVersionTest { logger.setUseParentHandlers(false); } - /** - * Compares two strings by removing all line separators and whitespace. - * - * @param text1 The first text to compare - * @param text2 The second text to compare - * @return true if the texts are equivalent when line separators are ignored, false otherwise - */ - static boolean compareTextIgnoringLineSeparators(String text1, String text2) { - // Handle null cases - if (text1 == null && text2 == null) { - return true; - } - if (text1 == null || text2 == null) { - return false; - } - - // Remove all line separators and whitespace - var cleanedText1 = text1.replaceAll("\\r?\\n|\\r|\\s", ""); - var cleanedText2 = text2.replaceAll("\\r?\\n|\\r|\\s", ""); - - // Compare the cleaned strings - return cleanedText1.equals(cleanedText2); - } - static void deleteOnExit(File folder) { folder.deleteOnExit(); for (var f : Objects.requireNonNull(folder.listFiles())) { @@ -116,22 +91,21 @@ class GeneratedVersionTest { gv.setClassName("MyVersion"); var t = gv.buildTemplate(); - var v = gv.getProject().version(); - assertThat(v).extracting("majorInt", "minorInt", "revisionInt").as("version") - .containsExactly(2, 1, 3); - assertThat(compareTextIgnoringLineSeparators(t.getContent(), - String.format("package %s;" + - "public final class %s {" + - " public static final int PROJECT = \"%s\";" + - " public static final int MAJOR = %d;" + - " public static final int MINOR = %d;" + - " public static final int REVISION = %d;" + - " public static final String QUALIFIER = \"\";" + - " private MyVersion() {" + - " // no-op" + - " }" + - "}", gv.getPackageName(), gv.getClassName(), gv.getProjectName(), v.majorInt(), - v.minorInt(), v.revisionInt()))).as("template").isTrue(); + assertThat(t.getContent()).isEqualTo(""" + package com.example.my; + + public final class MyVersion { + public static final int PROJECT = "My App"; + public static final int MAJOR = 2; + public static final int MINOR = 1; + public static final int REVISION = 3; + public static final String QUALIFIER = ""; + + private MyVersion() { + // no-op + } + } + """); } @Test @@ -142,11 +116,9 @@ class GeneratedVersionTest { var t = gv.buildTemplate(); assertThat(t).isNotNull(); - try (var softly = new AutoCloseableSoftAssertions()) { - softly.assertThat(gv.getProject()).isEqualTo(PROJECT); - softly.assertThat(gv.getPackageName()).isEqualTo(PROJECT.pkg()); - softly.assertThat(gv.getProjectName()).isEqualTo(PROJECT.name()); - } + assertThat(gv.getProject()).isEqualTo(PROJECT); + assertThat(gv.getPackageName()).isEqualTo(PROJECT.pkg()); + assertThat(gv.getProjectName()).isEqualTo(PROJECT.name()); assertThat(t.getContent()).contains("package com.example;").contains("class GeneratedVersion") .contains("PROJECT = \"MyExample\";").contains("MAJOR = 2").contains("MINOR = 1") @@ -175,7 +147,7 @@ class GeneratedVersionTest { tmpDir.deleteOnExit(); new GeneratedVersionOperation() - .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", "Example", "Example")) + .fromProject(new BaseProjectBlueprint(new File("examples"), "com.example", "Example")) .directory(tmpDir.getAbsolutePath()) //.classTemplate(new File("examples", "my_app_version.txt")) .classTemplate(new File("examples", "version.txt")) @@ -229,15 +201,13 @@ class GeneratedVersionTest { gv.setDirectory(new File("build")); gv.setExtension(".java"); - try (var softly = new AutoCloseableSoftAssertions()) { - softly.assertThat(gv.getProject()).as("project").isEqualTo(PROJECT); - softly.assertThat(gv.getTemplate()).as("template").exists(); - softly.assertThat(gv.getPackageName()).as("package name").isEqualTo("com.example.cool"); - softly.assertThat(gv.getProjectName()).as("project name").isEqualTo("Cool App"); - softly.assertThat(gv.getClassName()).as("class name").isEqualTo("CoolVersion"); - softly.assertThat(gv.getExtension()).as("extension").isEqualTo(".java"); - softly.assertThat(gv.getDirectory()).as("directory").isDirectory(); - } + assertThat(gv.getProject()).as("project").isEqualTo(PROJECT); + assertThat(gv.getTemplate()).as("template").exists(); + assertThat(gv.getPackageName()).as("package name").isEqualTo("com.example.cool"); + assertThat(gv.getProjectName()).as("project name").isEqualTo("Cool App"); + assertThat(gv.getClassName()).as("class name").isEqualTo("CoolVersion"); + assertThat(gv.getExtension()).as("extension").isEqualTo(".java"); + assertThat(gv.getDirectory()).as("directory").isDirectory(); } @Test