forked from nicoulaj/idea-markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
131 lines (119 loc) · 6.18 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2011-2012 Julien Nicoulaud <[email protected]>
~
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<project name="idea-markdown" default="all">
<property environment="env"/>
<!-- Versions -->
<property name="idea.version" value="11.1.1"/>
<!-- Paths definition -->
<dirname property="project.basedir" file="${ant.file}"/>
<property name="project.build.directory" value="${project.basedir}/out"/>
<property name="project.build.sourceDirectory" value="${project.basedir}/src/main/java"/>
<property name="project.build.resourcesDirectory" value="${project.basedir}/src/main/resources"/>
<property name="project.build.outputDirectory" value="${project.build.directory}/production/idea-markdown"/>
<property name="project.build.testSourceDirectory" value="${project.basedir}/src/test/java"/>
<property name="project.build.testResourcesDirectory" value="${project.basedir}/src/test/resources"/>
<property name="project.build.testOutputDirectory" value="${project.build.directory}/test/idea-markdown"/>
<property name="project.build.finalName" value="${project.basedir}/idea-markdown.zip"/>
<!-- Targets -->
<target name="clean" description="Delete all build output files">
<delete dir="${project.build.directory}"/>
<delete file="${project.build.finalName}"/>
</target>
<target name="ideaEnvironment" description="Validate and use Intellij IDEA from environment" if="env.IDEA_HOME">
<echo message="Using IDEA_HOME from environment (${env.IDEA_HOME})"/>
<available file="${env.IDEA_HOME}/lib/idea.jar" property="idea.home.valid"/>
<fail unless="${idea.home.valid}" message="IDEA_HOME is not pointing to a valid IntelliJ installation."/>
<property name="idea.home" value="${env.IDEA_HOME}"/>
</target>
<target name="ideaDownload" description="Download, unpack and use IntelliJ IDEA Community Edition"
unless="env.IDEA_HOME">
<echo message="IDEA_HOME not set in environment, downloading IDEA ${idea.version}"/>
<mkdir dir="${project.build.directory}/IDEA"/>
<get src="http://download.jetbrains.com/idea/ideaIC-${idea.version}.tar.gz"
dest="${project.build.directory}/IDEA/IDEA-IC-${idea.version}.tar.gz"/>
<untar src="${project.build.directory}/IDEA/IDEA-IC-${idea.version}.tar.gz"
dest="${project.build.directory}/IDEA"
compression="gzip">
<regexpmapper from="[^/]*/(.*)" to="\1"/>
</untar>
<property name="idea.home" value="${project.build.directory}/IDEA"/>
</target>
<target name="compile" depends="ideaEnvironment,ideaDownload" description="Compile project source classes">
<mkdir dir="${project.build.outputDirectory}"/>
<javac destdir="${project.build.outputDirectory}" includeantruntime="false" fork="true">
<classpath>
<fileset dir="${basedir}/lib" includes="*.jar"/>
<fileset dir="${idea.home}/lib" includes="*.jar"/>
</classpath>
<src location="${project.build.sourceDirectory}"/>
</javac>
<copy todir="${project.build.outputDirectory}">
<fileset dir="${project.basedir}/src/main/resources" includes="**"/>
</copy>
</target>
<target name="testCompile" depends="compile" description="Compile project test classes" unless="skipTests">
<mkdir dir="${project.build.testOutputDirectory}"/>
<javac destdir="${project.build.testOutputDirectory}" includeantruntime="false" fork="true">
<classpath>
<fileset dir="${basedir}/lib" includes="*.jar"/>
<fileset dir="${idea.home}/lib" includes="*.jar"/>
<pathelement location="${project.build.outputDirectory}"/>
</classpath>
<src location="${project.build.testSourceDirectory}"/>
</javac>
</target>
<target name="test" depends="testCompile" description="Run project tests" unless="skipTests">
<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
<classpath>
<pathelement location="${idea.home}/lib/junit-*.jar"/>
<pathelement location="${idea.home}/lib/ant/lib/ant-junit.jar"/>
</classpath>
</taskdef>
<junit printsummary="withOutAndErr" haltonfailure="yes" logfailedtests="true" showoutput="yes">
<classpath>
<fileset dir="${basedir}/lib" includes="*.jar"/>
<fileset dir="${idea.home}/lib" includes="*.jar"/>
<pathelement location="${project.build.outputDirectory}"/>
<pathelement location="${project.build.testOutputDirectory}"/>
</classpath>
<batchtest todir="${project.build.testOutputDirectory}">
<formatter type="plain"/>
<formatter type="xml"/>
<fileset dir="${project.basedir}/src/test/java" includes="**/*Test.java"/>
</batchtest>
</junit>
</target>
<target name="package" depends="compile" description="Build plugin archive for idea-markdown">
<jar destfile="${project.build.directory}/idea-markdown.jar" duplicate="preserve">
<zipfileset dir="${project.build.outputDirectory}"/>
<manifest>
<attribute name="Created-By" value="IntelliJ IDEA"/>
<attribute name="Manifest-Version" value="1.0"/>
</manifest>
</jar>
<zip destfile="${project.build.finalName}">
<zipfileset dir="lib" includes="*.jar" prefix="lib"/>
<zipfileset file="${project.build.directory}/idea-markdown.jar" prefix="lib"/>
</zip>
</target>
<target name="all" depends="clean,test,package" description="Build project, run tests and generate release archive"/>
</project>