Skip to content

Commit d6c8095

Browse files
authored
New gradle runDev alternative to "dev" (#3816)
1 parent 50808cd commit d6c8095

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

dev-docs/gradle-help/workflow.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ Put together a local Solr binary "distribution" folder:
3131
gradlew -p solr/packaging assemble
3232
ls solr/packaging/build/solr-* # expanded directory
3333

34-
For quick local development
35-
gradlew -p solr/packaging dev
36-
ls solr/packaging/build/dev # expanded directory
34+
Build & run Solr directly from Gradle, skipping "bin/solr", retaining data between runs:
35+
gradlew -p solr/packaging runDev
36+
37+
Build & run Solr, retaining data between runs:
38+
gradlew -p solr/packaging devSlim
39+
(cd solr/packaging/build/dev-slim && bin/solr start -f)
3740

3841
Generate the release tar archive (see publishing.txt for details)
3942
gradlew -p solr/distribution assembleRelease
4043
ls solr/distribution/build/release # release archives
4144

42-
Build a docker image from the local repository (see docker/gradle-help.txt for more)
45+
Build & run a docker image from the local repository (see docker/gradle-help.txt for more)
4346
gradlew dockerBuild dockerTag
4447
docker run --rm -p 8983:8983 apache/solr:9.0.0-SNAPSHOT
4548

gradle/help.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ configure(rootProject) {
4646
doLast {
4747
println ""
4848
println "This is the Solr gradle build. See some guidelines, "
49-
println "ant-equivalent commands, etc. under help/*; or type:"
49+
println "ant-equivalent commands, etc. under dev-docs/gradle-help/*; or type:"
5050
println ""
5151
helpFiles.each { section, path, sectionInfo ->
5252
println String.format(Locale.ROOT,

solr/packaging/build.gradle

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,39 @@ artifacts {
215215
solrSlimTgz(slimDistTar)
216216
}
217217

218+
tasks.register('runDev', JavaExec) {
219+
group = 'application'
220+
description = 'Starts Solr for local experimentation. Does NOT use the bin/solr script.'
221+
dependsOn 'devSlim'
222+
223+
workingDir = file("$slimDevDir/server")
224+
225+
// Intentionally not synchronizing the logic here with bin/solr; don't want the burden
226+
227+
doFirst {
228+
println "To attach a debugger, at the CLI pass: --debug-jvm"
229+
println "To pass JVM args, at the CLI pass: -PjvmArgs='--add-modules jdk.incubator.vector'"
230+
println "To pass system properties, at the CLI pass: -Dsolr.port.listen=8983"
231+
}
232+
233+
maxHeapSize = project.findProperty('maxHeapSize') ?: '1G'
234+
235+
jvmArgs = [] // don't use defaults from our build that assume this is a typical build task
236+
jvmArgs((project.findProperty('jvmArgs') ?: '').split())
237+
238+
systemProperty 'solr.port.listen', '8983'
239+
systemProperty 'solr.install.dir', file("$workingDir/..")
240+
systemProperty 'solr.logs.dir', file("$workingDir/logs")
241+
systemProperty 'solr.zookeeper.server.enabled', 'true' // SolrCloud; embedded ZK
242+
243+
// Propagate CLI system properties (override defaults above)
244+
systemProperties += gradle.startParameter.systemPropertiesArgs
245+
246+
classpath = files("$workingDir/start.jar")
247+
248+
args((project.findProperty('args') ?: '--module=http').split())
249+
}
250+
218251
task downloadBats(type: NpmTask) {
219252
group = 'Build Dependency Download'
220253
args = ["install", "https://github.com/bats-core/bats-core#v${libs.versions.bats.core.get()}",

0 commit comments

Comments
 (0)