Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e0c4dae

Browse filesBrowse files
Migrate legacy date-time api to new date-time api (hub4j#2074)
* Migrate legacy date-time api to new date-time api Signed-off-by: solonovamax <solonovamax@12oclockpoint.com> * Apply spotless fixes Signed-off-by: solonovamax <solonovamax@12oclockpoint.com> * Add bridge methods for Data backward compatibility * Fixup reflect tests * Add build for artifact with bridge methods * Disable japicmp temporarily * Improve code coverage * Increase code coverage * Add Deprecated and more coverage * More code coverage --------- Signed-off-by: solonovamax <solonovamax@12oclockpoint.com> Co-authored-by: Liam Newman <bitwiseman@gmail.com>
1 parent b8d48f3 commit e0c4dae
Copy full SHA for e0c4dae

File tree

Expand file treeCollapse file tree

104 files changed

+1033
-416
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

104 files changed

+1033
-416
lines changed

‎.github/workflows/maven-build.yml

Copy file name to clipboardExpand all lines: .github/workflows/maven-build.yml
+24-3Lines 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

Copy file name to clipboardExpand all lines: .github/workflows/publish_release_branch.yml
+8Lines 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

Copy file name to clipboardExpand all lines: pom.xml
+64-5Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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>
5+
<artifactId>${github-api.artifactId}</artifactId>
66
<version>2.0-rc.2-SNAPSHOT</version>
77
<name>GitHub API for Java</name>
88
<description>GitHub API for Java</description>
@@ -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>
@@ -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,7 +341,10 @@
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>
@@ -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>
@@ -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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHApp.java
+19-2Lines 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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHAppInstallation.java
+5-2Lines 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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHAppInstallationToken.java
+6-2Lines 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

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHArtifact.java
+5-2Lines 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
/**

‎src/main/java/org/kohsuke/github/GHCheckRun.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHCheckRun.java
+8-4Lines changed: 8 additions & 4 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.JsonProperty;
4+
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
45
import edu.umd.cs.findbugs.annotations.NonNull;
56
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
67
import org.kohsuke.github.internal.EnumUtils;
78

89
import java.io.IOException;
910
import java.net.URL;
11+
import java.time.Instant;
1012
import java.util.Arrays;
1113
import java.util.Collections;
1214
import java.util.Date;
@@ -269,17 +271,19 @@ public URL getDetailsUrl() {
269271
*
270272
* @return Timestamp of the start time
271273
*/
272-
public Date getStartedAt() {
273-
return GitHubClient.parseDate(startedAt);
274+
@WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
275+
public Instant getStartedAt() {
276+
return GitHubClient.parseInstant(startedAt);
274277
}
275278

276279
/**
277280
* Gets the completed time of the check run in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
278281
*
279282
* @return Timestamp of the completed time
280283
*/
281-
public Date getCompletedAt() {
282-
return GitHubClient.parseDate(completedAt);
284+
@WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
285+
public Instant getCompletedAt() {
286+
return GitHubClient.parseInstant(completedAt);
283287
}
284288

285289
/**

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.