diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-09-07 16:27:25 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-09-07 16:27:25 +0300 |
commit | df80f003108d5f803717ecd7d8789d865b30731a (patch) | |
tree | 8695b2da33ae8e8eaa501dbbc51f0f60145c7f7f /scripts/BuildHelpers.py | |
parent | 89b40a5d8d6e37fabee7a436a6b1d494c9b2e1bf (diff) | |
download | vaadin-framework-df80f003108d5f803717ecd7d8789d865b30731a.tar.gz vaadin-framework-df80f003108d5f803717ecd7d8789d865b30731a.zip |
Combine Archetype and Demo build scripts (#9943)
Diffstat (limited to 'scripts/BuildHelpers.py')
-rw-r--r-- | scripts/BuildHelpers.py | 76 |
1 files changed, 20 insertions, 56 deletions
diff --git a/scripts/BuildHelpers.py b/scripts/BuildHelpers.py index 9803e310fc..9dd7ab66e0 100644 --- a/scripts/BuildHelpers.py +++ b/scripts/BuildHelpers.py @@ -102,55 +102,26 @@ def copyWarFiles(artifactId, resultDir = resultPath, name = None): 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('}')] - ElementTree.register_namespace('', nameSpace) - - # Read the pom.xml correctly - return ElementTree.parse(pomFile), nameSpace - -# Recursive pom.xml update script -def updateRepositories(path, repoUrl = None, version = None, postfix = "staging"): - # If versions are not supplied, parse arguments - if version is None: - version = getArgs().version - - # Read pom.xml - pomXml = join(path, "pom.xml") - if isfile(pomXml): - # Read the pom.xml correctly - tree, nameSpace = readPomFile(pomXml) - - # NameSpace needed for finding the repositories node - repoNode = tree.getroot().find("{%s}repositories" % (nameSpace)) - else: - return - - if repoNode is not None: - print("Add staging repositories to " + pomXml) - - # Add framework staging repository - addRepo(repoNode, "repository", "vaadin-%s-%s" % (version, postfix), repoUrl) - - # Find the correct pluginRepositories node - pluginRepo = tree.getroot().find("{%s}pluginRepositories" % (nameSpace)) - if pluginRepo is None: - # Add pluginRepositories node if needed - pluginRepo = ElementTree.SubElement(tree.getroot(), "pluginRepositories") - - # Add plugin staging repository - addRepo(pluginRepo, "pluginRepository", "vaadin-%s-%s" % (version, postfix), repoUrl) - - # Overwrite the modified pom.xml - tree.write(pomXml, encoding='UTF-8') - - # Recursive pom.xml search. - for i in listdir(path): - file = join(path, i) - if isdir(file): - updateRepositories(join(path, i), repoUrl, version, postfix) +# Generates and modifies a maven pom file +def generateArchetype(archetype, artifactId, repo, logFile, group="testpkg", archetypeGroup="com.vaadin"): + # Generate the required command line for archetype generation + args = getArgs() + cmd = [mavenCmd, "archetype:generate"] + cmd.append("-DarchetypeGroupId=%s" % (archetypeGroup)) + cmd.append("-DarchetypeArtifactId=%s" % (archetype)) + cmd.append("-DarchetypeVersion=%s" % (args.version)) + if repo is not None: + cmd.append("-DarchetypeRepository=%s" % repo) + cmd.append("-DgroupId=%s" % (group)) + cmd.append("-DartifactId=%s" % (artifactId)) + cmd.append("-Dversion=1.0-SNAPSHOT") + cmd.append("-DinteractiveMode=false") + if hasattr(args, "maven") and args.maven is not None: + cmd.extend(args.maven.strip('"').split(" ")) + + # Generate pom.xml + print("Generating archetype %s" % (archetype)) + subprocess.check_call(cmd, cwd=resultPath, stdout=logFile) # Add a repository of repoType to given repoNode with id and URL def addRepo(repoNode, repoType, id, url): @@ -170,13 +141,6 @@ def removeDir(subdir): return rmtree(join(resultPath, subdir)) -def mavenInstall(pomFile, jarFile = None, mvnCmd = mavenCmd, logFile = sys.stdout): - cmd = [mvnCmd, "install:install-file"] - cmd.append("-Dfile=%s" % (jarFile if jarFile is not None else pomFile)) - cmd.append("-DpomFile=%s" % (pomFile)) - print("executing: %s" % (" ".join(cmd))) - subprocess.check_call(cmd, stdout=logFile) - def dockerWrap(imageVersion, imageName = "demo-validation"): dockerFileContent = """FROM jetty:jre8-alpine MAINTAINER FrameworkTeam |