Jump to content
Excelsior Forums

AndyDenby

Members
  • Content count

    0
  • Joined

  • Last visited

Everything posted by AndyDenby

  1. AndyDenby

    Load external configuration file

    am using the Excelsior Jet Gradle plug-in to secure our java web application based on Ratpack. Using the excelsiorJet block below I have successfully compiled and ran the application using gradle jetTestRun. excelsiorJet { //UNCOMMENT THIS ONCE YOU HAVE RUN GRADLE TEST RUN globalOptimizer = true mainClass = 'ratpack.groovy.GroovyRatpackMain' groupId = 'com.reshufl' version = '1.0.1' //jvmArgs "-Xms256m", "-Xmx512m", "-Djava.class.path=./config/" jvmArgs "-Xms256m", "-Xmx512m" stackAllocation = true inlineExpansion = 'aggressive' compilerOptions = ["-Djet.gc.ratio=11", "-Djet.gc.no.swap", "-Djava.class.path=./config/application.properties"] //compilerOptions = ["-Djet.gc.ratio=11", "-Djet.gc.no.swap"] optimizationPreset = 'smart' dependencies { dependency { groupId = 'com.reshufl' isLibrary = false } //dependency { // path = new File(project.projectDir, "src/ratpack/application.properties") // packagePath = 'config' // pack = 'none' //} } packageFiles { file { path = new File(project.projectDir, "src/ratpack/application.properties") packagePath = "config" } } runtime { flavor = 'server' components = ['jce'] } } On startup Ratpack is configured to load the configuration file "src/ratpack/application.properties" that is currently being built into the deployment package. I am trying to externalize this configuration file so that it is read from a config directory created by the installer so that the end user can modify the application properties on start-up. So far I managed to create a copy of the file under the config directory however I've been unable to modify the classpath to read this version of the file first. I've looked at the documentation but just don't seem to be able to get this going. Please could you point me in the right direction for how to do this using the gradle plug in.
  2. AndyDenby

    Load external configuration file

    Managed to get this going with the following excelsiorJet block. Key points in bold. 1. Add the classpath to the jvmArgs 2. Add the dependency block to copy the config files from src/ratpack to the config/ratpack folder under app excelsiorJet { // UNCOMMENT THIS ONCE YOU HAVE RUN GRADLE TEST RUN globalOptimizer = true // ONCE YOU HAVE EVERYTHING ELSE WORKING TRY... // protectData = true mainClass = 'ratpack.groovy.GroovyRatpackMain' groupId = 'com.group' version = '1.0.1' artifactName = 'myartifact' jvmArgs "-Djava.class.path=\$(Root)/config/ratpack", "-Xms256m", "-Xmx512m" stackAllocation = true inlineExpansion = 'aggressive' optimizationPreset = 'smart' compilerOptions = ["-Djet.gc.ratio=11", "-Djet.gc.no.swap"] dependencies { dependency { groupId = 'com.reshufl' isLibrary = false } dependency { path = new File(project.projectDir, "src/ratpack/") packagePath = 'config' pack = 'none' protect='not-required' optimize='auto-detect' } } runtime { flavor = 'server' components = ['jce'] } } Issue closed.
×