]> source.dussan.org Git - vaadin-framework.git/commitdiff
Add --maven parameter to add mvn commandline parameters
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Mon, 15 Jun 2015 09:31:07 +0000 (12:31 +0300)
committerTeemu Suo-Anttila <teemusa@vaadin.com>
Wed, 8 Jul 2015 07:59:51 +0000 (10:59 +0300)
Also adds a --teamcity flag, planned future functionality to add
supplied jar dependencies to local maven repo, and flags for setting
wildfly autodeployment parameters (url, user, password)

Change-Id: I7886009300564c1a088d63cf8d7cc35342706288

scripts/BuildArchetypes.py
scripts/BuildDemos.py
scripts/BuildHelpers.py
scripts/DeployHelpers.py

index ffdbbe1c7a3dd2aa9f0f94c8561967c24e129fcd..82ebe85e4347315b4ceaabd677cde1aeed81d1af 100644 (file)
@@ -11,7 +11,7 @@
 #
 
 import subprocess
-from BuildHelpers import mavenValidate, copyWarFiles, repo, getLogFile, mavenCmd, updateRepositories, getArgs, removeDir
+from BuildHelpers import mavenValidate, copyWarFiles, repo, getLogFile, mavenCmd, updateRepositories, getArgs, removeDir, parser
 from DeployHelpers import deployWar
 
 ## DEFAULT VARIABLES ##
@@ -50,6 +50,8 @@ def generateArchetype(archetype):
        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.extends(args.maven.split(" "))
        
        # Generate pom.xml
        print("Generating pom.xml for archetype %s" % (archetype))
@@ -60,6 +62,14 @@ def generateArchetype(archetype):
 
 ## 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='?')
+
+       archetypesFailed = False
+
+       # Parse the arguments
        args = getArgs()
        for archetype in archetypes:
                try:
@@ -73,7 +83,11 @@ if __name__ == "__main__":
                                        deployWar(war, "%s.war" % (archetype.split("-", 2)[2]))
                                except Exception as e:
                                        print("War %s failed to deploy: %s" % (war, e))
+                                       archetypesFailed = True
                except:
                        print("Archetype %s build failed" % (archetype))
+                       archetypesFailed = True
                removeDir(artifactId)
                print("")
+       if archetypesFailed:
+               sys.exit(1)
index 396863350df9be333c2c2c1d12066efa98c36aa0..6d8445b4d1f30d4080a11662395c0e2be21206cd 100644 (file)
@@ -15,7 +15,7 @@ try:
 except:
        print("BuildDemos depends on gitpython. Install it with `pip install gitpython`")
        sys.exit(1)
-from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir
+from BuildHelpers import updateRepositories, mavenValidate, copyWarFiles, getLogFile, removeDir, getArgs
 from DeployHelpers import deployWar
 
 # Validated demos. name -> git url
@@ -23,7 +23,6 @@ demos = {
        "dashboard" : "https://github.com/vaadin/dashboard-demo.git",
        "parking" : "https://github.com/vaadin/parking-demo.git",
        "addressbook" : "https://github.com/vaadin/addressbook.git",
-       "confirmdialog" : "https://github.com/samie/Vaadin-ConfirmDialog.git",
        "grid-gwt" : "https://github.com/vaadin/grid-gwt.git"
 }
 
@@ -31,6 +30,11 @@ def checkout(folder, url):
        Repo.clone_from(url, folder)
 
 if __name__ == "__main__":
+       if getArgs().teamcity:
+               print("Add dependency jars from TeamCity here")
+       
+       demosFailed = False
+       
        for demo in demos:
                print("Validating demo %s" % (demo))
                try:
@@ -43,8 +47,12 @@ if __name__ == "__main__":
                                        deployWar(war)
                                except Exception as e:
                                        print("War %s failed to deploy: %s" % (war, e))
+                                       demosFailed = True
                        print("%s demo validation succeeded!" % (demo))
-               except:
-                       print("%s demo validation failed" % (demo))
+               except Exception as e:
+                       print("%s demo validation failed: %s" % (demo, e))
+                       demosFailed = True
                removeDir(demo)
                print("")
+       if demosFailed:
+               sys.exit(1)
index 7349c9b36746d27f5bc8008b08ed45dcc27bbd7a..534ce5344172addbd2e963e87410d16a90db35c4 100644 (file)
@@ -27,21 +27,19 @@ elif not isdir(resultPath):
 
 args = None
 
-# Parse command line arguments <version> <framework-repo-id> <archetype-repo-id> <plugin-repo-id>
+# Default argument parser
+parser = argparse.ArgumentParser(description="Automated staging validation")
+parser.add_argument("version", type=str, help="Vaadin version to use")
+parser.add_argument("--maven", help="Additional maven command line parameters", default=None)
+parser.add_argument("--teamcity", help="Use vaadin jars provided by teamcity", action="store_const", const=True, default=False)
+
+# Parse command line arguments <version>
 def parseArgs():
-       # Command line arguments for this script
-       parser = argparse.ArgumentParser(description="Automated staging validation")
-       parser.add_argument("version", type=str, help="Vaadin version to use")
-       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='?')
-       
        # If no args, give help
        if len(sys.argv) == 1:
                args = parser.parse_args(["-h"])
        else:
                args = parser.parse_args()
-       
        return args
 
 # Function for determining the path for maven executable
@@ -81,6 +79,8 @@ def mavenValidate(artifactId, mvnCmd = mavenCmd, logFile = sys.stdout, repoIds =
        cmd = [mvnCmd]
        if hasattr(repoIds, "version") and repoIds.version is not None:
                cmd.append("-Dvaadin.version=%s" % (repoIds.version))
+       if hasattr(repoIds, "maven") and repoIds.maven is not None:
+               cmd.extend(repoIds.maven.split(" "))
        cmd.extend(["clean", "package", "validate"])
        print("executing: %s" % (" ".join(cmd)))
        subprocess.check_call(cmd, cwd=join(getcwd(), artifactId), stdout=logFile)
index c12c38d2935fcc8a8572211d1e4251d5f4533ba4..e8e27b98b6118c46992595076792794aba3172b7 100644 (file)
@@ -11,12 +11,11 @@ except Exception as e:
        sys.exit(1)
 from requests.auth import HTTPDigestAuth
 from os.path import join, expanduser, basename
+from BuildHelpers import parser, getArgs
 
-# .deploy-url in home folder
-deployUrlFile = join(expanduser("~"), ".deploy-url")
-
-# .deploy-credentials in home folder
-deployCredFile = join(expanduser("~"), ".deploy-credentials")
+parser.add_argument("--deployUrl", help="Wildfly management URL")
+parser.add_argument("--deployUser", help="Deployment user", default=None)
+parser.add_argument("--deployPass", help="Deployment password", default=None)
 
 # Helper for handling the full deployment
 # name should end with .war
@@ -50,7 +49,11 @@ def doDeploy(hash, name):
 
 # Helper for adding Content-Type to headers
 def doPostJson(**kwargs):
-       return requests.post(headers={"Content-Type" : "application/json"}, **kwargs)
+       r = requests.post(headers={"Content-Type" : "application/json"}, **kwargs)
+       # Wildfly gives code 500 when asking for a non-existent deployment
+       if r.status_code == requests.codes.ok or r.status_code == 500:
+               return r
+       r.raise_for_status()
 
 def doUploadWarFile(warFile):
        # Upload request, just see the outcome
@@ -70,10 +73,10 @@ def removeDeployment(name):
 
 # Read credentials file and return a HTTPDigestAuth object
 def getAuth():
-       (deployUser, deployPass) = open(deployCredFile).read().strip().split(",")
-       return HTTPDigestAuth(deployUser, deployPass)
+       args = getArgs()
+       return HTTPDigestAuth(args.deployUser, args.deployPass)
 
 # Read the deploy url file and return the url
 def getUrl():
-       return open(deployUrlFile).read().strip()
-
+       return getArgs().deployUrl
+