Created
October 9, 2012 09:45
-
-
Save fbricon/3857677 to your computer and use it in GitHub Desktop.
Make JDF quickstarts available as importable projects in JBoss Tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def basedir = project.basedir.canonicalPath.replace("\\", "/") | |
def version = "4.0.0" | |
def examplesBaseUrl = System.getProperty('examples.base.url')?:"http://download.jboss.org/jbosstools/examples/${version}"; | |
if (examplesBaseUrl.endsWith("/")) { | |
examplesBaseUrl = examplesBaseUrl.substring(0, examplesBaseUrl.length() -1); | |
} | |
def zipDir = new File(project.build.directory,"zips") | |
//def ant = new AntBuilder(); already available in gmaven's context | |
println "Starting zipping ${project.name} modules" | |
if (zipDir.exists()){ | |
println "Deleting ${zipDir}" | |
zipDir.delete() | |
} | |
zipDir.mkdirs() | |
project.modules.each { module -> | |
def zip = zipDir.canonicalPath.replace("\\", "/") + "/${module}.zip" | |
def source = "${basedir}/${module}" | |
println "Zipping ${source} to ${zip}" | |
ant.zip(baseDir: source, destFile: zip, excludes: "target/") | |
} | |
println "Zipping complete" | |
builder = new groovy.xml.StreamingMarkupBuilder() | |
builder.encoding = "UTF-8" | |
xmlDocument = builder.bind { | |
mkp.xmlDeclaration() | |
projects() { | |
for (module in project.modules) { | |
def zip = new File(zipDir, "${module}.zip") | |
if (zip.exists()) { | |
def p = getModel("${basedir}/${module}/pom.xml") | |
if (p) { | |
project { | |
id(module) | |
name(module) | |
category("JBoss Developer Framework") | |
shortDescription(p.name.text()) | |
description(p.description.text()) | |
url("${examplesBaseUrl}/${module}.zip") | |
size(zip.length()) | |
importType("maven") | |
icon(path:"icons/jboss.png") | |
tags("central") | |
"included-projects"() | |
fixes() { | |
fix(type:"wtpruntime") { | |
property(name:"allowed-types", "org.jboss.ide.eclipse.as.runtime.71, org.jboss.ide.eclipse.as.runtime.eap.60") | |
property(name:"description", "This project example requires JBoss Enterprise Application Platform 6 or JBoss Application Server 7.1") | |
property(name:"downloadId", "org.jboss.tools.runtime.core.as.711") | |
} | |
fix(type:"plugin") { | |
property(name:"id", "org.eclipse.m2e.core") | |
property(name:"versions", "[1.0.0,2.0.0)") | |
property(name:"description", "This project example requires m2e >= 1.1.") | |
property(name:"connectorIds", "org.eclipse.m2e.feature") | |
} | |
fix(type:"plugin") { | |
property(name:"id", "org.eclipse.m2e.wtp") | |
property(name:"versions", "[0.16.0,2.0.0)") | |
property(name:"description", "This project example requires m2e-wtp >= 0.16.0.") | |
property(name:"connectorIds", "org.maven.ide.eclipse.wtp.feature") | |
} | |
fix(type:"plugin") { | |
property(name:"id", "org.jboss.tools.maven.core") | |
property(name:"versions", "[1.4.0,2.0.0)") | |
property(name:"description", "This project example requires JBoss Maven Tools.") | |
property(name:"connectorIds", "org.jboss.tools.maven.feature,org.jboss.tools.maven.cdi.feature,org.jboss.tools.maven.hibernate.feature,org.jboss.tools.maven.jaxrs.feature") | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
xmlDocument.writeTo( new File(zipDir, 'quickstarts.xml').newWriter() ) | |
def Node getModel(String pom) { | |
new XmlParser().parse(pom) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment