Skip to content

Commit 4933239

Browse files
committed
Fixed CI build issues
1 parent 87a88a1 commit 4933239

7 files changed

Lines changed: 83 additions & 30 deletions

File tree

Ports/CLDC11/src/java/time/format/DateTimeFormatter.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private String formatPattern(TemporalAccessor temporal) {
214214
TimeZone original = TimeZone.getDefault();
215215
try {
216216
if (zone != null) {
217-
TimeZone.setDefault(zone.toTimeZone());
217+
TimeZone.setDefault(toTimeZone(zone));
218218
}
219219
return sdf.format(new Date(instant.toEpochMilli()));
220220
} finally {
@@ -230,7 +230,7 @@ private static ParsedPatternResult parsePattern(String text, String pattern, Zon
230230
TimeZone original = TimeZone.getDefault();
231231
try {
232232
if (defaultZone != null) {
233-
TimeZone.setDefault(defaultZone.toTimeZone());
233+
TimeZone.setDefault(toTimeZone(defaultZone));
234234
}
235235
SimpleDateFormat sdf = newFormat(pattern, defaultZone, locale);
236236
Date date = sdf.parse(text);
@@ -258,6 +258,14 @@ private static int parseInt(String text, int start, int end) {
258258
return Integer.parseInt(text.substring(start, end));
259259
}
260260

261+
private static TimeZone toTimeZone(ZoneId zone) {
262+
if (zone instanceof ZoneOffset) {
263+
ZoneOffset offset = (ZoneOffset) zone;
264+
return TimeZone.getTimeZone(offset.getId().equals("Z") ? "GMT" : "GMT" + offset.getId());
265+
}
266+
return TimeZone.getTimeZone(zone.getId());
267+
}
268+
261269
private static String pad(int value, int length) {
262270
String s = String.valueOf(Math.abs(value));
263271
StringBuffer out = new StringBuffer();

scripts/setup-workspace.sh

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,22 +248,27 @@ if [ ! -f "$BUILD_CLIENT" ]; then
248248
fi
249249

250250
log "Installing cn1-maven-archetypes"
251-
set +e # don't let a transient git failure abort the whole build
252-
if [ -d cn1-maven-archetypes/.git ]; then
253-
log "Updating existing cn1-maven-archetypes checkout"
254-
if ! git -C cn1-maven-archetypes fetch --all --tags; then
255-
log "git fetch failed (exit 128?). Leaving existing copy as-is."
256-
else
257-
git -C cn1-maven-archetypes reset --hard origin/master || \
258-
log "git reset failed; keeping local state."
259-
fi
251+
if [ "${SKIP_CN1_ARCHETYPES:-0}" = "1" ]; then
252+
log "Skipping cn1-maven-archetypes install because SKIP_CN1_ARCHETYPES=1"
253+
skip_archetypes=1
260254
else
261-
if ! git clone https://github.com/shannah/cn1-maven-archetypes cn1-maven-archetypes; then
262-
log "git clone failed (likely exit 128). Skipping archetype install."
263-
skip_archetypes=1
255+
set +e # don't let a transient git failure abort the whole build
256+
if [ -d cn1-maven-archetypes/.git ]; then
257+
log "Updating existing cn1-maven-archetypes checkout"
258+
if ! git -C cn1-maven-archetypes fetch --all --tags; then
259+
log "git fetch failed (exit 128?). Leaving existing copy as-is."
260+
else
261+
git -C cn1-maven-archetypes reset --hard origin/master || \
262+
log "git reset failed; keeping local state."
263+
fi
264+
else
265+
if ! git clone https://github.com/shannah/cn1-maven-archetypes cn1-maven-archetypes; then
266+
log "git clone failed (likely exit 128). Skipping archetype install."
267+
skip_archetypes=1
268+
fi
264269
fi
270+
set -e
265271
fi
266-
set -e
267272

268273
if [ "${skip_archetypes:-0}" -eq 0 ]; then
269274
(

scripts/website/build.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ WEBSITE_INCLUDE_JAVADOCS="${WEBSITE_INCLUDE_JAVADOCS:-false}"
2222
WEBSITE_INCLUDE_DEVGUIDE="${WEBSITE_INCLUDE_DEVGUIDE:-auto}"
2323
WEBSITE_INCLUDE_INITIALIZR="${WEBSITE_INCLUDE_INITIALIZR:-false}"
2424
WEBSITE_INCLUDE_PLAYGROUND="${WEBSITE_INCLUDE_PLAYGROUND:-false}"
25+
WEBSITE_BOOTSTRAP_CN1_SNAPSHOTS="${WEBSITE_BOOTSTRAP_CN1_SNAPSHOTS:-auto}"
2526
CN1_USER="${CN1_USER:-}"
2627
CN1_TOKEN="${CN1_TOKEN:-}"
2728

@@ -33,6 +34,18 @@ if [ "${WEBSITE_INCLUDE_INITIALIZR}" = "auto" ]; then
3334
fi
3435
fi
3536

37+
bootstrap_local_cn1_snapshots() {
38+
if [ "${WEBSITE_BOOTSTRAP_CN1_SNAPSHOTS}" != "true" ]; then
39+
return
40+
fi
41+
42+
echo "Bootstrapping local Codename One snapshot Maven artifacts..." >&2
43+
(
44+
cd "${REPO_ROOT}"
45+
SKIP_CN1_ARCHETYPES=1 ./scripts/setup-workspace.sh -q -DskipTests
46+
)
47+
}
48+
3649
if [ "${WEBSITE_INCLUDE_PLAYGROUND}" = "auto" ]; then
3750
if [ -n "${CN1_USER}" ] && [ -n "${CN1_TOKEN}" ]; then
3851
WEBSITE_INCLUDE_PLAYGROUND="true"
@@ -41,11 +54,19 @@ if [ "${WEBSITE_INCLUDE_PLAYGROUND}" = "auto" ]; then
4154
fi
4255
fi
4356

57+
if [ "${WEBSITE_BOOTSTRAP_CN1_SNAPSHOTS}" = "auto" ]; then
58+
if [ "${WEBSITE_INCLUDE_PLAYGROUND}" = "true" ]; then
59+
WEBSITE_BOOTSTRAP_CN1_SNAPSHOTS="true"
60+
else
61+
WEBSITE_BOOTSTRAP_CN1_SNAPSHOTS="false"
62+
fi
63+
fi
64+
4465
set_cn1_user_token() {
4566
local project_dir="$1"
4667

4768
if [ -n "${CN1_USER}" ] && [ -n "${CN1_TOKEN}" ]; then
48-
if ! ./mvnw -q -U -pl javascript -am \
69+
if ! sh ./mvnw -q -U -pl javascript -am \
4970
cn1:set-user-token \
5071
-Dcodename1.platform=javascript \
5172
-Duser="${CN1_USER}" \
@@ -515,9 +536,9 @@ build_initializr_for_site() {
515536

516537
run_initializr_mvn() {
517538
if command -v xvfb-run >/dev/null 2>&1; then
518-
xvfb-run -a ./mvnw "$@"
539+
xvfb-run -a sh ./mvnw "$@"
519540
else
520-
./mvnw "$@"
541+
sh ./mvnw "$@"
521542
fi
522543
}
523544

@@ -568,15 +589,17 @@ build_playground_for_site() {
568589
return
569590
fi
570591

592+
bootstrap_local_cn1_snapshots
593+
571594
echo "Building Playground JavaScript bundle for website..." >&2
572595
(
573596
cd "${REPO_ROOT}/scripts/cn1playground"
574597

575598
run_playground_mvn() {
576599
if command -v xvfb-run >/dev/null 2>&1; then
577-
xvfb-run -a ./mvnw "$@"
600+
xvfb-run -a sh ./mvnw "$@"
578601
else
579-
./mvnw "$@"
602+
sh ./mvnw "$@"
580603
fi
581604
}
582605

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.codename1.impl.time;
2+
3+
import java.time.ZoneId;
4+
import java.time.ZoneOffset;
5+
import java.util.TimeZone;
6+
7+
public final class TimeZoneSupport {
8+
private TimeZoneSupport() {
9+
}
10+
11+
public static TimeZone toTimeZone(ZoneId zoneId) {
12+
if (zoneId instanceof ZoneOffset) {
13+
ZoneOffset offset = (ZoneOffset) zoneId;
14+
return TimeZone.getTimeZone(offset.getId().equals("Z") ? "GMT" : "GMT" + offset.getId());
15+
}
16+
return TimeZone.getTimeZone(zoneId.getId());
17+
}
18+
}

vm/JavaAPI/src/java/time/DateTimeSupport.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package java.time;
22

3+
import com.codename1.impl.time.TimeZoneSupport;
34
import java.text.ParseException;
45
import java.text.SimpleDateFormat;
56
import java.util.Calendar;
@@ -181,7 +182,7 @@ public static LocalDateTime localDateTimeFromInstant(Instant instant, ZoneId zon
181182
}
182183

183184
public static ZoneOffset offsetFromInstant(Instant instant, ZoneId zone) {
184-
TimeZone tz = zone.toTimeZone();
185+
TimeZone tz = TimeZoneSupport.toTimeZone(zone);
185186
Calendar cal = newCalendar(TimeZone.getTimeZone("GMT"));
186187
cal.setTime(new Date(instant.toEpochMilli()));
187188
int offsetMillis = tz.getOffset(
@@ -206,7 +207,7 @@ public static String formatPattern(String pattern, TemporalCarrier carrier, Loca
206207
TimeZone original = TimeZone.getDefault();
207208
try {
208209
if (zone != null) {
209-
TimeZone.setDefault(zone.toTimeZone());
210+
TimeZone.setDefault(TimeZoneSupport.toTimeZone(zone));
210211
}
211212
return sdf.format(new Date(carrier.toInstant().toEpochMilli()));
212213
} finally {
@@ -218,7 +219,7 @@ public static ParsedPatternResult parsePattern(String text, String pattern, Zone
218219
TimeZone original = TimeZone.getDefault();
219220
try {
220221
if (defaultZone != null) {
221-
TimeZone.setDefault(defaultZone.toTimeZone());
222+
TimeZone.setDefault(TimeZoneSupport.toTimeZone(defaultZone));
222223
}
223224
SimpleDateFormat sdf = newFormat(pattern, defaultZone, locale);
224225
Date date = sdf.parse(text);

vm/JavaAPI/src/java/time/ZoneId.java

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

3+
import com.codename1.impl.time.TimeZoneSupport;
34
import java.util.TimeZone;
45

56
public class ZoneId {
@@ -37,11 +38,7 @@ public String getId() {
3738
}
3839

3940
TimeZone toTimeZone() {
40-
if (this instanceof ZoneOffset) {
41-
ZoneOffset offset = (ZoneOffset) this;
42-
return TimeZone.getTimeZone(offset.getId().equals("Z") ? "GMT" : "GMT" + offset.getId());
43-
}
44-
return TimeZone.getTimeZone(id);
41+
return TimeZoneSupport.toTimeZone(this);
4542
}
4643

4744
public boolean equals(Object obj) {

vm/JavaAPI/src/java/time/format/DateTimeFormatter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package java.time.format;
22

3+
import com.codename1.impl.time.TimeZoneSupport;
34
import java.text.ParseException;
45
import java.text.SimpleDateFormat;
56
import java.time.Instant;
@@ -214,7 +215,7 @@ private String formatPattern(TemporalAccessor temporal) {
214215
TimeZone original = TimeZone.getDefault();
215216
try {
216217
if (zone != null) {
217-
TimeZone.setDefault(zone.toTimeZone());
218+
TimeZone.setDefault(TimeZoneSupport.toTimeZone(zone));
218219
}
219220
return sdf.format(new Date(instant.toEpochMilli()));
220221
} finally {
@@ -230,7 +231,7 @@ private static ParsedPatternResult parsePattern(String text, String pattern, Zon
230231
TimeZone original = TimeZone.getDefault();
231232
try {
232233
if (defaultZone != null) {
233-
TimeZone.setDefault(defaultZone.toTimeZone());
234+
TimeZone.setDefault(TimeZoneSupport.toTimeZone(defaultZone));
234235
}
235236
SimpleDateFormat sdf = newFormat(pattern, defaultZone, locale);
236237
Date date = sdf.parse(text);

0 commit comments

Comments
 (0)