Skip to content

Commit ca23507

Browse files
committed
Merge branch '4.X' of github.com:yuzawa-san/iabgpp-java into 4.X-subsection-headers
2 parents afe99f8 + b6fdb1e commit ca23507

15 files changed

Lines changed: 291 additions & 40 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
1-
name: IABGPP-Java Release
1+
# Release to Maven Central via Central Publisher Portal
2+
# https://central.sonatype.org/publish/publish-portal-guide/
3+
#
4+
# Required GitHub secrets (Settings → Secrets and variables → Actions):
5+
# CENTRAL_TOKEN_USERNAME - Portal token username (from https://central.sonatype.com/usertoken)
6+
# CENTRAL_TOKEN_PASSWORD - Portal token password (from same page; save on first view, cannot be retrieved later)
7+
# GPG_SECRET_KEY - Armored GPG private key for signing
8+
# GPG_PASSPHRASE - Passphrase for the GPG key
9+
# PAT - Personal access token with repo scope (for pushing commits/tags)
10+
#
11+
name: IABGPP-Java 4.X Release
212

313
on:
414
workflow_dispatch:
515
inputs:
616
version:
7-
description: 'The release version (e.g., 3.x.x)'
17+
description: 'The release version (e.g., 4.x.x)'
818
required: true
919
default: ''
1020

@@ -14,15 +24,15 @@ jobs:
1424
steps:
1525
# Checkout the repository with full history for tagging
1626
- name: Checkout repository
17-
uses: actions/checkout@v2
27+
uses: actions/checkout@v4
1828
with:
1929
fetch-depth: 0
2030

21-
# Set up Java (assuming Java 11, adjust if different)
31+
# Set up Java
2232
- name: Set up Java
23-
uses: actions/setup-java@v2
33+
uses: actions/setup-java@v4
2434
with:
25-
distribution: 'adopt'
35+
distribution: 'temurin'
2636
java-version: '21'
2737

2838
# Import GPG secret key for signing
@@ -31,35 +41,44 @@ jobs:
3141
echo "${{ secrets.GPG_SECRET_KEY }}" > secret_key.asc
3242
gpg --import --no-tty --batch secret_key.asc || { echo "GPG import failed"; cat secret_key.asc; exit 1; }
3343
rm -f secret_key.asc
34-
# gpg --list-secret-keys
3544
36-
37-
# Generate settings.xml with Maven repository credentials
45+
# Generate settings.xml with Central Publisher Portal token credentials
46+
# Token from: https://central.sonatype.com/usertoken
3847
- name: Create settings.xml
48+
env:
49+
CENTRAL_TOKEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
50+
CENTRAL_TOKEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
3951
run: |
4052
mkdir -p ~/.m2
4153
cat > ~/.m2/settings.xml << EOF
42-
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
43-
<localRepository>~/.m2</localRepository> <interactiveMode>false</interactiveMode> <offline>false</offline><pluginGroups> <pluginGroup>org.sonatype.plugins</pluginGroup> </pluginGroups> <servers> <server> <id>sonatype-nexus-snapshots</id> <username>TiW/t45q</username> <password>${{ secrets.SONATYPE_PWD }}</password> </server> <server> <id>sonatype-nexus-staging</id> <username>TiW/t45q</username> <password>${{ secrets.SONATYPE_PWD_STAGING }}</password> </server> </servers>
54+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
55+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
56+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
57+
<servers>
58+
<server>
59+
<id>central</id>
60+
<username>${CENTRAL_TOKEN_USERNAME}</username>
61+
<password>${CENTRAL_TOKEN_PASSWORD}</password>
62+
</server>
63+
</servers>
4464
</settings>
4565
EOF
4666
4767
# Pull latest changes from master
4868
- name: Pull latest changes
49-
run: git pull origin master
69+
run: git pull origin 4.X
5070

5171
# Set the release version in pom.xml
5272
- name: Set release version
5373
run: mvn versions:set -DnewVersion=${{ github.event.inputs.version }} -DgenerateBackupPoms=false
5474

55-
# Build and deploy the release
75+
# Build and deploy to Central Publisher Portal (mvn deploy uploads bundle and publishes)
5676
- name: Deploy release
5777
run: |
5878
echo "pinentry-mode loopback" > ~/.gnupg/gpg.conf
5979
echo "use-agent" >> ~/.gnupg/gpg.conf
6080
export GPG_TTY=$(tty || echo /dev/tty)
6181
mvn clean deploy --settings ~/.m2/settings.xml -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" -Prelease
62-
# mvn clean deploy --settings ~/.m2/settings.xml -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" -Prelease -Dmaven.javadoc.skip=true
6382
6483
# Commit the release version and create a tag
6584
- name: Commit and tag release
@@ -80,12 +99,11 @@ jobs:
8099
NEW_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
81100
git add .
82101
git commit -m "$NEW_VERSION"
83-
# git commit -m "${{ github.event.inputs.version }}-SNAPSHOT"
84102
85103
# Push commits and tags to GitHub
86104
- name: Push changes
87105
run: |
88106
git status
89107
git push; git push --tags
90108
env:
91-
GITHUB_TOKEN: ${{secrets.PAT}}
109+
GITHUB_TOKEN: ${{ secrets.PAT }}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Release to Maven Central via Central Publisher Portal
2+
# https://central.sonatype.org/publish/publish-portal-guide/
3+
#
4+
# Required GitHub secrets (Settings → Secrets and variables → Actions):
5+
# CENTRAL_TOKEN_USERNAME - Portal token username (from https://central.sonatype.com/usertoken)
6+
# CENTRAL_TOKEN_PASSWORD - Portal token password (from same page; save on first view, cannot be retrieved later)
7+
# GPG_SECRET_KEY - Armored GPG private key for signing
8+
# GPG_PASSPHRASE - Passphrase for the GPG key
9+
# PAT - Personal access token with repo scope (for pushing commits/tags)
10+
#
11+
name: IABGPP-Java 4.X Release
12+
13+
on:
14+
workflow_dispatch:
15+
inputs:
16+
version:
17+
description: 'The release version (e.g., 4.x.x)'
18+
required: true
19+
default: ''
20+
21+
jobs:
22+
release:
23+
runs-on: ubuntu-latest
24+
steps:
25+
# Checkout the repository with full history for tagging
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
# Set up Java
32+
- name: Set up Java
33+
uses: actions/setup-java@v4
34+
with:
35+
distribution: 'temurin'
36+
java-version: '21'
37+
38+
# Import GPG secret key for signing
39+
- name: Import GPG key
40+
run: |
41+
echo "${{ secrets.GPG_SECRET_KEY }}" > secret_key.asc
42+
gpg --import --no-tty --batch secret_key.asc || { echo "GPG import failed"; cat secret_key.asc; exit 1; }
43+
rm -f secret_key.asc
44+
45+
# Generate settings.xml with Central Publisher Portal token credentials
46+
# Token from: https://central.sonatype.com/usertoken
47+
- name: Create settings.xml
48+
env:
49+
CENTRAL_TOKEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
50+
CENTRAL_TOKEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
51+
run: |
52+
mkdir -p ~/.m2
53+
cat > ~/.m2/settings.xml << EOF
54+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
55+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
56+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
57+
<servers>
58+
<server>
59+
<id>central</id>
60+
<username>${CENTRAL_TOKEN_USERNAME}</username>
61+
<password>${CENTRAL_TOKEN_PASSWORD}</password>
62+
</server>
63+
</servers>
64+
</settings>
65+
EOF
66+
67+
# Pull latest changes from master
68+
- name: Pull latest changes
69+
run: git pull origin 4.X
70+
71+
# Set the release version in pom.xml
72+
- name: Set release version
73+
run: mvn versions:set -DnewVersion=${{ github.event.inputs.version }} -DgenerateBackupPoms=false
74+
75+
# Build and deploy to Central Publisher Portal (mvn deploy uploads bundle and publishes)
76+
- name: Deploy release
77+
run: |
78+
echo "pinentry-mode loopback" > ~/.gnupg/gpg.conf
79+
echo "use-agent" >> ~/.gnupg/gpg.conf
80+
export GPG_TTY=$(tty || echo /dev/tty)
81+
mvn clean deploy --settings ~/.m2/settings.xml -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" -Prelease
82+
83+
# Commit the release version and create a tag
84+
- name: Commit and tag release
85+
run: |
86+
git config user.email "mayank@iabtechlab.com"
87+
git config user.name "Mayank Mishra"
88+
git add .
89+
git commit -m "${{ github.event.inputs.version }}"
90+
git tag "${{ github.event.inputs.version }}"
91+
92+
# Set the next snapshot version
93+
- name: Set next snapshot version
94+
run: mvn versions:set -DnextSnapshot=true -DgenerateBackupPoms=false
95+
96+
# Commit the snapshot version
97+
- name: Commit snapshot version
98+
run: |
99+
NEW_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
100+
git add .
101+
git commit -m "$NEW_VERSION"
102+
103+
# Push commits and tags to GitHub
104+
- name: Push changes
105+
run: |
106+
git status
107+
git push; git push --tags
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.PAT }}

iabgpp-encoder/pom.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
<parent>
88
<groupId>com.iabgpp</groupId>
99
<artifactId>iabgpp-core</artifactId>
10-
<version>4.0.0-SNAPSHOT</version>
10+
<version>4.0.1-RC1</version>
1111
</parent>
1212

1313
<artifactId>iabgpp-encoder</artifactId>
14+
<name>IAB GPP Encoder</name>
1415
<packaging>jar</packaging>
1516

1617
<dependencies>
@@ -51,6 +52,14 @@
5152
<id>release</id>
5253
<build>
5354
<plugins>
55+
<plugin>
56+
<groupId>org.apache.maven.plugins</groupId>
57+
<artifactId>maven-source-plugin</artifactId>
58+
</plugin>
59+
<plugin>
60+
<groupId>org.apache.maven.plugins</groupId>
61+
<artifactId>maven-javadoc-plugin</artifactId>
62+
</plugin>
5463
<plugin>
5564
<groupId>org.apache.maven.plugins</groupId>
5665
<artifactId>maven-gpg-plugin</artifactId>

iabgpp-encoder/src/main/java/com/iab/gpp/encoder/GppModel.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
public class GppModel extends AbstractEncodable {
4242

43-
// NOTE: we genrally use concrete types to avoid the cost of interface calls
43+
// NOTE: we generally use concrete types to avoid the cost of interface calls
4444
private static final HashMap<Integer, Supplier<EncodableSection<?>>> SECTION_ID_TO_CONSTRUCTOR =
4545
new HashMap<>();
4646
private static final HashMap<String, Integer> SECTION_NAME_TO_ID = new HashMap<>();
@@ -307,13 +307,13 @@ protected CharSequence doEncode() {
307307

308308
@Override
309309
protected void doDecode(CharSequence str) {
310-
if (str == null || str.isEmpty() || (str.charAt(0) == 'D' && str.charAt(1) == 'B')) {
310+
if (str == null || str.length() == 0 || (str.charAt(0) == 'D' && str.charAt(1) == 'B')) {
311311
if (!sections.isEmpty()) {
312312
sections.clear();
313313
header.getSectionsIds().clear();
314314
}
315315

316-
if (str != null && !str.isEmpty()) {
316+
if (str != null && str.length() != 0) {
317317
List<CharSequence> encodedSections = SlicedCharSequence.split(str, '~');
318318
header.decode(encodedSections.get(0));
319319

@@ -397,7 +397,7 @@ public void setDirty(boolean dirty) {
397397
for (Integer sectionId : header.getSectionsIds()) {
398398
EncodableSection<?> section = sections.get(sectionId);
399399
if (section != null) {
400-
section.setDirty(true);
400+
section.setDirty(dirty);
401401
}
402402
}
403403
}

iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/IntegerSet.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ public boolean isEmpty() {
7373
}
7474

7575
public boolean containsInt(int value) {
76+
if (value < adjustment) {
77+
return false;
78+
}
7679
int offset = getOffset(value);
7780
return offset < to && bitSet.get(offset);
7881
}

iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/RangeEntry.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,9 @@ public void setDirty(boolean dirty) {
6262
this.dirty = dirty;
6363
ids.setDirty(dirty);
6464
}
65+
66+
@Override
67+
public String toString() {
68+
return "{key=" + key + ", type=" + type + ", ids=" + ids + "}";
69+
}
6570
}

iabgpp-encoder/src/main/java/com/iab/gpp/encoder/section/EncodableSection.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ public final String toString() {
174174
.append(getVersion());
175175
int numSegments = size();
176176
for (int i = 0; i < numSegments; i++) {
177-
sb.append(", ").append(getSegment(i).toString());
177+
EncodableSegment<E> segment = getSegment(i);
178+
String segmentInfo = segment.toString();
179+
if (segment.shouldEncode()) {
180+
sb.append(", ").append(segmentInfo);
181+
}
178182
}
179183
sb.append('}');
180184
return sb.toString();

iabgpp-encoder/src/main/java/com/iab/gpp/encoder/section/SlicedCharSequence.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ public static List<CharSequence> split(CharSequence charSequence, char splitter)
3838
}
3939
List<CharSequence> out = null;
4040
int next = 0;
41-
while ((next = base.indexOf(splitter, start, end)) != -1) {
41+
// TODO: use base.indexOf(splitter, start, end) if the JDK baseline is set to above 21
42+
while ((next = base.indexOf(splitter, start)) != -1) {
43+
if (next >= end) {
44+
break;
45+
}
4246
if (out == null) {
4347
// most sections/segments have less than 4 components
4448
out = new ArrayList<>(4);

iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/AbstractLazilyEncodableSegment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public final boolean hasField(E key) {
4545
@Override
4646
public final boolean isDirty() {
4747
if (dirty) {
48-
return dirty;
48+
return true;
4949
}
5050
int size = fieldNames.size();
5151
for (int i = 0; i < size; i++) {

iabgpp-encoder/src/test/java/com/iab/gpp/encoder/GppModelTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ public void testDecode4() {
788788
@Test
789789
public void testDecode5() {
790790
GppModel gppModel = new GppModel("DBABLA~BVQqAAAAAgA.QA");
791+
Assertions.assertEquals("BVQqAAAAAgA.QA", gppModel.getUsNatSection().encode());
791792
gppModel.getFieldValue(UsNat.NAME, UsNatField.VERSION);
792793
}
793794

0 commit comments

Comments
 (0)