Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-16641 - Generate gradle.properties from template #1322

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/bin-solr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-binsolr-
${{ runner.os }}-gradle-
- name: Initialize gradle settings
run: ./gradlew localSettings
- name: Test the bin/solr script
run: ./gradlew integrationTests
- name: Archive logs
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-docker-
${{ runner.os }}-gradle-
- name: Initialize gradle settings
run: ./gradlew localSettings
- name: Build Docker image with Gradle
run: ./gradlew solr:docker:docker
- name: Run tests on Docker image
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/gradle-precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ jobs:
${{ runner.os }}-gradle-precommit-
${{ runner.os }}-gradle-

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

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

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/solrj-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,5 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-solrj-
${{ runner.os }}-gradle-
- name: Initialize gradle settings
run: ./gradlew localSettings
- name: Test the SolrJ Package
run: ./gradlew solr:solrj:test
1 change: 1 addition & 0 deletions dev-docs/how-to-contribute.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ In order to make a new contribution to Solr you will use the fork you have creat
1. Create a new Jira issue in the Solr project: https://issues.apache.org/jira/projects/SOLR/issues
2. Create a new branch in your Solr fork to provide a PR for your contribution on the newly created issue. Make any necessary changes for the given bug/feature in that branch. You can use additional information in these dev-docs to build and test your code as well as ensure it passes code quality checks.
3. Once you are satisfied with your changes, get your branch ready for a PR by running `./gradlew tidy updateLicenses check -x test`. This will format your source code, update licenses of any dependency version changes and run all pre-commit tests. Commit the changes.
* Note: the `check` command requires `perl` and `python3` to be present on your `PATH` to validate documentation.
4. Open a PR of your branch against the `main` branch of the apache/solr repository. When you open a PR on your fork, this should be the default option.
* The title of your PR should include the Solr Jira issue that you opened, i.e. `SOLR-12345: New feature`.
* The PR description will automatically populate with a pre-set template that you will need to fill out.
Expand Down
2 changes: 2 additions & 0 deletions dev-docs/solr-source-code.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ If you want to build the documentation, type `./gradlew -p solr documentation`.

`./gradlew check` will assemble Solr and run all validation tasks unit tests.

NOTE: the `check` command requires `perl` and `python3` to be present on your `PATH` to validate documentation.

To build the final Solr artifacts run `./gradlew assemble`.

Lastly, there is developer oriented documentation in `./dev-docs/README.adoc` that
Expand Down
2 changes: 0 additions & 2 deletions dev-tools/scripts/releaseWizard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,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
43 changes: 43 additions & 0 deletions gradle.properties.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# See gradlew :helpLocalSettings for more information on configuring this file.
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

# This setting enables local task output caches. This will speed up
# your local builds in most cases but will also consume disk space in your
# gradle home. See SOLR-15603 for details.
# org.gradle.caching=true

# 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=8

# Maximum number of test JVMs forked per test task.
tests.jvms=8

# Disable auto JVM provisioning (we don't use toolchains yet but want no surprises).
org.gradle.java.installations.auto-download=false

# Set these to enable automatic JVM location discovery.
org.gradle.java.installations.fromEnv=JDK11,JDK12,JDK13,JDK14,JDK15,JDK16,JDK17
org.gradle.java.installations.paths=(custom paths)

79 changes: 0 additions & 79 deletions gradle/generation/local-settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,83 +45,4 @@ configure(rootProject) {
}
}
}

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

# This setting enables local task output caches. This will speed up
# your local builds in most cases but will also consume disk space in your
# gradle home. See SOLR-15603 for details.
# org.gradle.caching=true

# 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}

# Disable auto JVM provisioning (we don't use toolchains yet but want no surprises).
org.gradle.java.installations.auto-download=false

# Set these to enable automatic JVM location discovery.
org.gradle.java.installations.fromEnv=JDK11,JDK12,JDK13,JDK14,JDK15,JDK16,JDK17
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.")
}
}
}
}

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
}
}
}
}
2 changes: 1 addition & 1 deletion gradle/validation/gradlew-scripts-tweaked.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ configure(rootProject) {
doFirst {
scripts.each { file ->
def content = new String(file.readBytes(), StandardCharsets.US_ASCII)
if (content.indexOf("Don't fork a daemon mode on initial run that generates local defaults") < 0) {
if (content.indexOf("gradle.properties.template") < 0) {
throw new GradleException("Launch script ${file} does not have a manual daemon tweak (see LUCENE-9232).")
}
}
Expand Down
15 changes: 11 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,18 @@ fi

CLASSPATH=$GRADLE_WRAPPER_JAR

# Don't fork a daemon mode on initial run that generates local defaults.
GRADLE_DAEMON_CTRL=
# Generate gradle.properties if they don't exist
if [ ! -e "$APP_HOME/gradle.properties" ]; then
GRADLE_DAEMON_CTRL=--no-daemon
echo "Populating gradle.properties from gradle.properties.template."
# Do the copy first. If the next steps fail, the gradle.properties will still be usable
cp gradle.properties.template gradle.properties
colvinco marked this conversation as resolved.
Show resolved Hide resolved
NUM_CORES=$(grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}')
colvinco marked this conversation as resolved.
Show resolved Hide resolved
if [ $NUM_CORES -ge 12 ]; then
NUM_CORES=12
fi
sed -i "s/org.gradle.workers.max=[[:digit:]]\+/org.gradle.workers.max=${NUM_CORES}/g;s/tests.jvms=[[:digit:]]\+/tests.jvms=${NUM_CORES}/g" gradle.properties
echo "Set org.gradle.workers.max and tests.jvm to $NUM_CORES"
echo "You can configure gradle.properties as required. See './gradlew :helpLocalSettings' for more information"
fi

# Increase the maximum file descriptors if we can.
Expand Down Expand Up @@ -237,7 +245,6 @@ set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
$GRADLE_DAEMON_CTRL \
"$@"

# Stop when "xargs" is not available.
Expand Down
11 changes: 7 additions & 4 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,15 @@ IF %ERRORLEVEL% NEQ 0 goto fail
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Don't fork a daemon mode on initial run that generates local defaults.
SET GRADLE_DAEMON_CTRL=
IF NOT EXIST "%DIRNAME%\gradle.properties" SET GRADLE_DAEMON_CTRL=--no-daemon
@rem Generate gradle.properties if they don't exist
IF NOT EXIST "%DIRNAME%\gradle.properties" (
echo Copying gradle.properties.template to gradle.properties
copy gradle.properties.template gradle.properties > NUL
echo You can configure gradle.properties as required. See "gradlew :helpLocalSettings" for more information
)

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %GRADLE_DAEMON_CTRL% %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down