Skip to content

Commit

Permalink
Merge branch 'branch_9x' into fs/branch_9x
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Sweeney committed Jul 6, 2023
2 parents 969d241 + 246ac4b commit b9d1926
Show file tree
Hide file tree
Showing 227 changed files with 8,011 additions and 3,900 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,5 @@ jobs:
- name: Prepare caches
uses: ./.github/actions/gradle-caches

- name: Initialize gradle settings (${{ matrix.os }})
run: ./gradlew localSettings

- name: Run all distribution tests including GUI tests (${{ matrix.os }})
run: ./gradlew -p lucene/distribution.tests test
10 changes: 2 additions & 8 deletions .github/workflows/gradle-precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ jobs:
- name: Prepare caches
uses: ./.github/actions/gradle-caches

- name: Initialize gradle settings
run: ./gradlew localSettings --max-workers 2

- name: Run gradle check (without tests)
run: ./gradlew check -x test -Ptask.times=true --max-workers 2

Expand Down Expand Up @@ -72,11 +69,8 @@ jobs:
- name: Prepare caches
uses: ./.github/actions/gradle-caches

- name: Initialize gradle settings
run: ./gradlew localSettings --max-workers 2
- name: Run gradle tests
run: ./gradlew test "-Ptask.times=true" --max-workers 2

- name: Echo settings
run: cat gradle.properties

- name: Run gradle tests
run: ./gradlew test "-Ptask.times=true" --max-workers 2
3 changes: 0 additions & 3 deletions .github/workflows/hunspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@ jobs:
- name: Prepare caches
uses: ./.github/actions/gradle-caches

- name: Initialize gradle settings
run: ./gradlew localSettings

- name: Run regular and regression tests
run: ./gradlew -p lucene/analysis/common check testRegressions
6 changes: 0 additions & 6 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ The Apache Software Foundation (http://www.apache.org/).

Includes software from other Apache Software Foundation projects,
including, but not limited to:
- Apache Ant
- Apache Jakarta Regexp
- Apache Commons
- Apache Xerces
Expand Down Expand Up @@ -38,9 +37,6 @@ under the 2-clause BSD license.
The Google Code Prettify is Apache License 2.0.
See http://code.google.com/p/google-code-prettify/

JUnit (junit-4.10) is licensed under the Common Public License v. 1.0
See http://junit.sourceforge.net/cpl-v10.html

This product includes code (JaspellTernarySearchTrie) from Java Spelling Checkin
g Package (jaspell): http://jaspell.sourceforge.net/
License: The BSD License (http://www.opensource.org/licenses/bsd-license.php)
Expand Down Expand Up @@ -203,5 +199,3 @@ which can be obtained from

https://bitbucket.org/eunjeon/mecab-ko-dic/downloads/mecab-ko-dic-2.0.3-20170922.tar.gz

The floating point precision conversion in NumericUtils.Float16Converter is derived from work by
Jeroen van der Zijp, granted for use under the Apache license.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {
id "base"
id "com.palantir.consistent-versions" version "2.11.0"
id "org.owasp.dependencycheck" version "7.2.0"
id 'de.thetaphi.forbiddenapis' version '3.4' apply false
id 'de.thetaphi.forbiddenapis' version '3.5' apply false
id "de.undercouch.download" version "5.2.0" apply false
id "net.ltgt.errorprone" version "3.0.1" apply false
id 'com.diffplug.spotless' version "6.5.2" apply false
Expand Down Expand Up @@ -158,6 +158,7 @@ apply from: file('gradle/generation/javacc.gradle')
apply from: file('gradle/generation/forUtil.gradle')
apply from: file('gradle/generation/antlr.gradle')
apply from: file('gradle/generation/unicode-test-classes.gradle')
apply from: file('gradle/generation/panama-foreign.gradle')

apply from: file('gradle/datasets/external-datasets.gradle')

Expand Down
1 change: 1 addition & 0 deletions buildSrc/scriptDepVersions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ext {
scriptDepVersions = [
"apache-rat": "0.14",
"asm": "9.4",
"commons-codec": "1.13",
"ecj": "3.30.0",
"flexmark": "0.61.24",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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.
*/
package org.apache.lucene.gradle;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Map;

/**
* Standalone class that generates a populated gradle.properties from a template.
*
* <p>Has no dependencies outside of standard java libraries
*/
public class GradlePropertiesGenerator {
public static void main(String[] args) {
if (args.length != 2) {
System.err.println("Usage: java GradlePropertiesGenerator.java <source> <destination>");
System.exit(2);
}

try {
new GradlePropertiesGenerator().run(Paths.get(args[0]), Paths.get(args[1]));
} catch (Exception e) {
System.err.println("ERROR: " + e.getMessage());
System.exit(3);
}
}

public void run(Path source, Path destination) throws IOException {
if (!Files.exists(source)) {
throw new IOException("template file not found: " + source);
}
if (Files.exists(destination)) {
System.out.println(destination + " already exists, skipping generation.");
return;
}

// Approximate a common-sense default for running gradle/tests with parallel
// workers: half the count of available cpus but not more than 12.
var cpus = Runtime.getRuntime().availableProcessors();
var maxWorkers = (int) Math.max(1d, Math.min(cpus * 0.5d, 12));
var testsJvms = (int) Math.max(1d, Math.min(cpus * 0.5d, 12));

var replacements = Map.of("@MAX_WORKERS@", maxWorkers, "@TEST_JVMS@", testsJvms);

System.out.println("Generating gradle.properties");
String fileContent = Files.readString(source, StandardCharsets.UTF_8);
for (var entry : replacements.entrySet()) {
fileContent = fileContent.replace(entry.getKey(), String.valueOf(entry.getValue()));
}
Files.writeString(
destination, fileContent, StandardCharsets.UTF_8, StandardOpenOption.CREATE_NEW);
}
}
4 changes: 1 addition & 3 deletions dev-tools/scripts/releaseWizard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,6 @@ groups:
- !Command
cmd: git pull --ff-only
stdout: true
- !Command
cmd: "{{ gradle_cmd }} localSettings"
- !Command
cmd: "{{ gradle_cmd }} clean check -x test"
- !Todo
Expand Down Expand Up @@ -933,7 +931,7 @@ groups:
commands_text: In the source checkout do the following (note that this step will prompt you for your Apache LDAP credentials)
commands:
- !Command
cmd: java dev-tools/scripts/StageArtifacts.java --user {{ gpg.apache_id }} --description "{{ 'Apache Lucene ', release_version, ' (commit ', git_sha, ')' }}" "{{ [dist_file_path, dist_folder, 'solr', 'maven'] | path_join }}"
cmd: java dev-tools/scripts/StageArtifacts.java --user {{ gpg.apache_id }} --description "{{ 'Apache Lucene ', release_version, ' (commit ', git_sha, ')' }}" "{{ [dist_file_path, dist_folder, 'lucene', 'maven'] | path_join }}"
tee: true
logfile: publish_lucene_maven.log
post_description: The artifacts are not published yet, please proceed with the next step to actually publish!
Expand Down
3 changes: 0 additions & 3 deletions dev-tools/scripts/smokeTestRelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,6 @@ def verifyUnpacked(java, artifact, unpackPath, gitRevision, version, testArgs):
print(' %s' % line.strip())
raise RuntimeError('source release has WARs...')

print(' initialize local settings for Gradle...')
java.run_java11('./gradlew --no-daemon localSettings', '%s/localsettings.log' % unpackPath)

validateCmd = './gradlew --no-daemon check -p lucene/documentation'
print(' run "%s"' % validateCmd)
java.run_java11(validateCmd, '%s/validate.log' % unpackPath)
Expand Down
76 changes: 3 additions & 73 deletions gradle/generation/local-settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,82 +41,12 @@ configure(rootProject) {
throw new GradleException(
"Certain gradle tasks and plugins require access to jdk.compiler" +
" internals, your gradle.properties might have just been generated or could be" +
" out of sync (see help/localSettings.txt)")
}
}
}

task localSettings() {
doFirst {
// If we don't have the defaults yet, create them.
if (hasDefaults) {
logger.lifecycle("Local settings already exist, skipping generation.")
} else {
// Approximate a common-sense default for running gradle/tests with parallel
// workers: half the count of available cpus but not more than 12.
def cpus = Runtime.runtime.availableProcessors()
def maxWorkers = (int) Math.max(1d, Math.min(cpus * 0.5d, 12))
def testsJvms = (int) Math.max(1d, Math.min(cpus * 0.5d, 12))

// Write the defaults for this machine.
rootProject.file("gradle.properties").write("""
# These settings have been generated automatically on the first run.
# See gradlew :helpLocalSettings for more information.
systemProp.file.encoding=UTF-8
# Set up gradle JVM defaults.
#
# We also open up internal compiler modules for spotless/ google java format.
org.gradle.jvmargs=-Xmx1g -XX:TieredStopAtLevel=1 -XX:+UseParallelGC -XX:ActiveProcessorCount=1 \\
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \\
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \\
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \\
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \\
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
# Run at normal priority, in parallel
org.gradle.parallel=true
org.gradle.priority=normal
# Silence gradle warnings. We'll deal with them when we upgrade the wrapper.
org.gradle.warning.mode=none
# You may disable the background daemon if it consumes too much memory.
org.gradle.daemon=true
# timeout after 15 mins of inactivity.
org.gradle.daemon.idletimeout=900000
# Maximum number of parallel gradle workers.
org.gradle.workers.max=${maxWorkers}
# Maximum number of test JVMs forked per test task.
tests.jvms=${testsJvms}
# Enable auto JVM provisioning.
org.gradle.java.installations.auto-download=true
# Set these to enable automatic JVM location discovery.
org.gradle.java.installations.fromEnv=JAVA17_HOME,JAVA19_HOME,JAVA20_HOME,JAVA21_HOME,RUNTIME_JAVA_HOME
#org.gradle.java.installations.paths=(custom paths)
""", "UTF-8")

logger.log(LogLevel.WARN, "\nIMPORTANT. This is the first time you ran the build. " +
"I wrote some sane defaults (for this machine) to 'gradle.properties', " +
"they will be picked up on consecutive gradle invocations (not this one).\n\n" +
"Run gradlew :helpLocalSettings for more information.")
" out of sync (see gradle/template.gradle.properties)")
}
}
}
}

if (!hasDefaults) {
// Make all tasks depend on local setup to make sure it'll run.
allprojects {
tasks.all { task ->
if (task != rootProject.localSettings) {
task.dependsOn rootProject.localSettings
}
}
}
task localSettings() {
// This is just a placeholder until all references to the localSettings task are removed
}
65 changes: 65 additions & 0 deletions gradle/generation/panama-foreign.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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.
*/

def resources = scriptResources(buildscript)

configure(project(":lucene:core")) {
ext {
apijars = file('src/generated/jdk');
panamaJavaVersions = [ 19, 20 ]
}

configurations {
apiextractor
}

dependencies {
apiextractor "org.ow2.asm:asm:${scriptDepVersions['asm']}"
}

for (jdkVersion : panamaJavaVersions) {
def task = tasks.create(name: "generatePanamaForeignApiJar${jdkVersion}", type: JavaExec) {
description "Regenerate the API-only JAR file with public Panama Foreign API from JDK ${jdkVersion}"
group "generation"

javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(jdkVersion)
}

onlyIf {
try {
javaLauncher.get()
return true
} catch (Exception e) {
logger.warn('Launcher for Java {} is not available; skipping regeneration of Panama Foreign API JAR.', jdkVersion)
logger.warn('Error: {}', e.cause?.message)
logger.warn("Please make sure to point env 'JAVA{}_HOME' to exactly JDK version {} or enable Gradle toolchain auto-download.", jdkVersion, jdkVersion)
return false
}
}

classpath = configurations.apiextractor
mainClass = file("${resources}/ExtractForeignAPI.java") as String
args = [
jdkVersion,
new File(apijars, "panama-foreign-jdk${jdkVersion}.apijar"),
]
}

regenerate.dependsOn task
}
}
Loading

0 comments on commit b9d1926

Please sign in to comment.