Skip to content

Commit ed1c463

Browse files
committed
build(core): Move custom ant tasks to build-definitions.xml
Partially from LWJGL@8fd5f8d This stops `BindingConfig` from being called repeatedly when chaining tasks like we do in `ci_build_android.bash` which causes issues as it sets `-Dbinding.core=true` after hardcoding its inclusion in the modules list. This causes `core` to duplicate at the end of the property `module.list` (because BindingConfig has no deduplciation logic for that) which messes with `ModuleInfoGen` as it tries to move a file it already moved before, that being the `module-info.class` file for `core`.
1 parent 32b88d1 commit ed1c463

3 files changed

Lines changed: 60 additions & 17 deletions

File tree

build.xml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,6 @@
2727

2828
<mkdir-symlink dir="bin"/>
2929

30-
<!-- Compile custom Ant tasks -->
31-
<mkdir dir="${bin.ant}"/>
32-
<lwjgl.javac
33-
destdir="${bin.ant}"
34-
classpath="${ant.core.lib}"
35-
36-
srcdir="${src.ant}/java"
37-
includes="org/lwjgl/**"
38-
39-
taskname="javac: Custom Ant Tasks"
40-
/>
41-
42-
<taskdef name="logLevel" classname="org.lwjgl.SetLogLevel" classpath="${bin.ant}"/>
43-
<taskdef name="bindingConfig" classname="org.lwjgl.BindingConfig" classpath="${bin.ant}"/>
44-
<bindingConfig/>
45-
4630
<ant antfile="update-dependencies.xml" target="check-dependencies" inheritAll="false"/>
4731

4832
<taskdef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="${kotlinc}/lib/kotlin-ant.jar"/>

config/build-definitions.xml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@ Defines global properties and useful macros.
99
This script is included in /build.xml and /config/update-dependencies.xml.
1010
-->
1111
<project name="definitions" basedir="../" xmlns:if="ant:if" xmlns:unless="ant:unless">
12+
<property name="bin.ant" location="bin/classes/ant" relative="true"/>
13+
14+
<!-- Compile custom Ant tasks -->
15+
<mkdir dir="bin/classes/ant"/>
16+
<javac
17+
sourcepath="" debug="yes" source="8" target="8" encoding="UTF-8" includeantruntime="false" nowarn="true"
18+
19+
destdir="bin/classes/ant"
20+
classpath="${ant.core.lib}"
21+
22+
srcdir="modules/ant/src/main/java"
23+
includes="org/lwjgl/**"
24+
25+
taskname="javac: Custom Ant Tasks"
26+
/>
27+
28+
<!-- Define custom Ant tasks -->
29+
<taskdef name="logLevel" classname="org.lwjgl.SetLogLevel" classpath="${bin.ant}"/>
30+
<taskdef name="bindingConfig" classname="org.lwjgl.BindingConfig" classpath="${bin.ant}"/>
31+
<bindingConfig/>
32+
1233
<property environment="env"/>
1334

1435
<!--
@@ -88,7 +109,6 @@ This script is included in /build.xml and /config/update-dependencies.xml.
88109

89110
<property name="test.resources" location="modules/samples/src/test/resources" relative="true"/>
90111

91-
<property name="bin.ant" location="bin/classes/ant" relative="true"/>
92112
<property name="bin.extract" location="bin/classes/extract" relative="true"/>
93113
<property name="bin.generator" location="bin/classes/generator" relative="true"/>
94114
<property name="bin.javadoc" location="bin/javadoc" relative="true"/>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright LWJGL. All rights reserved.
3+
* License terms: https://www.lwjgl.org/license
4+
*/
5+
package org.lwjgl;
6+
7+
import org.apache.tools.ant.*;
8+
9+
import java.util.regex.*;
10+
11+
public class DetectJDKVersion extends Task {
12+
13+
@Override public void execute() {
14+
15+
String javaVersion = System.getProperty("java.version");
16+
17+
Matcher matcher = Pattern
18+
.compile("^([1-9][0-9]*)(?:(?:\\.0)*\\.[1-9][0-9]*)*(?:-[a-zA-Z0-9]+)?")
19+
.matcher(javaVersion);
20+
21+
if (!matcher.find()) {
22+
if (javaVersion.startsWith("1.")) {
23+
if (!javaVersion.startsWith("1.8.")) {
24+
throw new BuildException("JDK 8 or newer is required.");
25+
}
26+
return;
27+
}
28+
throw new BuildException("Failed to parse java.version: " + javaVersion);
29+
}
30+
31+
int version = Integer.parseInt(matcher.group(1));
32+
33+
Project LWJGL = getProject();
34+
for (int v = version; 9 <= v; v--) {
35+
LWJGL.setProperty("jdk" + v, "true");
36+
}
37+
}
38+
39+
}

0 commit comments

Comments
 (0)