Skip to content

Commit 84cdbee

Browse files
committed
adding first build script examples
1 parent 1e625ba commit 84cdbee

File tree

3 files changed

+133
-0
lines changed

3 files changed

+133
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<project name="my-app" basedir="." default="package"> <1>
2+
3+
<property name="version" value="1.0-SNAPSHOT"/> <2>
4+
<property name="finalName" value="${ant.project.name}-${version}"/>
5+
<property name="src.dir" value="src/main/java"/>
6+
<property name="build.dir" value="target"/>
7+
<property name="output.dir" value="${build.dir}/classes"/>
8+
<property name="test.src.dir" value="src/test/java"/>
9+
<property name="test.output.dir" value="${build.dir}/test-classes"/>
10+
<property name="lib.dir" value="lib"/>
11+
12+
<path id="classpath"> <3>
13+
<fileset dir="${lib.dir}" includes="**/*.jar"/>
14+
</path>
15+
16+
<target name="clean">
17+
<delete dir="${build.dir}"/>
18+
</target>
19+
20+
<target name="compile" depends="clean"> <4>
21+
<mkdir dir="${output.dir}"/>
22+
<javac srcdir="${src.dir}"
23+
destdir="${output.dir}"
24+
target="11" source="11"
25+
classpathref="classpath"
26+
includeantruntime="false"/>
27+
</target>
28+
29+
<target name="compile-test">
30+
<mkdir dir="${test.output.dir}"/>
31+
<javac srcdir="${test.src.dir}"
32+
destdir="${test.output.dir}"
33+
target="11" source="11"
34+
classpathref="classpath"
35+
includeantruntime="false"/>
36+
</target>
37+
38+
<target name="test" depends="compile-test"> <5>
39+
<junit printsummary="yes" fork="true">
40+
<classpath>
41+
<path refid="classpath"/>
42+
<pathelement location="${output.dir}"/>
43+
<pathelement location="${test.output.dir}"/>
44+
</classpath>
45+
46+
<batchtest>
47+
<fileset dir="${test.src.dir}" includes="**/*Test.java"/>
48+
</batchtest>
49+
</junit>
50+
</target>
51+
52+
<target name="package" depends="compile,test"> <6>
53+
<mkdir dir="${build.dir}"/>
54+
<jar jarfile="${build.dir}/${finalName}.jar"
55+
basedir="${output.dir}"/>
56+
</target>
57+
58+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.mycompany.app</groupId> <1>
8+
<artifactId>my-app</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<name>my-app</name>
12+
<!-- FIXME change it to the project's website -->
13+
<url>http://www.example.com</url>
14+
15+
<properties> <2>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<maven.compiler.release>11</maven.compiler.release>
18+
</properties>
19+
20+
<dependencies> <3>
21+
<dependency>
22+
<groupId>junit</groupId>
23+
<artifactId>junit</artifactId>
24+
<version>4.11</version>
25+
<scope>test</scope>
26+
</dependency>
27+
</dependencies>
28+
29+
<build> <4>
30+
<pluginManagement>
31+
<plugins>
32+
<plugin> <5>
33+
<artifactId>maven-compiler-plugin</artifactId>
34+
<version>3.8.0</version>
35+
</plugin>
36+
</plugins>
37+
</pluginManagement>
38+
</build>
39+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* This file was generated by the Gradle 'init' task.
3+
*/
4+
5+
plugins {
6+
id 'java' <1>
7+
id 'maven-publish'
8+
}
9+
10+
repositories { <2>
11+
mavenLocal()
12+
maven {
13+
url = uri('https://repo.maven.apache.org/maven2')
14+
}
15+
}
16+
17+
dependencies {
18+
testImplementation 'junit:junit:4.11' <3>
19+
}
20+
21+
group = 'com.mycompany.app'
22+
version = '1.0-SNAPSHOT'
23+
description = 'my-app'
24+
sourceCompatibility = '11' <4>
25+
26+
publishing {
27+
publications {
28+
maven(MavenPublication) {
29+
from(components.java)
30+
}
31+
}
32+
}
33+
34+
tasks.withType(JavaCompile) { <5>
35+
options.encoding = 'UTF-8'
36+
}

0 commit comments

Comments
 (0)