All, I've been trying to use Gradle to start a Solr instance, create a core, and then shut down the instance. I'm doing this to produce an installer to deploy a preconfigured deployment of Nutch, along with Hadoop and Solr, onto Windows machines. I've been trying a variety of approaches and have realized I have no idea how to do this. Is there an existing example that is known to work? Below is my initial code. It seemed an obvious approach, but after days of making changes to it involving nesting operations into bat scripts, trying API calls, and even kill commands, I realized it was probably a completely wrong approach.
Thanks in advance, John P.S. I run this via "gradle setupAndCreateCore --info --stacktrace", where the solar distribution is in a ./solr directory from the build.gradle file. plugins { id 'base' // Base plugin for lifecycle tasks } // def solrHome = "$buildDir/solr" // Define a working directory for Solr def solrHome = "$projectDir/solr" // Define a working directory for Solr def solrPort = 8983 def solrCoreName = "nutch" def solrConfigDir = "server/solr/configsets/nutch/conf" def solrExecutable = "${solrHome}/bin/solr.cmd" // Use bin/solr for Linux/Mac // Task to download and extract Solr if necessary task setupSolr { description = 'Sets up Solr directory if not already set up.' doLast { println "Ensure Solr is installed and accessible." } } // Task to start the Solr instance task startSolr(dependsOn: setupSolr) { description = 'Starts the Solr instance.' doLast { exec { workingDir solrHome commandLine solrExecutable, 'start', '-p', solrPort.toString() } } } // Task to create a new core task createCore(dependsOn: startSolr) { description = 'Creates a new Solr core.' doLast { exec { workingDir solrHome commandLine solrExecutable, 'create', '-p', solrPort.toString(), '-c', solrCoreName, '-d', solrConfigDir } } } // Task to stop the Solr instance task stopSolr { description = 'Stops the Solr instance.' doLast { exec { workingDir solrHome commandLine solrExecutable, 'stop', '-p', solrPort.toString() } } } // A lifecycle task to handle all operations task setupAndCreateCore { description = 'Sets up Solr, starts it, creates the core, and shuts it down.' dependsOn startSolr, createCore, stopSolr }