You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BuildArchetypes.py 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #coding=UTF-8
  2. #
  3. # Windows users:
  4. # You need to setup your environment so that you have mvn on your PATH.
  5. # Maven needs that JAVA_HOME environment is set and points to a JDK
  6. # Python3 is required as this script uses some Python3 specific features.
  7. # Might work with Python2, haven't tested.
  8. #
  9. # python BuildArchetypes.py version fw-repo-id archetype-repo-id plugin-repo-id
  10. #
  11. import subprocess
  12. from BuildHelpers import mavenValidate, copyWarFiles, repo, getLogFile, parseArgs, mavenCmd, updateRepositories
  13. ## DEFAULT VARIABLES ##
  14. # ArchetypeGroupId
  15. archetypeGroup = "com.vaadin"
  16. # List of built archetypes
  17. archetypes = [
  18. "vaadin-archetype-widget",
  19. "vaadin-archetype-application",
  20. "vaadin-archetype-application-example",
  21. "vaadin-archetype-application-multimodule"
  22. ]
  23. # Maven GroupID
  24. group = "testpkg"
  25. log = None
  26. args = None
  27. ## BUILDING METHODS ##
  28. # Generates and modifies a maven pom file
  29. def generateArchetype(archetype):
  30. artifactId = "test-%s-%s" % (archetype, args.version.replace(".", "-"))
  31. # Generate the required command line for archetype generation
  32. cmd = [mavenCmd, "archetype:generate"]
  33. cmd.append("-DarchetypeGroupId=%s" % (archetypeGroup))
  34. cmd.append("-DarchetypeArtifactId=%s" % (archetype))
  35. cmd.append("-DarchetypeVersion=%s" % (args.version))
  36. if hasattr(args, "archetype") and args.archetype != None:
  37. cmd.append("-DarchetypeRepository=%s" % (repo % (args.archetype)))
  38. cmd.append("-DgroupId=%s" % (group))
  39. cmd.append("-DartifactId=%s" % (artifactId))
  40. cmd.append("-Dversion=1.0-SNAPSHOT")
  41. cmd.append("-DinteractiveMode=false")
  42. # Generate pom.xml
  43. print("Generating pom.xml for archetype %s" % (archetype))
  44. subprocess.check_call(cmd, stdout=log)
  45. # Return the artifactId so we know the name in the future
  46. return artifactId
  47. ## DO THIS IF RUN AS A SCRIPT (not import) ##
  48. if __name__ == "__main__":
  49. args = parseArgs()
  50. for archetype in archetypes:
  51. log = getLogFile(archetype)
  52. artifactId = generateArchetype(archetype)
  53. updateRepositories(artifactId)
  54. mavenValidate(artifactId, logFile=log)
  55. copyWarFiles(artifactId, name=archetype)