forked from nexiles/windchill-maven
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
85 lines (64 loc) · 2.59 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import os
import sys
from fabric.api import task, execute, local, lcd
from fabric.colors import red, yellow, green
from fabric.context_managers import settings, hide
WT_HOME = os.environ.get("WT_HOME")
if not os.path.exists(WT_HOME):
print(red("Can't access WT_HOME: {}".format(WT_HOME)))
sys.exit(10)
project_root = os.path.dirname(__file__)
build_dir = os.path.join(project_root, "build")
docs_dir = os.path.join(project_root, "docs")
GROUP_ID = "com.ptc"
@task
def make_artifats(version):
"create windchill artifacts"
dest = os.path.join(build_dir, version)
os.environ["WTVERSION"] = version
print green("Building artifacts for {} version {}".format(GROUP_ID, version))
with settings(hide("running", "stdout")):
print green(" Copying jar files ...")
local("mkdir -p {}".format(dest))
with lcd(dest):
local("cp {}/srclib/tool/Annotations.jar .".format(WT_HOME))
local("cp {}/codebase/WEB-INF/lib/ie3rdpartylibs.jar .".format(WT_HOME))
print green(" Creating codebase jar file ...")
local("ant makeCodebaseJar")
@task
def import_artifats(version):
"import artifacts to maven local repo"
src = os.path.join(build_dir, version)
os.environ["WTVERSION"] = version
if not os.path.exists(src):
print(red("Please make artifacts for version {} first.".format(version)))
sys.exit(10)
print green("Importing artifacts for {} version {}".format(GROUP_ID, version))
with settings(hide("running", "stdout")):
with lcd(src):
for artifact in "codebase Annotations ie3rdpartylibs".split():
print green(" {} ...".format(artifact))
cmd = "mvn install:install-file -Dfile={artifact}.jar " \
"-DgroupId={group_id} -DartifactId={artifact} " \
"-Dversion={version} -Dpackaging=jar -DgeneratePom=true " \
"-DcreateChecksum=true".format(artifact=artifact, version=version, group_id=GROUP_ID)
local(cmd)
@task
def build_docs():
print green("Building docs ...")
with settings(hide("running", "stdout")):
with lcd(docs_dir):
local("make gh_pages")
local("make preview")
@task
def push_docs():
print green("Pushing docs to GitHub ...")
with settings(hide("running", "stdout")):
with lcd(docs_dir):
local("make gh_pages_sync")
@task
def make(version):
"create and import artifacts to maven local repo"
execute(make_artifats, version=version)
execute(import_artifats, version=version)
# EOF