-
Notifications
You must be signed in to change notification settings - Fork 0
/
ant-deploy-site.xml
103 lines (86 loc) · 3.84 KB
/
ant-deploy-site.xml
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<project name="DeploySite" default="deploy" basedir=".">
<description>
Deploy the site. The site must have been previously been staged in the target/stage folder. The site is
checked out from the gh-pages branch of the github repository, then synchronized with the target/stage folder, then
commited back to github.
</description>
<!-- set global properties for this build -->
<property name="sourceFolder" location="target/staging" />
<property name="targetFolder" location="target/gh-pages_branch" />
<property name="targetProjectFolder" location="target/gh-pages_branch/graphql-maven-plugin-project" />
<target name="deploy">
<!-- This is an ant implementation largely inspired from this page (thanks a lot to you, guys!): -->
<!-- http://wiki.bitplan.com/index.php/Multi-Module_Maven_with_github_pages -->
<input message="Enter the last released version (e.g.: 1.6.0):" addproperty="version" />
<!-- For git on Windows, there is an issue with (too) long filenames. The git command below takes care of that -->
<exec executable="git" failonerror="true">
<arg value="config" />
<arg value="--system" />
<arg value="core.longpaths" />
<arg value="true" />
</exec>
<!-- To be sure everything is ready for the site, we first build the project -->
<exec executable="cmd" failonerror="true">
<arg value="/c" />
<arg value="mvn" />
<arg value="install" />
<arg value="-DskipTests" />
</exec>
<!-- Prepares the site (this command is very long to execute -->
<exec executable="cmd" failonerror="true">
<arg value="/c" />
<arg value="mvn" />
<arg value="site" />
<arg value="-Prelease" />
<arg value=""-DlastReleasedVersion=${version}"" />
<!-- There is an issue with creating the site on some configurations. It works in offline mode. -->
<arg value="-o"/>
</exec>
<!-- Stages the site -->
<exec executable="cmd" failonerror="true">
<arg value="/c" />
<arg value="mvn" />
<arg value="site:stage" />
</exec>
<!-- Checks that the site has been staged -->
<available file="${sourceFolder}" type="dir" property="siteHasBeenStaged" value="true" />
<fail unless="siteHasBeenStaged" message="The site has not been staged. Please run first: mvn site:stage" />
<!-- Cleaning the check out folder -->
<delete dir="${targetFolder}" />
<mkdir dir="${targetFolder}" />
<!-- Checkout the gh-pages branch,to commit the site onto it -->
<!-- git clone https://github.com/graphql-java-generator/graphql-maven-plugin-project - -branch gh-pages - -single-branch -->
<exec executable="git" dir="${targetFolder}" failonerror="true">
<arg value="clone" />
<arg value="https://github.com/graphql-java-generator/graphql-maven-plugin-project" />
<arg value="--branch" />
<arg value="gh-pages" />
<arg value="--single-branch" />
</exec>
<!-- Synchronize the target gh-pages folder, with the staged site -->
<sync todir="${targetProjectFolder}" overwrite="true">
<fileset dir="${sourceFolder}" />
<preserveintarget>
<include name="/.git/**" />
<include name="**/CNAME" />
</preserveintarget>
</sync>
<!-- git add * -->
<exec executable="git" dir="${targetProjectFolder}" failonerror="true">
<arg value="add" />
<arg value="*" />
</exec>
<!-- git commit -m "checking new site in" -->
<exec executable="git" dir="${targetProjectFolder}" failonerror="true">
<arg value="commit" />
<arg value="-m" />
<arg value="Checking new site in" />
<arg value="--author=EtienneSF <[email protected]>" />
</exec>
<!-- git push -->
<echo message="The site is ready to be pushed. Do these commands:" level="info" />
<echo message="cd ${targetProjectFolder}" level="info" />
<echo message="git push" level="info" />
<!-- exec executable="git" dir="${targetProjectFolder}" failonerror="true"> <arg value="push" /> </exec -->
</target>
</project>