dweiss commented on code in PR #15623:
URL: https://github.com/apache/lucene/pull/15623#discussion_r2779634550
##########
build-tools/build-infra/src/main/java/org/apache/lucene/gradle/WrapperDownloader.java:
##########
@@ -122,12 +123,28 @@ public void run(Path destination) throws IOException,
NoSuchAlgorithmException {
}
}
- Path versionPath =
- destination.resolveSibling(destination.getFileName().toString() +
".version");
- if (!Files.exists(versionPath)) {
- throw new IOException("Wrapper version file not found: " + versionPath);
+ Path wrapperProperties =
+ destination.resolveSibling(
+ destination.getFileName().toString().replace(".jar",
".properties"));
+ if (!Files.exists(wrapperProperties)) {
+ throw new IOException("Wrapper property file not found: " +
wrapperProperties);
}
- String wrapperVersion = Files.readString(versionPath,
StandardCharsets.UTF_8).trim();
+
+ Pattern versionPattern = Pattern.compile("gradle-(?<version>.+?)-bin.zip");
+ String wrapperVersion =
+ Files.readAllLines(wrapperProperties, StandardCharsets.UTF_8).stream()
+ .map(
+ line -> {
+ var matcher = versionPattern.matcher(line);
+ if (matcher.find()) {
+ return matcher.group("version");
+ } else {
+ return null;
+ }
+ })
+ .filter(Objects::nonNull)
+ .findAny()
+ .orElseThrow();
Review Comment:
Unrelated simplification - removed the duplication of gradle version and
parse the property file instead.
##########
build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/TestsAndRandomizationPlugin.java:
##########
@@ -601,4 +632,114 @@ private static boolean addVectorizationOptions(
return defaultVectorizationOption.get();
}
+
+ public abstract static class LuceneTestFramework implements TestFramework {
+ private final DefaultTestFilter filter;
+ private final Factory<File> testTaskTemporaryDir;
+ private final Provider<Boolean> dryRun;
+ private TestFrameworkDetector detector =
+ new TestFrameworkDetector() {
+ private TestDefinitionProcessor<? super ClassTestDefinition>
testDefinitionProcessor;
+
+ @Override
+ public void startDetection(
+ TestDefinitionProcessor<? super ClassTestDefinition>
testDefinitionProcessor) {
+ this.testDefinitionProcessor = testDefinitionProcessor;
+ }
+
+ @Override
+ public boolean processTestClass(RelativeFile testClassFile) {
+ var cc =
+ ClassFile.of(
+ ClassFile.ConstantPoolSharingOption.NEW_POOL,
+ ClassFile.DebugElementsOption.DROP_DEBUG,
+ ClassFile.LineNumbersOption.DROP_LINE_NUMBERS,
+ ClassFile.StackMapsOption.DROP_STACK_MAPS);
+
+ try {
+ ClassModel parsed = cc.parse(testClassFile.getFile().toPath());
+ String internalName =
parsed.thisClass().asInternalName().replace('/', '.');
+ testDefinitionProcessor.processTestDefinition(new
ClassTestDefinition(internalName));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
Review Comment:
Get fully qualified class name from a file. Perhaps it could be less fancy
than actually parsing the file, don't know.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]