Skip to content

Commit 07a3584

Browse files
committed
Merge branch 'master' into issue813
2 parents 5539722 + b5b9f63 commit 07a3584

File tree

3 files changed

+114
-54
lines changed

3 files changed

+114
-54
lines changed

.github/workflows/deployment.yml

Lines changed: 69 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,72 @@ on:
1111
types: [published]
1212

1313
jobs:
14-
publish:
15-
runs-on: ubuntu-latest
16-
permissions:
17-
contents: read
18-
packages: write
19-
steps:
20-
- uses: actions/checkout@v4
21-
- name: Set up Java for publishing to Maven Central Repository
22-
uses: actions/setup-java@v3
23-
with:
24-
# Use lowest supported LTS Java version
25-
java-version: '8'
26-
distribution: 'temurin'
27-
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
28-
server-username: MAVEN_USERNAME # env variable for username in deploy
29-
server-password: MAVEN_PASSWORD # env variable for token in deploy
30-
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
31-
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
32-
33-
- name: Publish to the Maven Central Repository
34-
run: mvn --batch-mode deploy
35-
env:
36-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
37-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
38-
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
39-
# - name: Set up Java for publishing to GitHub Packages
40-
# uses: actions/setup-java@v3
41-
# with:
42-
# # Use lowest supported LTS Java version
43-
# java-version: '8'
44-
# distribution: 'temurin'
45-
# - name: Publish to GitHub Packages
46-
# run: mvn --batch-mode deploy
47-
# env:
48-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
# old-school build and jar method. No tests run or compiled.
15+
publish-1_6:
16+
name: Publish Java 1.6 to GitHub Release
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Setup java
23+
uses: actions/setup-java@v1
24+
with:
25+
java-version: 1.6
26+
- name: Compile Java 1.6
27+
run: |
28+
mkdir -p target/classes
29+
javac -version
30+
javac -source 1.6 -target 1.6 -d target/classes/ src/main/java/org/json/*.java
31+
- name: Create JAR 1.6
32+
run: |
33+
jar cvf "target/org.json-1.6-${{ github.ref_name }}.jar" -C target/classes .
34+
- name: Add 1.6 Jar To Release
35+
uses: softprops/action-gh-release@v1
36+
with:
37+
append_body: true
38+
files: |
39+
target/*.jar
40+
publish:
41+
name: Publish Java 8 to Maven Central and GitHub Release
42+
runs-on: ubuntu-latest
43+
permissions:
44+
contents: write
45+
packages: write
46+
steps:
47+
- uses: actions/checkout@v4
48+
- name: Set up Java for publishing to Maven Central Repository
49+
uses: actions/setup-java@v3
50+
with:
51+
# Use lowest supported LTS Java version
52+
java-version: '8'
53+
distribution: 'temurin'
54+
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
55+
server-username: MAVEN_USERNAME # env variable for username in deploy
56+
server-password: MAVEN_PASSWORD # env variable for token in deploy
57+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
58+
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
59+
60+
- name: Publish to the Maven Central Repository
61+
run: mvn --batch-mode deploy
62+
env:
63+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
64+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
65+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
66+
67+
- name: Add Jar To Release
68+
uses: softprops/action-gh-release@v1
69+
with:
70+
append_body: true
71+
files: |
72+
target/*.jar
73+
# - name: Set up Java for publishing to GitHub Packages
74+
# uses: actions/setup-java@v3
75+
# with:
76+
# # Use lowest supported LTS Java version
77+
# java-version: '8'
78+
# distribution: 'temurin'
79+
# - name: Publish to GitHub Packages
80+
# run: mvn --batch-mode deploy
81+
# env:
82+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pipeline.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,35 @@ on:
1010
branches: [ master ]
1111

1212
jobs:
13+
# old-school build and jar method. No tests run or compiled.
14+
build-1_6:
15+
name: Java 1.6
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Setup java
20+
uses: actions/setup-java@v1
21+
with:
22+
java-version: 1.6
23+
- name: Compile Java 1.6
24+
run: |
25+
mkdir -p target/classes
26+
javac -version
27+
javac -source 1.6 -target 1.6 -d target/classes/ src/main/java/org/json/*.java
28+
- name: Create java 1.6 JAR
29+
run: |
30+
jar cvf target/org.json.jar -C target/classes .
31+
- name: Upload JAR 1.6
32+
if: ${{ always() }}
33+
uses: actions/upload-artifact@v3
34+
with:
35+
name: Create java 1.6 JAR
36+
path: target/*.jar
1337
build:
1438
runs-on: ubuntu-latest
1539
strategy:
40+
fail-fast: false
41+
max-parallel: 2
1642
matrix:
1743
# build against supported Java LTS versions:
1844
java: [ 8, 11, 17, 21 ]
@@ -26,15 +52,15 @@ jobs:
2652
java-version: ${{ matrix.java }}
2753
cache: 'maven'
2854
- name: Compile Java ${{ matrix.java }}
29-
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
55+
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
3056
- name: Run Tests ${{ matrix.java }}
3157
run: |
32-
mvn test -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.target=${{ matrix.java }}
58+
mvn test -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
3359
- name: Build Test Report ${{ matrix.java }}
3460
if: ${{ always() }}
3561
run: |
36-
mvn surefire-report:report-only -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.target=${{ matrix.java }}
37-
mvn site -DgenerateReports=false -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.target=${{ matrix.java }}
62+
mvn surefire-report:report-only -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
63+
mvn site -D generateReports=false -D maven.compiler.source=${{ matrix.java }} -D maven.compiler.target=${{ matrix.java }}
3864
- name: Upload Test Results ${{ matrix.java }}
3965
if: ${{ always() }}
4066
uses: actions/upload-artifact@v3
@@ -48,7 +74,7 @@ jobs:
4874
name: Test Report ${{ matrix.java }}
4975
path: target/site/
5076
- name: Package Jar ${{ matrix.java }}
51-
run: mvn clean package -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.target=${{ matrix.java }} -Dmaven.test.skip=true -Dmaven.site.skip=true
77+
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
5278
- name: Upload Package Results ${{ matrix.java }}
5379
if: ${{ always() }}
5480
uses: actions/upload-artifact@v3

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,56 +44,56 @@ The org.json package can be built from the command line, Maven, and Gradle. The
4444
**Building from the command line**
4545

4646
*Build the class files from the package root directory src/main/java*
47-
````
47+
```shell
4848
javac org/json/*.java
49-
````
49+
```
5050

5151
*Create the jar file in the current directory*
52-
````
52+
```shell
5353
jar cf json-java.jar org/json/*.class
54-
````
54+
```
5555

5656
*Compile a program that uses the jar (see example code below)*
57-
````
57+
```shell
5858
javac -cp .;json-java.jar Test.java (Windows)
5959
javac -cp .:json-java.jar Test.java (Unix Systems)
60-
````
60+
```
6161

6262
*Test file contents*
6363

64-
````
64+
```java
6565
import org.json.JSONObject;
6666
public class Test {
6767
public static void main(String args[]){
6868
JSONObject jo = new JSONObject("{ \"abc\" : \"def\" }");
6969
System.out.println(jo.toString());
7070
}
7171
}
72-
````
72+
```
7373

7474
*Execute the Test file*
75-
````
75+
```shell
7676
java -cp .;json-java.jar Test (Windows)
7777
java -cp .:json-java.jar Test (Unix Systems)
78-
````
78+
```
7979

8080
*Expected output*
8181

82-
````
82+
```json
8383
{"abc":"def"}
84-
````
84+
```
8585

8686

8787
**Tools to build the package and execute the unit tests**
8888

8989
Execute the test suite with Maven:
90-
```
90+
```shell
9191
mvn clean test
9292
```
9393

9494
Execute the test suite with Gradlew:
9595

96-
```
96+
```shell
9797
gradlew clean build test
9898
```
9999

0 commit comments

Comments
 (0)