Apache Lucene open-source search software
Remove legacy ant hacks - add conf to test sourceSet. Correct jvm options hack (don't apply to benchmarks run).
Dawid Weissf83c9462bbbc
diff --git a/build.gradle b/build.gradleindex a288e0d6c6b..2ae28268b9b 100644--- a/build.gradle+++ b/build.gradle@@ -170,7 +170,6 @@ apply from: file('gradle/help.gradle')// Ant-compatibility layer. ALL OF THESE SHOULD BE GONE at some point. They are// here so that we can coexist with current ant build but they are indicative// of potential problems with the build conventions, dependencies, etc.-apply from: file('gradle/ant-compat/misc.gradle')apply from: file('gradle/ant-compat/test-classes-cross-deps.gradle')apply from: file('gradle/documentation/documentation.gradle')diff --git a/gradle/ant-compat/misc.gradle b/gradle/ant-compat/misc.gradledeleted file mode 100644index baefa2b16b4..00000000000--- a/gradle/ant-compat/misc.gradle+++ /dev/null@@ -1,27 +0,0 @@-/*- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--// Resources from top-level project folder are looked up via getClass(). Strange.-configure(project(":lucene:benchmark")) {- plugins.withType(JavaPlugin) {- task syncConf(type: Sync) {- from('conf')- into file("${sourceSets.test.java.outputDir}/conf")- }- processTestResources.dependsOn syncConf- }-}diff --git a/gradle/hacks/turbocharge-jvm-opts.gradle b/gradle/hacks/turbocharge-jvm-opts.gradleindex cdb226a89b3..5682dc17ad1 100644--- a/gradle/hacks/turbocharge-jvm-opts.gradle+++ b/gradle/hacks/turbocharge-jvm-opts.gradle@@ -30,7 +30,12 @@ allprojects {// Inject vm options into any JavaExec task... We could narrow it// down but I don't think there is any harm in keeping it broad.- tasks.withType(JavaExec) {+ tasks.withType(JavaExec) { task ->+ // Skip tuning java exec for benchmarks.+ if (task.path == ":lucene:benchmark:run") {+ return+ }+jvmArgs += vmOpts}}\ No newline at end of filediff --git a/lucene/benchmark/build.gradle b/lucene/benchmark/build.gradleindex 9271b003710..565516a31cc 100644--- a/lucene/benchmark/build.gradle+++ b/lucene/benchmark/build.gradle@@ -19,7 +19,7 @@ plugins {id "java"}-description = 'System for benchmarking Lucene'+description = 'Lucene benchmarking module'dependencies {implementation project(':lucene:core')@@ -43,9 +43,15 @@ dependencies {testImplementation project(':lucene:test-framework')}+// We add 'conf' to resources because we validate *.alg script correctness in one of the tests.+sourceSets {+ test.resources.srcDirs += ['conf']+}+task run(type: JavaExec) {description "Run a perf test (optional: -PtaskAlg=conf/your-algorithm-file -PmaxHeapSize=1G)"main 'org.apache.lucene.benchmark.byTask.Benchmark'+classpath sourceSets.main.runtimeClasspath// allow these to be specified on the CLI via -PtaskAlg= for exampleargs = [propertyOrDefault('taskAlg', 'conf/micro-standard.alg')]diff --git a/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java b/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.javaindex 026a57198bc..b3ccee71863 100644--- a/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java+++ b/lucene/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksParse.java@@ -18,6 +18,7 @@ package org.apache.lucene.benchmark.byTask;import java.io.IOException;import java.io.StringReader;+import java.net.URL;import java.nio.charset.StandardCharsets;import java.nio.file.DirectoryStream;import java.nio.file.Files;@@ -35,6 +36,7 @@ import org.apache.lucene.benchmark.byTask.utils.Config;import org.apache.lucene.search.Query;import org.apache.lucene.util.LuceneTestCase;import org.apache.lucene.util.LuceneTestCase.SuppressSysoutChecks;+import org.junit.Assert;/** Test very simply that perf tasks are parsed as expected. */@SuppressSysoutChecks(bugUrl = "very noisy")@@ -122,9 +124,14 @@ public class TestPerfTasksParse extends LuceneTestCase {/** Test the parsing of example scripts * */@SuppressWarnings("try")public void testParseExamples() throws Exception {- // hackedy-hack-hack++ // Locate the folder with *.alg resources. This is hacky - we look up+ // one of the resources and then assume it's an accessible path.+ URL resource = getClass().getClassLoader().getResource("addIndexes.alg");+ Assert.assertNotNull("Couldn't locate *.alg resources?", resource);+boolean foundFiles = false;- final Path examplesDir = Paths.get(getClass().getResource("/conf").toURI());+ final Path examplesDir = Paths.get(resource.toURI()).getParent();try (DirectoryStream<Path> stream = Files.newDirectoryStream(examplesDir, "*.alg")) {for (Path path : stream) {Config config = new Config(Files.newBufferedReader(path, StandardCharsets.UTF_8));@@ -152,10 +159,12 @@ public class TestPerfTasksParse extends LuceneTestCase {config.set("query.maker", MockQueryMaker.class.getName());}PerfRunData data = new PerfRunData(config);- try (Algorithm algo = new Algorithm(data)) {}+ new Algorithm(data).close();+foundFiles = true;}}+if (!foundFiles) {fail("could not find any .alg files!");}