Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,22 @@ jobs:
- name: 'Check Spock'
run: |
./mvnw -V -B verify
check-ant:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache Ivy download cache
uses: actions/cache@v4
with:
path: ~/.ivy2
key: test-${{ runner.os }}-ivy-${{ hashFiles('ivy.xml', 'ivysettings.xml') }}
restore-keys: |
test-${{ runner.os }}-ivy-
- name: 'Set up JDK'
uses: actions/setup-java@v4
with:
java-version: 8
distribution: temurin
- name: 'Check Spock'
run: |
ant test
188 changes: 188 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<project name="SpockExample"
default="test"
xmlns:groovy="antlib:org.codehaus.groovy.ant"
xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- Various Paths -->
<property name="test.src.dir"
location="src/test/groovy"/>
<property name="test.resource.dir"
location="src/test/resources"/>
<property name="build.dir"
location="ant/build"/>
<property name="lib.dir"
location="ant/lib"/>
<property name="classes.dir"
location="${build.dir}/classes"/>

<!-- Ivy Properties -->
<property name="config.ivy.version"
value="2.5.3"/>
<property name="ivy.jar.dir"
location="${lib.dir}/ivy"/>
<property name="ivy.jar.filename"
value="ivy-${config.ivy.version}.jar"/>
<property name="ivy.jar.file"
location="${ivy.jar.dir}/${ivy.jar.filename}"/>

<target name="init">
<echo message="Buildfile for ${ant.project.name} (${ant.file})"
level="info"/>
<fail message="Ant 1.10.6 or newer is needed for ${ant.project.name} to build, please install it and rerun (found Ant version: '${ant.version}')">
<condition>
<not>
<antversion atleast="1.10.6"/>
</not>
</condition>
</fail>
<fail message="Java 8 or newer is needed for ${ant.project.name} to build, please install it and rerun (found Java version: '${ant.java.version}')">
<condition>
<not>
<javaversion atleast="1.8"/>
</not>
</condition>
</fail>
<fail message="The ant-optional package is needed for ${ant.project.name} to build, please install it and rerun">
<condition>
<not>
<and>
<available classname="org.apache.tools.ant.taskdefs.optional.depend.Depend"/>
<available classname="org.apache.tools.ant.taskdefs.optional.TraXLiaison"/>
</and>
</not>
</condition>
</fail>
</target>

<target name="check-ivy"
depends="init">
<available property="ivy.jar.present"
file="${ivy.jar.file}"
type="file"/>
</target>

<target name="download-ivy"
depends="init,check-ivy"
unless="ivy.jar.present">
<mkdir dir="${ivy.jar.dir}"/>
<get src="https://repo.maven.apache.org/maven2/org/apache/ivy/ivy/${config.ivy.version}/ivy-${config.ivy.version}.jar"
dest="${ivy.jar.file}"
usetimestamp="true"/>
</target>

<target name="init-ivy"
depends="init,download-ivy">
<property name="ivy.retrieve.pattern"
value="${lib.dir}/[conf]/[artifact](-[classifier]).[ext]"/>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
classpath="${ivy.jar.file}"
loaderref="ivy.loader"
uri="antlib:org.apache.ivy.ant"/>
</target>

<target name="retrieve"
description="retrieve the dependencies"
depends="init,init-ivy">
<ivy:retrieve sync="true"/>
<ivy:retrieve pattern="${lib.dir}/ivy/[artifact]-[revision].[ext]"
organisation="org.apache.ivy"
module="ivy"
revision="${config.ivy.version}"
conf="default"
inline="true"/>
</target>

<target name="clean"
depends="init"
description="clean up intermediate files">
<delete includeemptydirs="true"
failonerror="false">
<fileset dir="${classes.dir}"
defaultexcludes="false"/>
</delete>
</target>

<target name="clean-all"
depends="init"
description="clean up lib.dir, classes.dir, and build.dir completely">
<delete includeemptydirs="true"
failonerror="false">
<fileset dir="${lib.dir}"
defaultexcludes="false"/>
<fileset dir="${classes.dir}"
defaultexcludes="false"/>
<fileset dir="${build.dir}"
defaultexcludes="false"/>
</delete>
</target>

<target name="compile-test"
depends="init,retrieve">
<mkdir dir="${classes.dir}/test"/>
<depend srcDir="${test.src.dir}"
destDir="${classes.dir}/test"
cache="${classes.dir}"/>
<dependset>
<srcfilelist files="build.xml"/>
<srcfilelist files="ivy.xml"/>
<srcfilelist files="ivysettings.xml"/>
<targetfileset dir="${classes.dir}/test"/>
</dependset>
<taskdef resource="org/codehaus/groovy/antlib.xml"
uri="antlib:org.codehaus.groovy.ant">
<classpath>
<fileset dir="${lib.dir}/groovy-ant"
includes="*.jar"/>
</classpath>
</taskdef>
<groovy:groovyc srcdir="${test.src.dir}"
destdir="${classes.dir}/test"
encoding="UTF-8"
includeAntRuntime="false"
fork="true">
<groovy:classpath id="classpath.test">
<fileset dir="${lib.dir}/test"
includes="*.jar"/>
</groovy:classpath>
</groovy:groovyc>
</target>

<target name="test"
depends="init,retrieve,compile-test"
description="run unit tests">
<delete dir="${build.dir}/test/raw-reports"/>
<mkdir dir="${build.dir}/test/raw-reports"/>
<junitlauncher printsummary="true"
failureproperty="tests.failed">
<classpath refid="classpath.test"/>
<classpath location="§{test.resource.dir}"/>
<classpath location="${classes.dir}/test"/>
<classpath location="${ant.library.dir}/ant.jar"/>
<classpath location="${ant.library.dir}/ant-junitlauncher.jar"/>
<listener type="legacy-xml"
outputDir="${build.dir}/test/raw-reports"/>
<testclasses>
<fork includeJUnitPlatformLibraries="false"
includeAntRuntimeLibraries="false"/>
<fileset dir="${classes.dir}/test">
<scriptselector language="groovy">
<classpath>
<fileset dir="${lib.dir}/groovy-script"
includes="*.jar"/>
</classpath>
<![CDATA[
import org.spockframework.buildsupport.SpecClassFileFinder
self.selected = new SpecClassFileFinder().isRunnableSpec(file)
Comment on lines +173 to +174
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a single line

Suggested change
import org.spockframework.buildsupport.SpecClassFileFinder
self.selected = new SpecClassFileFinder().isRunnableSpec(file)
self.selected = new org.spockframework.buildsupport.SpecClassFileFinder().isRunnableSpec(file)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No specific reason, just two shorter lines instead of one long line.
If you want one long line instead, I'll change it.

]]>
</scriptselector>
</fileset>
</testclasses>
</junitlauncher>
<mkdir dir="${build.dir}/test/merged-reports"/>
<junitreport todir="${build.dir}/test/merged-reports">
<fileset dir="${build.dir}/test/raw-reports"/>
<report todir="${build.dir}/test/reports"/>
</junitreport>
<fail message="Unit test(s) failed! See reports at ${build.dir}/test/reports/index.html"
if="tests.failed"/>
</target>
</project>
47 changes: 47 additions & 0 deletions ivy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="org.spockframework" module="spock-example">
<license name="ASLv2" url="https://www.apache.org/licenses/LICENSE-2.0"/>
<ivyauthor name="Björn Kautler"/>
<description homepage="https://spockframework.org/">
Spock Framework - Example Project
</description>
</info>

<configurations confmappingoverride="true" defaultconfmapping="sources,javadoc->@;compile->master;%->default">
<conf name="default" description="Runtime dependencies and master artifacts" extends="master, runtime"/>
<conf name="master" description="Artifacts of this module without dependencies"/>
<conf name="compile" description="Compile dependencies" visibility="private" transitive="false"/>
<conf name="runtime" description="Runtime dependencies" extends="compile"/>
<conf name="test" description="Testing dependencies" visibility="private" extends="runtime"/>
<conf name="provided" description="Provided dependencies" visibility="private"/>
<conf name="sources" description="Source artifacts" visibility="private"/>
<conf name="javadoc" description="JavaDoc artifacts" visibility="private"/>
<conf name="groovy-ant" description="Dependencies for Groovy Ant tasks" visibility="private" extends="test"/>
<conf name="groovy-script" description="Dependencies for Groovy script selector" visibility="private" extends="test"/>
</configurations>

<publications defaultconf="master"/>

<dependencies defaultconf="compile;sources;javadoc">
<dependency org="org.apache.groovy" name="groovy-ant" rev="4.0.26" conf="groovy-ant;sources;javadoc"/>
<dependency org="org.apache.groovy" name="groovy-groovydoc" rev="4.0.26" conf="groovy-ant;sources;javadoc"/>
<dependency org="org.apache.groovy" name="groovy" rev="4.0.26" conf="test;sources;javadoc"/>
<!-- Mandatory dependencies for using Spock -->
<dependency org="org.spockframework" name="spock-core" rev="2.3-groovy-4.0" conf="test;sources;javadoc"/>
<dependency org="org.junit.platform" name="junit-platform-launcher" rev="1.12.1" conf="test;sources;javadoc"/>
<!-- Optional dependencies for using Spock -->
<!-- enables mocking of classes (in addition to interfaces) -->
<dependency org="org.objenesis" name="objenesis" rev="3.4" conf="test;sources;javadoc"/>
<dependency org="net.bytebuddy" name="byte-buddy" rev="1.17.5" conf="test;sources;javadoc"/>
<!-- Dependencies used by examples in this project (not required for using Spock) -->
<dependency org="org.apache.groovy" name="groovy-sql" rev="4.0.26" conf="test;sources;javadoc"/>
<dependency org="org.spockframework" name="spock-junit4" rev="2.3-groovy-4.0" conf="test;sources;javadoc"/>
<dependency org="com.h2database" name="h2" rev="2.2.224" conf="test;sources;javadoc"/>
<!-- For using the scriptselector with Groovy -->
<dependency org="org.apache.groovy" name="groovy-jsr223" rev="4.0.26" conf="groovy-script;sources;javadoc"/>
<dependency org="org.ow2.asm" name="asm" rev="9.8" conf="groovy-script;sources;javadoc"/>
</dependencies>
</ivy-module>
15 changes: 15 additions & 0 deletions ivysettings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<ivysettings>
<settings defaultResolver="default"/>

<resolvers>
<ibiblio name="public" root="https://repo.maven.apache.org/maven2/" m2compatible="true"/>
<!-- The whole file is only required if a snapshot version of Spock is used -->
<ibiblio name="snapshots" root="https://oss.sonatype.org/content/repositories/snapshots/" m2compatible="true"/>
</resolvers>

<include url="${ivy.default.settings.dir}/ivysettings-shared.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-local.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-main-chain.xml"/>
<include url="${ivy.default.settings.dir}/ivysettings-default-chain.xml"/>
</ivysettings>
Loading