Skip to content

Instantly share code, notes, and snippets.

@stephanos
Created January 27, 2014 11:57
Show Gist options
  • Save stephanos/8647374 to your computer and use it in GitHub Desktop.
Save stephanos/8647374 to your computer and use it in GitHub Desktop.
def IDEA_MODULE_NAME = 'mymodule'
def IDEA_ARTIFACT_NAME = 'myproject'
def artifactManager = xmlFile.asNode().component.find { it.@name == 'ArtifactManager' } as Node
if (artifactManager) {
Node artifact = artifactManager.artifact.find { it.@type == 'exploded-war' }
if (artifact)
artifactManager.remove(artifact)
} else {
artifactManager = xmlFile.asNode().appendNode('component', [name: 'ArtifactManager']);
}
def artifact = new NodeBuilder().artifact(type: 'exploded-war', 'build-on-make': "true", name: "$IDEA_ARTIFACT_NAME") {
'output-path'("\$PROJECT_DIR\$/$IDEA_BUILD_APP_DIR")
root(id: 'root') {
element(id: 'directory', name: 'WEB-INF') {
element(id: 'directory', name: 'classes') {
element(id: 'module-output', name: IDEA_MODULE_NAME)
}
element(id: 'directory', name: 'lib') {
this.project.configurations.runtime.each {
element(id: 'file-copy', path: it)
}
}
}
element(id: 'javaee-facet-resources', facet: "$IDEA_MODULE_NAME/web/Web")
}
}
artifactManager.append artifact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment