Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let's say you have configured a multi-project build with the following directory and file structure:</p> <pre><code>/combined-war /main-project /src /webapp /WEB-INF web.xml build.gradle /other-project /resources /WEB-INF /classes config.txt build.gradle build.gradle </code></pre> <p>In order to allow <code>jettyRun</code> to combine the contents of the <code>webapp</code> directory from <code>main-project</code> with the contents of the <code>resources</code> directory in <code>other-project</code> you need to add a workaround to your <code>build.gradle</code> of <code>main-project</code> (I've adapted the one posted by the user <a href="https://gist.github.com/siasia/1618850" rel="nofollow">siasia on gist</a>).</p> <p>Adding the same directory content to the war file is quite simple and is documented in the <a href="http://www.gradle.org/docs/current/userguide/war_plugin.html" rel="nofollow">Gradle User Guide</a> and and the <a href="http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.bundling.War.html" rel="nofollow">DSL reference</a>.</p> <pre class="lang-java prettyprint-override"><code>apply plugin: 'java' apply plugin: 'war' apply plugin: 'jetty' import org.gradle.api.plugins.jetty.internal.JettyPluginWebAppContext def newResourceCollection(File... resources) { def script = ''' import org.mortbay.resource.ResourceCollection new ResourceCollection(resources) ''' def shell = new GroovyShell(JettyPluginWebAppContext.class.classLoader) shell.setProperty("resources", resources as String[]) return shell.evaluate(script) } jettyRun.doFirst { jettyRun.webAppConfig = new JettyPluginWebAppContext() jettyRun.webAppConfig.baseResource = newResourceCollection( // list the folders that should be combined file(webAppDirName), file("${project(':other-project').projectDir}/resources") ) } war { from("${project(':other-project').projectDir}/resources") } </code></pre> <p>Whenever you execute <code>gradle jettyRun</code> a new <code>ResourceCollection</code> is created that combines the given directories. Per default Jetty locks (at least on Windows) all the files it's serving. So, in case you want to edit those files while Jetty is running take a look at the <a href="https://www.assembla.com/spaces/liftweb/wiki/Fix_file_locking_problem_with_jettyrun" rel="nofollow">following solutions</a>.</p> <p><strong>Update</strong></p> <p>Since <code>other-project</code> in this case is not another Gradle project the two tasks in <code>build.gradle</code> should look like that:</p> <pre class="lang-java prettyprint-override"><code>jettyRun.doFirst { jettyRun.webAppConfig = new JettyPluginWebAppContext() jettyRun.webAppConfig.baseResource = newResourceCollection( file(webAppDirName), file("$projectDir/../other-project/resources") ) } war { from("$projectDir/../other-project/resources") } </code></pre> <p>I'm not aware of any solution that adds only one file (e.g. <code>config.txt</code>). You'll always have to add a complete directory.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload