From 6007165c17f349b81787657d104c967ef5dcc9ae Mon Sep 17 00:00:00 2001 From: Yeikel Date: Sat, 21 Oct 2023 00:10:42 -0400 Subject: [PATCH 1/4] docs: use syntax highlighting use syntax highlighting to improve the format of the readme --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 5f1f5b0..1db1f54 100644 --- a/README.md +++ b/README.md @@ -44,24 +44,24 @@ The org.json package can be built from the command line, Maven, and Gradle. The **Building from the command line** *Build the class files from the package root directory src/main/java* -```` +```shell javac org/json/*.java -```` +``` *Create the jar file in the current directory* -```` +```shell jar cf json-java.jar org/json/*.class -```` +``` *Compile a program that uses the jar (see example code below)* -```` +```shell javac -cp .;json-java.jar Test.java (Windows) javac -cp .:json-java.jar Test.java (Unix Systems) -```` +``` *Test file contents* -```` +```java import org.json.JSONObject; public class Test { public static void main(String args[]){ @@ -69,31 +69,31 @@ public class Test { System.out.println(jo.toString()); } } -```` +``` *Execute the Test file* -```` +```shell java -cp .;json-java.jar Test (Windows) java -cp .:json-java.jar Test (Unix Systems) -```` +``` *Expected output* -```` +```json {"abc":"def"} -```` +``` **Tools to build the package and execute the unit tests** Execute the test suite with Maven: -``` +```shell mvn clean test ``` Execute the test suite with Gradlew: -``` +```shell gradlew clean build test ``` From 1ab11d08024f9d815772811c3ebdd110ad228ce8 Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Mon, 23 Oct 2023 14:50:21 -0400 Subject: [PATCH 2/4] ensure java 6 compatable --- .github/workflows/pipeline.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index a66ae7b..39d23e2 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -10,6 +10,34 @@ on: branches: [ master ] jobs: + # old-school build and jar method. No tests run or compiled. + build-1_6: + runs-on: ubuntu-latest + strategy: + matrix: + # build for java 1.6, however don't run any tests + java: [ 1.6 ] + name: Java ${{ matrix.java }} + steps: + - uses: actions/checkout@v3 + - name: Setup java + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: Compile Java ${{ matrix.java }} + run: | + mkdir -p target/classes + javac -version + javac -d target/classes/ src/main/java/org/json/*.java + - name: Create java ${{ matrix.java }} JAR + run: | + jar cvf target/org.json.jar -C target/classes . + - name: Upload JAR ${{ matrix.java }} + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: Create java ${{ matrix.java }} JAR + path: target/*.jar build: runs-on: ubuntu-latest strategy: From a2a8240d0d83836c509dd59d060d7d08b0429a3c Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Mon, 23 Oct 2023 16:18:23 -0400 Subject: [PATCH 3/4] upload jar files to GitHub release --- .github/workflows/deployment.yml | 104 ++++++++++++++++++++----------- .github/workflows/pipeline.yml | 4 +- 2 files changed, 72 insertions(+), 36 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 54457d9..809c4a0 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -11,38 +11,72 @@ on: types: [published] jobs: - publish: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v4 - - name: Set up Java for publishing to Maven Central Repository - uses: actions/setup-java@v3 - with: - # Use lowest supported LTS Java version - java-version: '8' - distribution: 'temurin' - server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml - server-username: MAVEN_USERNAME # env variable for username in deploy - server-password: MAVEN_PASSWORD # env variable for token in deploy - gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import - gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase - - - name: Publish to the Maven Central Repository - run: mvn --batch-mode deploy - env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} - # - name: Set up Java for publishing to GitHub Packages - # uses: actions/setup-java@v3 - # with: - # # Use lowest supported LTS Java version - # java-version: '8' - # distribution: 'temurin' - # - name: Publish to GitHub Packages - # run: mvn --batch-mode deploy - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # old-school build and jar method. No tests run or compiled. + publish-1_6: + name: Publish Java 1.6 to GitHub Release + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Setup java + uses: actions/setup-java@v1 + with: + java-version: 1.6 + - name: Compile Java 1.6 + run: | + mkdir -p target/classes + javac -version + javac -d target/classes/ src/main/java/org/json/*.java + - name: Create JAR 1.6 + run: | + jar cvf "target/org.json-1.6-${{ github.ref_name }}.jar" -C target/classes . + - name: Add 1.6 Jar To Release + uses: softprops/action-gh-release@v1 + with: + append_body: true + files: | + target/*.jar + publish: + name: Publish Java 8 to Maven Central and GitHub Release + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + steps: + - uses: actions/checkout@v4 + - name: Set up Java for publishing to Maven Central Repository + uses: actions/setup-java@v3 + with: + # Use lowest supported LTS Java version + java-version: '8' + distribution: 'temurin' + server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml + server-username: MAVEN_USERNAME # env variable for username in deploy + server-password: MAVEN_PASSWORD # env variable for token in deploy + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import + gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase + + - name: Publish to the Maven Central Repository + run: mvn --batch-mode deploy + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + + - name: Add Jar To Release + uses: softprops/action-gh-release@v1 + with: + append_body: true + files: | + target/*.jar + # - name: Set up Java for publishing to GitHub Packages + # uses: actions/setup-java@v3 + # with: + # # Use lowest supported LTS Java version + # java-version: '8' + # distribution: 'temurin' + # - name: Publish to GitHub Packages + # run: mvn --batch-mode deploy + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 39d23e2..b5b5f3f 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -19,7 +19,7 @@ jobs: java: [ 1.6 ] name: Java ${{ matrix.java }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup java uses: actions/setup-java@v1 with: @@ -41,6 +41,8 @@ jobs: build: runs-on: ubuntu-latest strategy: + fail-fast: false + max-parallel: 2 matrix: # build against supported Java LTS versions: java: [ 8, 11, 17, 21 ] From ea842b437cf552de8394bd843e40cf12f92a0c94 Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Mon, 23 Oct 2023 17:11:55 -0400 Subject: [PATCH 4/4] remove unneeded matrix build typ for java 1.6 --- .github/workflows/deployment.yml | 2 +- .github/workflows/pipeline.yml | 28 ++++++++++++---------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 809c4a0..e870644 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -27,7 +27,7 @@ jobs: run: | mkdir -p target/classes javac -version - javac -d target/classes/ src/main/java/org/json/*.java + javac -source 1.6 -target 1.6 -d target/classes/ src/main/java/org/json/*.java - name: Create JAR 1.6 run: | jar cvf "target/org.json-1.6-${{ github.ref_name }}.jar" -C target/classes . diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index b5b5f3f..63540cc 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -12,31 +12,27 @@ on: jobs: # old-school build and jar method. No tests run or compiled. build-1_6: + name: Java 1.6 runs-on: ubuntu-latest - strategy: - matrix: - # build for java 1.6, however don't run any tests - java: [ 1.6 ] - name: Java ${{ matrix.java }} steps: - uses: actions/checkout@v4 - name: Setup java uses: actions/setup-java@v1 with: - java-version: ${{ matrix.java }} - - name: Compile Java ${{ matrix.java }} + java-version: 1.6 + - name: Compile Java 1.6 run: | mkdir -p target/classes javac -version - javac -d target/classes/ src/main/java/org/json/*.java - - name: Create java ${{ matrix.java }} JAR + javac -source 1.6 -target 1.6 -d target/classes/ src/main/java/org/json/*.java + - name: Create java 1.6 JAR run: | jar cvf target/org.json.jar -C target/classes . - - name: Upload JAR ${{ matrix.java }} + - name: Upload JAR 1.6 if: ${{ always() }} uses: actions/upload-artifact@v3 with: - name: Create java ${{ matrix.java }} JAR + name: Create java 1.6 JAR path: target/*.jar build: runs-on: ubuntu-latest @@ -56,15 +52,15 @@ jobs: java-version: ${{ matrix.java }} cache: 'maven' - name: Compile Java ${{ matrix.java }} - run: mvn clean compile -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.target=${{ matrix.java }} -Dmaven.test.skip=true -Dmaven.site.skip=true -Dmaven.javadoc.skip=true + run: mvn clean compile -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} -D maven.test.skip=true -D maven.site.skip=true -D maven.javadoc.skip=true - name: Run Tests ${{ matrix.java }} run: | - mvn test -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.target=${{ matrix.java }} + mvn test -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} - name: Build Test Report ${{ matrix.java }} if: ${{ always() }} run: | - mvn surefire-report:report-only -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.target=${{ matrix.java }} - mvn site -DgenerateReports=false -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.target=${{ matrix.java }} + mvn surefire-report:report-only -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} + mvn site -D generateReports=false -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} - name: Upload Test Results ${{ matrix.java }} if: ${{ always() }} uses: actions/upload-artifact@v3 @@ -78,7 +74,7 @@ jobs: name: Test Report ${{ matrix.java }} path: target/site/ - name: Package Jar ${{ matrix.java }} - run: mvn clean package -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.target=${{ matrix.java }} -Dmaven.test.skip=true -Dmaven.site.skip=true + run: mvn clean package -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }} -D maven.test.skip=true -D maven.site.skip=true - name: Upload Package Results ${{ matrix.java }} if: ${{ always() }} uses: actions/upload-artifact@v3