Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="installer/src/java"/>
<classpathentry kind="src" path="installer/test/java"/>
<classpathentry kind="src" path="build/gensrc"/>
<classpathentry kind="src" path="tests/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="extlibs/ant-1.10.18.jar"/>
<classpathentry kind="lib" path="extlibs/ant-jarjar-1.18.1.jar"/>
<classpathentry kind="lib" path="extlibs/antlr-complete-3.5.3.jar"/>
<classpathentry kind="lib" path="extlibs/asm-9.11.jar"/>
<classpathentry kind="lib" path="extlibs/asm-commons-9.11.jar"/>
<classpathentry kind="lib" path="extlibs/asm-util-9.11.jar"/>
<classpathentry kind="lib" path="extlibs/bcpkix-jdk18on-1.86.jar"/>
<classpathentry kind="lib" path="extlibs/bcprov-jdk18on-1.86.jar"/>
<classpathentry kind="lib" path="extlibs/commons-compress-1.28.0.jar"/>
<classpathentry kind="lib" path="extlibs/commons-io-2.22.0.jar"/>
<classpathentry kind="lib" path="extlibs/guava-33.7.2-jre.jar"/>
<classpathentry kind="lib" path="extlibs/icu4j-78.3.jar"/>
<classpathentry kind="lib" path="extlibs/jakarta.servlet-api-6.1.0.jar"/>
<classpathentry kind="lib" path="extlibs/jarjar-1.18.1.jar"/>
<classpathentry kind="lib" path="extlibs/java-sizeof-0.0.5.jar"/>
<classpathentry kind="lib" path="extlibs/jdbc-15.0.1.4.jar"/>
<classpathentry kind="lib" path="extlibs/jffi-1.4.3.jar"/>
<classpathentry kind="lib" path="extlibs/jline-4.4.8.jar"/>
<classpathentry kind="lib" path="extlibs/jnr-constants-0.11.2.jar"/>
<classpathentry kind="lib" path="extlibs/jnr-ffi-2.3.3.jar"/>
<classpathentry kind="lib" path="extlibs/jnr-posix-3.2.4.jar"/>
<classpathentry kind="lib" path="extlibs/junit-jupiter-6.1.3.jar"/>
<classpathentry kind="lib" path="extlibs/junit-jupiter-api-6.1.3.jar"/>
<classpathentry kind="lib" path="extlibs/junit-jupiter-engine-6.1.3.jar"/>
<classpathentry kind="lib" path="extlibs/junit-jupiter-params-6.1.3.jar"/>
<classpathentry kind="lib" path="extlibs/junit-platform-commons-6.1.3.jar"/>
<classpathentry kind="lib" path="extlibs/junit-platform-engine-6.1.3.jar"/>
<classpathentry kind="lib" path="extlibs/junit-platform-launcher-6.1.3.jar"/>
<classpathentry kind="lib" path="extlibs/netty-buffer-4.2.19.Final.jar"/>
<classpathentry kind="lib" path="extlibs/netty-codec-base-4.2.19.Final.jar"/>
<classpathentry kind="lib" path="extlibs/netty-common-4.2.19.Final.jar"/>
<classpathentry kind="lib" path="extlibs/netty-handler-4.2.19.Final.jar"/>
<classpathentry kind="lib" path="extlibs/netty-resolver-4.2.19.Final.jar"/>
<classpathentry kind="lib" path="extlibs/netty-transport-4.2.19.Final.jar"/>
<classpathentry kind="lib" path="extlibs/netty-transport-native-unix-common-4.2.19.Final.jar"/>
<classpathentry kind="lib" path="extlibs/ojdbc8-23.26.3.0.0.jar"/>
<classpathentry kind="lib" path="extlibs/opentest4j-1.3.0.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ updates:
bouncycastle:
patterns:
- "org.bouncycastle:bc*"
jarjar:
patterns:
- "com.eed3si9n.jarjar:*"
jnr:
patterns:
- "com.github.jnr:*"
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
.idea/

# Eclipse files
.classpath
.externalToolBuilders/*
.project
.pydevproject
Expand Down
3 changes: 2 additions & 1 deletion b/.idea/libraries/extlibs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ dependencies {
testImplementation(libs.junit.jupiter)
testImplementation(libs.junit.platform.launcher)
testImplementation(libs.antlr.complete)
// to trigger dependabot on jarjar
testImplementation(libs.ant.jarjar)
testImplementation(libs.jarjar)
}


Expand Down
17 changes: 10 additions & 7 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -824,15 +824,15 @@ The text for an official release would continue like ...
</target>

<target name="jar-complete" depends="jar, pycompile">
<taskdef name="jarjar" classname="org.pantsbuild.jarjar.JarJarTask">
<taskdef name="jarjar" classname="com.eed3si9n.jarjar.JarJarTask">
<classpath>
<pathelement path="extlibs/jarjar-1.7.2.jar" />
<pathelement path="extlibs/ant-jarjar-1.18.1.jar" />
<pathelement path="extlibs/jarjar-1.18.1.jar" />
<path refid="main.classpath" />
</classpath>
</taskdef>
<!-- produce the big shadowed jar using jarjar -->
<property name="initial.jarjared.jar" value="jarjared.jar"/>
<jarjar destfile="${dist.dir}/${initial.jarjared.jar}" update="${jar.update}">
<jarjar destfile="${dist.dir}/${jython.deploy.jar}" update="${jar.update}">
<zipfileset src="${dist.dir}/${jython.dev.jar}"/>
<!-- pin to Antlr 3 until we upgrade parsing -->
<zipfileset src="extlibs/antlr-runtime-3.5.3.jar"/>
Expand Down Expand Up @@ -903,7 +903,8 @@ The text for an official release would continue like ...
<rule pattern="org.apache.xerces.**" result="org.python.apache.xerces.@1"/>
<rule pattern="org.apache.wml.**" result="org.python.apache.wml.@1"/>
<rule pattern="org.apache.html.**" result="org.python.apache.html.@1"/>
<!-- leave jline out: jarjar cannot handle FFM classes - if we exclude them, the console is broken -->
<zipfileset src="extlibs/jline-4.4.8.jar"/>
<rule pattern="org.jline.**" result="org.python.jline.@1"/>
<manifest>
<attribute name="Main-Class" value="org.python.util.jython" />
<attribute name="Built-By" value="${user.name}" />
Expand All @@ -922,17 +923,19 @@ The text for an official release would continue like ...
</section>
</manifest>
</jarjar>
<!-- pack jline as is - see above -->
<!-- pack jline as is - see above
<jar destfile="${dist.dir}/${jython.deploy.jar}" update="${jar.update}">
<zipfileset src="${dist.dir}/${initial.jarjared.jar}"/>
<zipfileset src="extlibs/jline-4.5.0.jar" excludes="META-INF/MANIFEST.MF"/>
</jar>
<!-- delete the intermediate .jar file -->
-->
<!-- delete the intermediate .jar file
<delete>
<filelist dir="${dist.dir}">
<file name="${initial.jarjared.jar}"/>
</filelist>
</delete>
-->
</target>

<target name="jar-standalone" depends="jar-complete, copy-lib">
Expand Down
Binary file added extlibs/ant-jarjar-1.18.1.jar
Binary file not shown.
Binary file added extlibs/jarjar-1.18.1.jar
Binary file not shown.
Binary file removed extlibs/jarjar-1.7.2.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ rev_guava = "33.8.0-jre"
rev_icu4j = "79.1"
rev_informix = "15.0.1.4"
rev_jakarta_servlet_api = "6.1.0"
rev_jarjar = "1.18.1"
rev_java_sizeof = "0.0.5"
rev_jffi = "1.4.7"
rev_jline = "4.5.0"
Expand All @@ -22,6 +23,7 @@ rev_oracle = "23.26.4.0.0"

[libraries]
ant = { module = "org.apache.ant:ant", version.ref = "rev_ant" }
ant_jarjar = { module = "com.eed3si9n.jarjar:ant-jarjar", version.ref = "rev_jarjar" }
antlr = { module = "org.antlr:antlr", version.ref = "rev_antlr" }
antlr-complete = { module = "org.antlr:antlr-complete", version.ref = "rev_antlr" }
asm = { module = "org.ow2.asm:asm", version.ref = "rev_asm" }
Expand All @@ -35,6 +37,7 @@ guava = { module = "com.google.guava:guava",
icu4j = { module = "com.ibm.icu:icu4j", version.ref = "rev_icu4j"}
informix = { module = "com.ibm.informix:jdbc", version.ref = "rev_informix" }
jakarta_servlet_api = { module = "jakarta.servlet:jakarta.servlet-api", version.ref = "rev_jakarta_servlet_api" }
jarjar = { module = "com.eed3si9n.jarjar:jarjar", version.ref = "rev_jarjar" }
java_sizeof = { module = "com.carrotsearch:java-sizeof", version.ref = "rev_java_sizeof" }
jffi = { module = "com.github.jnr:jffi", version.ref = "rev_jffi" }
jline = { module = "org.jline:jline", version.ref = "rev_jline" }
Expand Down
16 changes: 13 additions & 3 deletions src/org/python/util/VersionMatchingAntTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class VersionMatchingAntTask extends Task {
ARTEFACT_NAME_FORMATS.put("rev_icu4j", "icu4j-%s.jar");
ARTEFACT_NAME_FORMATS.put("rev_informix", "jdbc-%s.jar");
ARTEFACT_NAME_FORMATS.put("rev_jakarta_servlet_api", "jakarta.servlet-api-%s.jar");
ARTEFACT_NAME_FORMATS.put("rev_jarjar", "ant-jarjar-%s.jar");
ARTEFACT_NAME_FORMATS.put("rev_java_sizeof", "java-sizeof-%s.jar");
ARTEFACT_NAME_FORMATS.put("rev_jffi", "jffi-%s.jar");
ARTEFACT_NAME_FORMATS.put("rev_jline", "jline-%s.jar");
Expand Down Expand Up @@ -115,9 +116,18 @@ private static void addGradleArtefact(String line, Set<String> artefacts) {

private static void addAntArtefact(String line, Set<String> artefacts) {
line = line.trim();
if (line.startsWith("<file name=\"") && line.contains(".jar\"")) {
int quoteIndex = line.indexOf('"');
artefacts.add(line.substring(quoteIndex + 1, line.indexOf('"', quoteIndex + 1)));
if (line.contains(".jar\"")) {
if (line.startsWith("<file name=\"") ) {
int quoteIndex = line.indexOf('"');
artefacts.add(line.substring(quoteIndex + 1, line.indexOf('"', quoteIndex + 1)));
}
String pathStart = "<pathelement path=\"extlibs/";
if (line.startsWith(pathStart)) {
int startIndex = pathStart.length();
artefacts.add(line.substring(startIndex, line.indexOf('"', startIndex + 1)));
}


}
}

Expand Down
48 changes: 33 additions & 15 deletions tests/java/org/python/util/VersionMatchingAntTaskTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,32 @@
import java.nio.file.Paths;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Location;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

class VersionMatchingAntTaskTest {

static Set<String> antArtefacts = new HashSet<>();

private VersionMatchingAntTask task;

@BeforeEach
void setUp() throws Exception {
task = new VersionMatchingAntTask();
setLocationToBuildXml();
// add all ant artefacts to a static collection (for parameterized tests
antArtefacts.addAll(task.parseAntArtefacts());
}



@Test
void testGetLocation() {
Location location = task.getLocation();
Expand All @@ -42,14 +52,12 @@ void testGetLocation() {
void testParseGradleAretfacts() throws IOException {
Set<String> gradleArtefacts = task.parseGradleArtefacts();
assertNotNull(gradleArtefacts);
assertEquals(20, gradleArtefacts.size());
assertEquals(21, gradleArtefacts.size());
}

@Test
void testParseAntArtefacts() throws IOException {
Set<String> antArtefacts = task.parseAntArtefacts();
assertNotNull(antArtefacts);
assertEquals(39, antArtefacts.size());
assertEquals(41, antArtefacts.size());
}

@Test
Expand Down Expand Up @@ -84,6 +92,7 @@ void testCalculateGradleArtefact() {
assertEquals("icu4j-78.7.jar", calculateGradleArtefact("rev_icu4j", "78.7"));
assertEquals("jdbc-15.3.2.1.jar", calculateGradleArtefact("rev_informix", "15.3.2.1"));
assertEquals("jakarta.servlet-api-6.1.0.jar", calculateGradleArtefact("rev_jakarta_servlet_api", "6.1.0"));
assertEquals("ant-jarjar-1.18.1.jar", calculateGradleArtefact("rev_jarjar", "1.18.1"));
assertEquals("java-sizeof-0.1.2.jar", calculateGradleArtefact("rev_java_sizeof", "0.1.2"));
assertEquals("jffi-1.3.15.jar", calculateGradleArtefact("rev_jffi", "1.3.15"));
assertEquals("jline-3.30.4.jar", calculateGradleArtefact("rev_jline", "3.30.4"));
Expand All @@ -96,23 +105,32 @@ void testCalculateGradleArtefact() {
assertEquals("ojdbc8-23.26.1.2.3.jar", calculateGradleArtefact("rev_oracle", "23.26.1.2.3"));
}

@Test
void testCheckAntArtefact() {
Set<String> antArtefacts = new HashSet<>();
antArtefacts.add("junit-jupiter-6.1.3.jar");
antArtefacts.add("additiona.jar");
antArtefacts.add("asm-9.8.7.jar");

checkAntArtefact("junit-jupiter-6.1.3.jar", antArtefacts);
checkAntArtefact("asm-9.8.7.jar", antArtefacts);
@ParameterizedTest
@MethodSource("provideAntArtefacts")
void testCheckAntArtefact(String antArtefact) throws IOException {
checkAntArtefact(antArtefact, antArtefacts);
}

@ParameterizedTest
@MethodSource("provideMissingAntArtefacts")
void testCheckAntArtefactMissingVersion(String missingAntArtefact) throws IOException {
try {
checkAntArtefact("icu4j-78.1.jar", antArtefacts);
checkAntArtefact(missingAntArtefact, antArtefacts);
} catch (BuildException be) {
assertEquals("Gradle artefact 'icu4j-78.1.jar' is missing from build.xml. Please synchronize extlibs and build.xml with libs.versions.toml.",
assertEquals(String.format("Gradle artefact '%s' is missing from build.xml. " + //
"Please synchronize extlibs and build.xml with libs.versions.toml.", missingAntArtefact),
be.getMessage());
}
}

private static Stream<Arguments> provideAntArtefacts() throws IOException {
return antArtefacts.stream().sorted().map(a -> Arguments.of(a));
}

private static Stream<Arguments> provideMissingAntArtefacts() throws IOException {
return antArtefacts.stream().sorted().map(a -> Arguments.of(a.substring(0, a.length() - 4) + ".999.jar"));
}

private void setLocationToBuildXml() throws URISyntaxException {
// in test mode, we need to set the location to the build.xml file
URL actualURL = VersionMatchingAntTask.class.getResource("VersionMatchingAntTask.class");
Expand Down
5 changes: 3 additions & 2 deletions tests/modjy/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@
<property name="mockrunner_servlet_jakarta_jar"
location="${build}/mockrunner-jakarta/mockrunner-servlet.jar" />

<taskdef name="jarjar" classname="org.pantsbuild.jarjar.JarJarTask">
<taskdef name="jarjar" classname="com.eed3si9n.jarjar.JarJarTask">
<classpath>
<pathelement location="../../extlibs/jarjar-1.7.2.jar" />
<pathelement location="../../extlibs/ant-jarjar-1.18.1.jar" />
<pathelement location="../../extlibs/jarjar-1.18.1.jar" />
<pathelement location="../../extlibs/asm-9.11.1.jar" />
<pathelement location="../../extlibs/asm-commons-9.11.1.jar" />
</classpath>
Expand Down
Loading