Skip to content

Commit 47605ca

Browse files
committed
Merge tag 'github-api-2.0-rc.2' into release/v2.x
github-api-2.0-rc.2
2 parents b6c4121 + 1b19295 commit 47605ca

File tree

109 files changed

+1193
-430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+1193
-430
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- [ ] Add JavaDocs and other comments explaining the behavior.
99
- [ ] When adding or updating methods that fetch entities, add `@link` JavaDoc entries to the relevant documentation on https://docs.github.com/en/rest .
1010
- [ ] Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
11-
- [ ] Run `mvn -D enable-ci clean install site` locally. If this command doesn't succeed, your change will not pass CI.
11+
- [ ] Run `mvn -D enable-ci clean install site "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"` locally. If this command doesn't succeed, your change will not pass CI.
1212
- [ ] Push your changes to a branch other than `main`. You will create your PR from that branch.
1313

1414
# When creating a PR:

.github/workflows/maven-build.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Maven Install (skipTests)
3636
env:
3737
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
38-
run: mvn -B clean install -DskipTests --file pom.xml
38+
run: mvn -B clean install -Djapicmp.skip=true -DskipTests --file pom.xml
3939
- uses: actions/upload-artifact@v4
4040
with:
4141
name: maven-target-directory
@@ -59,7 +59,27 @@ jobs:
5959
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
6060
# running install site seems to more closely imitate real site deployment,
6161
# more likely to prevent failed deployment
62-
run: mvn -B clean install site -DskipTests --file pom.xml
62+
run: mvn -B clean install site -Djapicmp.skip=true -DskipTests --file pom.xml
63+
test-bridged:
64+
name: build-and-test Bridged (Java 17)
65+
# Does not require build output, but orders execution to prevent launching test workflows when simple build fails
66+
needs: build
67+
runs-on: ubuntu-latest
68+
strategy:
69+
fail-fast: true
70+
steps:
71+
- uses: actions/checkout@v4
72+
- name: Set up JDK
73+
uses: actions/setup-java@v4
74+
with:
75+
java-version: 17
76+
distribution: 'temurin'
77+
cache: 'maven'
78+
- name: Maven Install (skipTests)
79+
env:
80+
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
81+
#skipping japicmp check for bridged artifact until after next release
82+
run: mvn -B clean install -Djapicmp.skip=true -Pbridged -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
6383
test:
6484
name: test (${{ matrix.os }}, Java ${{ matrix.java }})
6585
# Does not require build output, but orders execution to prevent launching test workflows when simple build fails
@@ -88,7 +108,8 @@ jobs:
88108
if: matrix.os != 'windows'
89109
env:
90110
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
91-
run: mvn -B clean install -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
111+
# Disable japicmp until next release
112+
run: mvn -B clean install -Djapicmp.skip=true -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED"
92113
- name: Save coverage data
93114
if: matrix.os == 'ubuntu' && matrix.java == '17'
94115
uses: actions/upload-artifact@v4

.github/workflows/publish_release_branch.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ jobs:
5656
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN_PASSWORD }}
5757
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSPHRASE }}
5858

59+
- name: Publish package with bridge methods
60+
run: mvn -B clean deploy -DskipTests -Prelease -Pbridged
61+
env:
62+
MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }}
63+
MAVEN_USERNAME: ${{ secrets.OSSRH_TOKEN_USERNAME }}
64+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN_PASSWORD }}
65+
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSPHRASE }}
66+
5967
publish_gh_pages:
6068
runs-on: ubuntu-latest
6169
needs: build

pom.xml

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.kohsuke</groupId>
5-
<artifactId>github-api</artifactId>
6-
<version>2.0-rc.1</version>
5+
<artifactId>${github-api.artifactId}</artifactId>
6+
<version>2.0-rc.2</version>
77
<name>GitHub API for Java</name>
88
<description>GitHub API for Java</description>
99
<url>https://hub4j.github.io/github-api/</url>
@@ -62,6 +62,7 @@
6262
</distributionManagement>
6363

6464
<properties>
65+
<github-api.artifactId>github-api</github-api.artifactId>
6566
<hamcrest.version>3.0</hamcrest.version>
6667
<!-- Using this as the minimum bar for code coverage. Adding methods without covering them will fail this. -->
6768
<jacoco.coverage.target.bundle.method>0.70</jacoco.coverage.target.bundle.method>
@@ -141,6 +142,10 @@
141142
<groupId>com.fasterxml.jackson.core</groupId>
142143
<artifactId>jackson-databind</artifactId>
143144
</dependency>
145+
<dependency>
146+
<groupId>com.fasterxml.jackson.datatype</groupId>
147+
<artifactId>jackson-datatype-jsr310</artifactId>
148+
</dependency>
144149
<dependency>
145150
<groupId>com.infradna.tool</groupId>
146151
<artifactId>bridge-method-annotation</artifactId>
@@ -214,7 +219,7 @@
214219
<dependency>
215220
<groupId>com.google.guava</groupId>
216221
<artifactId>guava</artifactId>
217-
<version>33.4.5-jre</version>
222+
<version>33.4.6-jre</version>
218223
<scope>test</scope>
219224
</dependency>
220225
<dependency>
@@ -302,6 +307,18 @@
302307
</testResources>
303308
<pluginManagement>
304309
<plugins>
310+
<plugin>
311+
<groupId>com.infradna.tool</groupId>
312+
<artifactId>bridge-method-injector</artifactId>
313+
<version>1.30</version>
314+
<executions>
315+
<execution>
316+
<goals>
317+
<goal>process</goal>
318+
</goals>
319+
</execution>
320+
</executions>
321+
</plugin>
305322
<plugin>
306323
<groupId>org.apache.maven.plugins</groupId>
307324
<artifactId>maven-gpg-plugin</artifactId>
@@ -324,13 +341,16 @@
324341
</configuration>
325342
</plugin>
326343
<plugin>
327-
<groupId>org.apache.maven.plugins</groupId>
344+
<artifactId>maven-resources-plugin</artifactId>
345+
<version>3.3.1</version>
346+
</plugin>
347+
<plugin>
328348
<artifactId>maven-source-plugin</artifactId>
329349
<version>3.3.1</version>
330350
</plugin>
331351
<plugin>
332352
<artifactId>maven-surefire-plugin</artifactId>
333-
<version>3.5.2</version>
353+
<version>3.5.3</version>
334354
<configuration>
335355
<!-- SUREFIRE-1226 workaround -->
336356
<trimStackTrace>false</trimStackTrace>
@@ -455,7 +475,7 @@
455475
<plugin>
456476
<groupId>com.diffplug.spotless</groupId>
457477
<artifactId>spotless-maven-plugin</artifactId>
458-
<version>2.44.2</version>
478+
<version>2.44.3</version>
459479
<configuration>
460480
<java>
461481
<includes>
@@ -511,7 +531,7 @@
511531
<plugin>
512532
<groupId>com.github.siom79.japicmp</groupId>
513533
<artifactId>japicmp-maven-plugin</artifactId>
514-
<version>0.23.0</version>
534+
<version>0.23.1</version>
515535
<configuration>
516536
<parameter>
517537
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
@@ -561,7 +581,7 @@
561581
</plugin>
562582
<plugin>
563583
<artifactId>maven-compiler-plugin</artifactId>
564-
<version>3.13.0</version>
584+
<version>3.14.0</version>
565585
<configuration>
566586
<source>11</source>
567587
<target>11</target>
@@ -570,7 +590,7 @@
570590
<annotationProcessorPath>
571591
<groupId>org.jenkins-ci</groupId>
572592
<artifactId>annotation-indexer</artifactId>
573-
<version>1.17</version>
593+
<version>1.18</version>
574594
</annotationProcessorPath>
575595
</annotationProcessorPaths>
576596
</configuration>
@@ -619,6 +639,9 @@
619639
<artifactId>maven-surefire-plugin</artifactId>
620640
<configuration>
621641
<argLine>@{jacoco.surefire.argLine} ${surefire.argLine}</argLine>
642+
<systemPropertyVariables>
643+
<test.projectArtifactId>${project.artifactId}</test.projectArtifactId>
644+
</systemPropertyVariables>
622645
</configuration>
623646
<executions>
624647
<execution>
@@ -636,7 +659,7 @@
636659
<!--
637660
This plugin is used to generate AOT metadata during tests so that it can be
638661
compared against those in META-INF/native-image/org.kohsuke/github-api/*.
639-
The tests are start with the name "Aot..."
662+
The tests are start with the name "Aot..."
640663
-->
641664
<plugin>
642665
<groupId>org.springframework.boot</groupId>
@@ -799,6 +822,42 @@
799822
</plugins>
800823
</build>
801824
</profile>
825+
<profile>
826+
<id>bridged</id>
827+
<properties>
828+
<!-- Only fail code coverage on non-windows machines -->
829+
<github-api.artifactId>github-api-bridged</github-api.artifactId>
830+
</properties>
831+
<build>
832+
<plugins>
833+
<plugin>
834+
<groupId>com.infradna.tool</groupId>
835+
<artifactId>bridge-method-injector</artifactId>
836+
</plugin>
837+
<plugin>
838+
<artifactId>maven-resources-plugin</artifactId>
839+
<executions>
840+
<execution>
841+
<id>copy-bridged-resources</id>
842+
<goals>
843+
<goal>copy-resources</goal>
844+
</goals>
845+
<!-- here the phase you need -->
846+
<phase>validate</phase>
847+
<configuration>
848+
<outputDirectory>${basedir}/target/classes/META-INF/native-image/org.kohsuke/${github-api.artifactId}</outputDirectory>
849+
<resources>
850+
<resource>
851+
<directory>src/main/resources/META-INF/native-image/org.kohsuke/github-api</directory>
852+
</resource>
853+
</resources>
854+
</configuration>
855+
</execution>
856+
</executions>
857+
</plugin>
858+
</plugins>
859+
</build>
860+
</profile>
802861
<profile>
803862
<id>ci-non-windows</id>
804863
<activation>

src/main/java/org/kohsuke/github/GHApp.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.io.IOException;
77
import java.net.URL;
8+
import java.time.Instant;
89
import java.util.Collections;
910
import java.util.Date;
1011
import java.util.List;
@@ -145,7 +146,7 @@ public PagedIterable<GHAppInstallationRequest> listInstallationRequests() {
145146
* @see <a href="https://developer.github.com/v3/apps/#list-installations">List installations</a>
146147
*/
147148
public PagedIterable<GHAppInstallation> listInstallations() {
148-
return listInstallations(null);
149+
return listInstallations(GitHubClient.toInstantOrNull(null));
149150
}
150151

151152
/**
@@ -157,11 +158,27 @@ public PagedIterable<GHAppInstallation> listInstallations() {
157158
* - Allows users to get installations that have been updated since a given date.
158159
* @return a list of App installations since a given time.
159160
* @see <a href="https://developer.github.com/v3/apps/#list-installations">List installations</a>
161+
* @deprecated use {@link #listInstallations(Instant)}
160162
*/
163+
@Deprecated
161164
public PagedIterable<GHAppInstallation> listInstallations(final Date since) {
165+
return listInstallations(since.toInstant());
166+
}
167+
168+
/**
169+
* Obtains all the installations associated with this app since a given date.
170+
* <p>
171+
* You must use a JWT to access this endpoint.
172+
*
173+
* @param since
174+
* - Allows users to get installations that have been updated since a given date.
175+
* @return a list of App installations since a given time.
176+
* @see <a href="https://developer.github.com/v3/apps/#list-installations">List installations</a>
177+
*/
178+
public PagedIterable<GHAppInstallation> listInstallations(final Instant since) {
162179
Requester requester = root().createRequest().withUrlPath("/app/installations");
163180
if (since != null) {
164-
requester.with("since", GitHubClient.printDate(since));
181+
requester.with("since", GitHubClient.printInstant(since));
165182
}
166183
return requester.toIterable(GHAppInstallation[].class, null);
167184
}

src/main/java/org/kohsuke/github/GHAppInstallation.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package org.kohsuke.github;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
45
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
56
import org.kohsuke.github.internal.EnumUtils;
67

78
import java.io.IOException;
89
import java.net.URL;
10+
import java.time.Instant;
911
import java.util.Collections;
1012
import java.util.Date;
1113
import java.util.List;
@@ -189,8 +191,9 @@ public GHRepositorySelection getRepositorySelection() {
189191
*
190192
* @return the suspended at
191193
*/
192-
public Date getSuspendedAt() {
193-
return GitHubClient.parseDate(suspendedAt);
194+
@WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
195+
public Instant getSuspendedAt() {
196+
return GitHubClient.parseInstant(suspendedAt);
194197
}
195198

196199
/**

src/main/java/org/kohsuke/github/GHAppInstallationToken.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.kohsuke.github;
22

3+
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
4+
5+
import java.time.Instant;
36
import java.util.*;
47

58
// TODO: Auto-generated Javadoc
@@ -66,7 +69,8 @@ public GHRepositorySelection getRepositorySelection() {
6669
*
6770
* @return date when this token expires
6871
*/
69-
public Date getExpiresAt() {
70-
return GitHubClient.parseDate(expires_at);
72+
@WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
73+
public Instant getExpiresAt() {
74+
return GitHubClient.parseInstant(expires_at);
7175
}
7276
}

src/main/java/org/kohsuke/github/GHArtifact.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package org.kohsuke.github;
22

33
import com.fasterxml.jackson.annotation.JsonIgnore;
4+
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
45
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
56
import org.apache.commons.lang3.StringUtils;
67
import org.kohsuke.github.function.InputStreamFunction;
78

89
import java.io.IOException;
910
import java.net.URL;
11+
import java.time.Instant;
1012
import java.util.Date;
1113
import java.util.Objects;
1214

@@ -77,8 +79,9 @@ public boolean isExpired() {
7779
*
7880
* @return the date of expiration
7981
*/
80-
public Date getExpiresAt() {
81-
return GitHubClient.parseDate(expiresAt);
82+
@WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
83+
public Instant getExpiresAt() {
84+
return GitHubClient.parseInstant(expiresAt);
8285
}
8386

8487
/**

0 commit comments

Comments
 (0)