summaryrefslogtreecommitdiff
path: root/build.xml
blob: d80c6b2b6e757ed664e8b1505b6c4940955baeaf (plain)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?xml version="1.0" encoding="utf-8"?>

<project default="package">

  <tstamp>
    <format property="version.date" pattern="yyyyMMddhhmmss"/>
  </tstamp>

  <property name="version.tag" value="1.${version.date}"/>
  <property name="web-dir" location="src/main/resources/META-INF/resources"/>

  <target name="yarn" depends="yarn.check" if="yarn.run">
    <exec executable="yarn" dir="${web-dir}">
      <arg value="install"/>
    </exec>
  </target>

  <target name="yarn.check">
    <condition property="yarn.run">
      <not>
        <available file="${web-dir}/node_modules"/>
      </not>
    </condition>
  </target>

  <target name="snowpack" depends="snowpack.check,yarn" if="snowpack.run">
    <!-- Build for development -->
    <exec executable="yarn" dir="${web-dir}">
      <arg value="run"/>
      <arg value="snowpack"/>
    </exec>
  </target>

  <target name="snowpack.check">
    <condition property="snowpack.run">
      <not>
        <available file="${web-dir}/web_modules"/>
      </not>
    </condition>
  </target>

  <target name="snowpack-build" depends="snowpack-build.check,yarn" if="snowpack-build.run">
    <!-- Build for distribution -->
    <exec executable="yarn" dir="${web-dir}">
      <arg value="run"/>
      <arg value="snowpack"/>
      <arg value="build"/>
    </exec>
  </target>

  <target name="snowpack-build.check">
    <condition property="snowpack-build.run">
      <not>
        <available file="${web-dir}/build/web_modules"/>
      </not>
    </condition>
  </target>

  <target name="parcel" depends="parcel.check,yarn" if="parcel.run">
    <exec executable="yarn" dir="${web-dir}">
      <arg value="parcel"/>
      <arg value="build"/>
      <arg value="lib.css"/>
      <arg value="lib.js"/>
    </exec>
  </target>

  <target name="parcel.check">
    <condition property="parcel.run">
      <not>
        <available file="${web-dir}/dist"/>
      </not>
    </condition>
  </target>

  <target name="flow" depends="snowpack">
    <exec executable="yarn" dir="${web-dir}">
      <arg value="run"/>
      <arg value="flow"/>
      <arg value="--color=always"/>
    </exec>
  </target>

  <target name="eslint" depends="snowpack">
    <exec executable="yarn" dir="${web-dir}">
      <arg value="run"/>
      <arg value="eslint"/>
      <arg value="bookmarks"/>
      <arg value="cms2"/>
      <arg value="lazychat"/>
      <arg value="posts"/>
      <arg value="wiki"/>
      <arg value="--color"/>
    </exec>
  </target>

  <target name="web.resources" depends="snowpack,snowpack-build" unless="skip-web"/>
  <target name="web.check" unless="skip-web" depends="web.resources,flow,eslint"/>
  <target name="web.bundle" unless="skip-web" depends="web.resources,parcel"/>
  <target name="web" unless="skip-web" depends="web.resources,web.check,web.bundle" description="Generate web resources"/>

  <target name="package" description="Create executable JAR">
    <exec executable="./mvnw">
      <arg value="package"/>
      <arg value="-Dquarkus.container-image.push=false"/>
    </exec>
  </target>

  <target name="deploy" description="Deploy JAR to Kubernetes">
    <exec executable="./mvnw">
      <arg value="package"/>
      <arg value="-Drevision=${version.tag}"/>
      <arg value="-Dquarkus.container-image.build=true"/>
      <arg value="-Dquarkus.container-image.push=true"/>
    </exec>
    <exec executable="kubectl">
      <arg value="config"/>
      <arg value="use-context"/>
      <arg value="mulk"/>
    </exec>
    <exec executable="kubectl">
      <arg value="set"/>
      <arg value="image"/>
      <arg value="deployments/mulkcms2"/>
      <arg value="mulkcms2=docker.benkard.de/mulk/mulkcms2:${version.tag}"/>
    </exec>
    <exec executable="kubectl">
      <arg value="rollout"/>
      <arg value="status"/>
      <arg value="deployments/mulkcms2"/>
    </exec>
  </target>

  <target name="clean">
    <exec executable="./mvnw">
      <arg value="clean"/>
    </exec>
    <delete dir="${web-dir}/.parcel-cache"/>
    <delete dir="${web-dir}/build"/>
    <delete dir="${web-dir}/dist"/>
    <delete dir="${web-dir}/node_modules"/>
    <delete dir="${web-dir}/web_modules"/>
  </target>

</project>