# python BuildArchetypes.py version fw-repo-id archetype-repo-id plugin-repo-id
#
-import subprocess
-from BuildHelpers import mavenValidate, copyWarFiles, repo, getLogFile, mavenCmd, updateRepositories, getArgs, removeDir, parser, resultPath
+import subprocess, sys
+from BuildHelpers import mavenValidate, copyWarFiles, getLogFile, mavenCmd, updateRepositories, getArgs, removeDir, parser, resultPath
from DeployHelpers import deployWar
## DEFAULT VARIABLES ##
## BUILDING METHODS ##
# Generates and modifies a maven pom file
-def generateArchetype(archetype):
- artifactId = "test-%s-%s" % (archetype, args.version.replace(".", "-"))
-
+def generateArchetype(archetype, artifactId):
# Generate the required command line for archetype generation
cmd = [mavenCmd, "archetype:generate"]
cmd.append("-DarchetypeGroupId=%s" % (archetypeGroup))
cmd.append("-Dversion=1.0-SNAPSHOT")
cmd.append("-DinteractiveMode=false")
if hasattr(args, "maven") and args.maven is not None:
- cmd.extends(args.maven.split(" "))
+ cmd.extend(args.maven.strip('"').split(" "))
# Generate pom.xml
print("Generating pom.xml for archetype %s" % (archetype))
subprocess.check_call(cmd, cwd=resultPath, stdout=log)
- # Return the artifactId so we know the name in the future
- return artifactId
-
## DO THIS IF RUN AS A SCRIPT (not import) ##
if __name__ == "__main__":
# Add command line arguments for staging repos
parser.add_argument("framework", type=int, help="Framework repo id (comvaadin-XXXX)", nargs='?')
parser.add_argument("archetype", type=int, help="Archetype repo id (comvaadin-XXXX)", nargs='?')
parser.add_argument("plugin", type=int, help="Maven Plugin repo id (comvaadin-XXXX)", nargs='?')
+ parser.add_argument("--repo", type=str, help="Staging repository template", required=True)
archetypesFailed = False
# Parse the arguments
args = getArgs()
+
+ if hasattr(args, "artifactPath") and args.artifactPath is not None:
+ raise Exception("Archetype validation build does not support artifactPath")
+
for archetype in archetypes:
+ artifactId = "test-%s-%s" % (archetype, args.version.replace(".", "-"))
try:
log = getLogFile(archetype)
- artifactId = generateArchetype(archetype)
+ generateArchetype(archetype, artifactId)
updateRepositories(artifactId)
mavenValidate(artifactId, logFile=log)
warFiles = copyWarFiles(artifactId, name=archetype)
for war in warFiles:
try:
- deployWar(war, "%s.war" % (archetype.split("-", 2)[2]))
+ deployWar(war, "%s-%s.war" % (archetype.split("-", 2)[2], args.version))
except Exception as e:
print("War %s failed to deploy: %s" % (war, e))
archetypesFailed = True
- except:
- print("Archetype %s build failed" % (archetype))
+ except Exception as e:
+ print("Archetype %s build failed" % (archetype, e))
archetypesFailed = True
removeDir(artifactId)
print("")
import sys, os
from os.path import join, isfile
from fnmatch import fnmatch
+from xml.etree.ElementTree import ElementTree
# Validated demos. name -> git url
demos = {
except:
print("BuildDemos depends on gitpython. Install it with `pip install gitpython`")
sys.exit(1)
- from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir, getArgs, mavenInstall, resultPath
+ from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir, getArgs, mavenInstall, resultPath, readPomFile
from DeployHelpers import deployWar
-
if hasattr(getArgs(), "artifactPath") and getArgs().artifactPath is not None:
+ version = False
basePath = getArgs().artifactPath
poms = []
for root, dirs, files in os.walk(basePath):
mavenInstall(pom, jarFile)
else:
mavenInstall(pom)
-
+ if "vaadin-server" in pom:
+ pomXml, nameSpace = readPomFile(pom)
+ for version in pomXml.getroot().findall("./{%s}version" % (nameSpace)):
+ getArgs().version = version.text
demosFailed = False
for demo in demos:
# Default argument parser
parser = argparse.ArgumentParser(description="Automated staging validation")
-parser.add_argument("version", type=str, help="Vaadin version to use")
+group = parser.add_mutually_exclusive_group(required=True)
+group.add_argument("--version", help="Vaadin version to use")
+group.add_argument("--artifactPath", help="Path to local folder with Vaadin artifacts")
+
parser.add_argument("--maven", help="Additional maven command line parameters", default=None)
-parser.add_argument("--artifactPath", help="Path to local folder with Vaadin artifacts", default=None)
# Parse command line arguments <version>
def parseArgs():
copiedWars.append(join(resultDir, deployName))
return copiedWars
+def readPomFile(pomFile):
+ # pom.xml namespace workaround
+ root = ElementTree.parse(pomFile).getroot()
+ nameSpace = root.tag[1:root.tag.index('}')]
+ print("Using namespace: %s" % (nameSpace))
+ ElementTree.register_namespace('', nameSpace)
+
+ # Read the pom.xml correctly
+ return ElementTree.parse(pomFile), nameSpace
+
# Recursive pom.xml update script
def updateRepositories(path, repoIds = None, repoUrl = repo):
# If versions are not supplied, parse arguments
# Read pom.xml
pomXml = join(path, "pom.xml")
if isfile(pomXml):
- # pom.xml namespace workaround
- root = ElementTree.parse(pomXml).getroot()
- nameSpace = root.tag[1:root.tag.index('}')]
- ElementTree.register_namespace('', nameSpace)
-
# Read the pom.xml correctly
- tree = ElementTree.parse(pomXml)
+ tree, nameSpace = readPomFile(pomXml)
# NameSpace needed for finding the repositories node
repoNode = tree.getroot().find("{%s}repositories" % (nameSpace))