-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
111 lines (98 loc) · 4.5 KB
/
build.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
104
105
106
107
108
109
110
111
<project name="which" default="build" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:unless="ant:unless">
<property environment="env"/>
<xmlproperty file="ivy.xml"/>
<property name="project.title" value="Which for Java"/>
<property name="project.version" value="${ivy-module.info(revision)}"/>
<property name="vendor.id" value="io.belin"/>
<property name="vendor.name" value="Cédric Belin"/>
<description>${project.title} ${project.version}</description>
<path id="project.classpath">
<pathelement location="bin"/>
<fileset dir="lib" excludes="*-javadoc.jar,*-sources.jar" includes="*.jar"/>
</path>
<target name="build" description="Builds the project">
<unzip dest="src">
<fileset dir="lib" includes="picocli-*-sources.jar"/>
<patternset includes="**/CommandLine.java"/>
</unzip>
<mkdir dir="bin"/>
<javac srcDir="src" destDir="bin" classPathRef="project.classpath" includeAntRuntime="false">
<compilerarg value="-proc:full"/>
<compilerarg value="-Xlint:all,-path,-processing"/>
</javac>
</target>
<target name="clean" description="Deletes all generated files">
<delete failonerror="false" includeEmptyDirs="true">
<fileset dir="bin" excludes="*.ps1"/>
<fileset dir="src/picocli"/>
<fileset dir="var" excludes=".gitkeep"/>
</delete>
</target>
<target name="dist" description="Packages the project" depends="clean,version,build">
<mkdir dir="bin/META-INF"/>
<copy file="LICENSE.md" toDir="bin/META-INF"/>
<jar destFile="bin/${ant.project.name}.jar">
<fileset dir="bin" excludes="*.jar,*.ps1,picocli/,io/belin/**/Program.class"/>
<manifest>
<attribute name="Implementation-Title" value="${project.title}"/>
<attribute name="Implementation-Vendor" value="${vendor.name}"/>
<attribute name="Implementation-Vendor-Id" value="${vendor.id}"/>
<attribute name="Implementation-Version" value="${project.version}"/>
</manifest>
</jar>
<jar destFile="bin/${ant.project.name}-cli.jar">
<fileset dir="bin" excludes="*.jar,*.ps1"/>
<manifest>
<attribute name="Implementation-Title" value="${project.title} (CLI)"/>
<attribute name="Implementation-Vendor" value="${vendor.name}"/>
<attribute name="Implementation-Vendor-Id" value="${vendor.id}"/>
<attribute name="Implementation-Version" value="${project.version}"/>
<attribute name="Main-Class" value="${vendor.id}.${ant.project.name}.Program"/>
</manifest>
</jar>
</target>
<target name="install" description="Installs the project dependencies">
<mkdir dir="lib"/>
<ivy:retrieve log="download-only" sync="true"/>
</target>
<target name="lint" description="Performs the static analysis of source code." depends="build">
<taskdef name="cpd" className="net.sourceforge.pmd.ant.CPDTask" classPathRef="project.classpath"/>
<cpd minimumTokenCount="100">
<fileset dir="src/io/belin"/>
<fileset dir="test"/>
</cpd>
<java className="net.sourceforge.pmd.cli.PmdCli" classPathRef="project.classpath" failOnError="true" fork="true">
<arg line="check --cache=var/pmd.cache --dir=example,src/io/belin,test --no-progress --rulesets=etc/pmd.xml"/>
</java>
</target>
<target name="outdated" description="Checks whether installed packages are out of date">
<ivy:checkdepsupdate log="quiet"/>
</target>
<target name="publish" description="Publishes the package" depends="dist">
<exec executable="git">
<arg line="tag v${project.version}"/>
</exec>
<exec executable="git">
<arg line="push origin v${project.version}"/>
</exec>
</target>
<target name="run" description="Runs a main class from the "example" folder" depends="build">
<fail message="You must specify an example to run using -Dclass=<example>." unless="class"/>
<java sourceFile="example/${class}.java" classPathRef="project.classpath" failOnError="true" fork="true"/>
</target>
<target name="test" description="Runs the test suite" depends="build">
<javac srcDir="test" destDir="bin" classPathRef="project.classpath" includeAntRuntime="false">
<compilerarg value="-proc:full"/>
<compilerarg value="-Xlint:all,-path,-processing"/>
</javac>
<java className="org.junit.platform.console.ConsoleLauncher" classPathRef="project.classpath" failOnError="true" fork="true">
<arg line="--select-package=${vendor.id}.${ant.project.name}"/>
<assertions>
<enable/>
</assertions>
</java>
</target>
<target name="version" description="Updates the version number in the sources">
<replaceregexp file="README.md" match="project/v\d+(\.\d+){2}" replace="project/v${project.version}"/>
</target>
</project>