public
Description: JSR308 Typestate Checker
Homepage: http://www.warski.org/typestate.html
Clone URL: git://github.com/adamw/jsr308-typestate-checker.git
100644 183 lines (164 sloc) 7.142 kb
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<project name="typestatechecker" default="dist" basedir=".">
    <description>Builds the Typestate Checker. </description>
 
    <property name="src" value="src"/>
    <property name="test" value="tests/src"/>
    <property name="dist" value="dist"/>
    <property name="build" value="build"/>
    <property name="doc" value="doc"/>
    <property name="build.tests" value="tests/build"/>
    <property file="build.properties"/>
    <property name="dist.file" value="typestate-checker.jar"/>
    <property name="dist.src.file" value="typestate-checker-src.zip"/>
    <property name="javari.jdk.src" value="jdk/javari/src"/>
    <property name="javari.jdk.build" value="jdk/javari/build"/>
    <property name="javaparser.loc" value="../javaparser"/>
    <property name="checkers.rel.jp" value="../checkers"/>
 
    <property name="compiler.version.goal" value="javac 1.7.0-jsr308-0.9.9"/>
    <property name="run.tests.should.fork" value="true"/>
 
    <path id="build.path">
        <pathelement location="${compiler.lib}"/>
        <pathelement location="lib"/>
    </path>
 
    <target name="prep" description="Create required directories">
        <mkdir dir="${build}"/>
        <mkdir dir="${build.tests}"/>
        <mkdir dir="${build.tests}/testclasses"/>
        <mkdir dir="${dist}"/>
 
        <java fork="true"
              outputproperty="compiler.version"
              classpath="${compiler.lib}"
              classname="com.sun.tools.javac.Main">
            <arg line="-version"/>
        </java>
 
        <condition property="compiler.exists">
            <equals arg1="${compiler.version}"
                    arg2="${compiler.version.goal}"/>
        </condition>
    </target>
 
    <target name="clean" description="Remove generated files">
        <delete dir="${build}"/>
        <delete dir="${dist}"/>
        <delete dir="${doc}"/>
        <delete failonerror="false">
            <fileset dir="${build.tests}" includes="**/*.class"/>
        </delete>
    </target>
 
    <target name="check-compiler">
        <fail unless="compiler.exists" message="
Needed version ${compiler.version.goal} of the JSR 308 compiler,
but found version ${compiler.version} on your classpath.
${line.separator}${line.separator}
Check that the 'compiler.lib' property in 'build.properties' points to version
${compiler.version.goal} of the 'javac.jar' library."/>
    </target>
 
    <target name="build" depends="prep,check-compiler" description="Compile files">
        <pathconvert pathsep=" " property="src.files">
            <path>
                <fileset dir="${src}">
                    <include name="**/*.java"/>
                </fileset>
            </path>
        </pathconvert>
        <copy todir="${build}">
            <fileset dir="${src}" includes="**/*.properties"/>
            <fileset dir="${src}" includes="**/*.astub"/>
        </copy>
        <java fork="true"
              failonerror="true"
              classpath="${compiler.lib}:${checkers.lib}"
              classname="com.sun.tools.javac.Main">
            <jvmarg line="-Xbootclasspath/p:${compiler.lib}"/>
            <arg value="-g"/>
            <arg line="-sourcepath ${src}"/>
            <arg line="-d ${build}"/>
            <arg line="${src.files}"/>
            <arg line="-version"/>
        </java>
        <!--<unjar src="${javaparser.lib}" dest="${build}" /> -->
    </target>
 
    <target name="dist" depends="build" description="Create jar file">
        <jar destfile="${dist}/${dist.file}" basedir="${build}"/>
    </target>
 
    <target name="dist-src">
        <delete file="${dist}/${dist.src.file}" />
        <zip destfile="${dist}/${dist.src.file}">
            <zipfileset dir="." prefix="typestate-checker">
                <include name="build.xml" />
                <include name="build.properties" />
                <include name="example.sh" />
                <include name="${src}/**/*" />
                <include name="tests/**/*" />
                <include name="example/**/*" />
                <exclude name="tests/build/**/*" />
            </zipfileset>
        </zip>
    </target>
 
    <target name="doc" description="Create javadocs">
        <mkdir dir="${doc}"/>
        <javadoc sourcepath="${src}" destdir="${doc}" classpath="${compiler.lib}:${checkers.lib}:${dist.file}" />
    </target>
 
    <target name="build-test" depends="prep,check-compiler" description="Compile tests">
        <pathconvert pathsep=" " property="src.tests">
            <path>
                <fileset dir="${test}">
                    <include name="**/*.java"/>
                </fileset>
            </path>
        </pathconvert>
        <java fork="true"
              failonerror="true"
              classpath="${compiler.lib}:${junit.lib}:${checkers.test.lib}:${build}"
              classname="com.sun.tools.javac.Main">
            <jvmarg line="-Xbootclasspath/p:${compiler.lib}"/>
            <arg value="-g"/>
            <arg line="-sourcepath ${test}"/>
            <arg line="-d ${build.tests}"/>
            <arg line="${src.tests}"/>
        </java>
    </target>
 
    <target name="-run-tests" description="Generalized test runner">
        <java fork="${run.tests.should.fork}"
              failonerror="true"
              classpath="${compiler.lib}:${dist}/${dist.file}:${build.tests}:${junit.lib}:${checkers.lib}:${checkers.test.lib}"
              classname="org.junit.runner.JUnitCore">
            <jvmarg line="-Xbootclasspath/p:${compiler.lib}"/>
            <jvmarg line="-ea"/>
            <arg line="${param}"/>
        </java>
    </target>
 
    <target name="test" depends="build, build-test" description="Run tests for the Checker Framework">
        <antcall target="-run-tests">
            <param name="param" value="checkers.typestate.test.TypestateTest"/>
        </antcall>
    </target>
 
    <!-- Type checking the typestate checker -->
    <target name="-run-checker" depends="dist" description="Run a checker">
        <pathconvert pathsep=" " property="files.to.check">
            <path>
                <fileset dir="${src}">
                    <include name="**/*.java" />
                    <exclude name="**/*MainFlow*" />
                </fileset>
            </path>
        </pathconvert>
 
        <java fork="true"
              failonerror="true"
              classpath="${compiler.lib}:${checkers.lib}:${dist.file}"
              classname="com.sun.tools.javac.Main">
            <jvmarg line="-Xbootclasspath/p:${compiler.lib}"/>
            <arg value="-g"/>
            <arg line="-sourcepath ${src}:${checker-jdk}"/>
            <arg line="-d ${build}"/>
            <arg line="${files.to.check}"/>
            <arg line="-version"/>
            <arg line="-proc:only"/>
            <arg line="-processor ${checker-name}"/>
        </java>
    </target>
 
    <target name="check-nullness" description="Run the nullness checker">
        <antcall target="-run-checker">
            <param name="checker-name" value="checkers.nullness.NullnessChecker"/>
            <param name="checker-jdk" value="jdk/nullness/src"/>
        </antcall>
    </target>
</project>