Skip to content

Commit 6c2ba2f

Browse files
committed
Merge branch 'android'
* android: Added Ant file to Android example to automatically download required jars.
2 parents b407f1c + 0707f76 commit 6c2ba2f

File tree

4 files changed

+53
-10
lines changed

4 files changed

+53
-10
lines changed

examples/android/cukeulator-test/README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@ Features must be placed in `assets/features/`. Subdirectories are allowed.
66

77
Read `libs/README.md` for details on dependencies.
88

9-
### Using ant
9+
### Using Ant
1010
1. Please read ["Building and Running from the Command Line"](https://developer.android.com/tools/building/building-cmdline.html).
11-
2. Make sure you have the required jars in `libs/` (read libs/README.md).
12-
3. Run `ant test`.
11+
2. Run `ant test`.
1312

1413
### Using an IDE
1514
1. Please read ["Building and Running from Eclipse with ADT"](https://developer.android.com/tools/building/building-eclipse.html).
1615
2. Create an Android test-project from these sources with `cucumber-example/` as the tested project.
1716
3. Create a run configuration with `cucumber.android.api.CucumberInstrumentation` as the instrumentation.
18-
4. Put the required jar dependencies into `libs/`.
17+
4. Make sure you have the required jar dependencies in `libs/`.
1918

2019
### Using Maven
2120
To build:
2221

23-
````
22+
```
2423
mvn package -pl examples/android/cukeulator-test -am -P android,android-examples
2524
```
2625

examples/android/cukeulator-test/custom_rules.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
-post-build
1212
-pre-clean
1313
-->
14+
<import file="./libs/init.xml"/>
15+
1416
<target name="-pre-build">
15-
<!-- TODO: see libs/README.md -->
17+
<antcall target="libs.init"/>
1618
</target>
1719
</project>
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
If you intend to build this project with Ant or with an IDE,
2-
you will need to place the required jars inside this directory.
2+
you will need to have the required jars inside this directory.
3+
4+
If you're building this project with **Ant,** just run ../build.xml
5+
and the required jars will **automatically be downloaded.**
36

47
### Required jars for Cukeulator Test App
58
* cucumber-core
69
* cucumber-java
710
* cucumber-android
811

9-
Run `./init.sh`
1012

11-
**TODO:** Ant file for downloading jars from sonatype (when building with Ant, Maven should not be required).
13+
* To download the release versions run `ant -f init.xml`.
14+
* Or run `./init.sh` to build snaphsots with Maven.
1215

13-
*Note: For each Android project, Ant and Eclipse will automatically include all .jars from the libs/ directory.*
16+
*Note for Eclipse users: The IDE should automatically include all .jars from the libs/ directory.*
1417

1518
*Note for IDEA users: You need to manually include jars from /libs for your module.*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="AndroidCucumberExampleTest" default="libs.init">
3+
<property name="url.variant" value="releases"/>
4+
<property name="url.base" value="https://oss.sonatype.org/content/repositories/${url.variant}/info/cukes"/>
5+
<property name="name.cucumber" value="cucumber-jvm"/>
6+
<property name="name.core" value="cucumber-core"/>
7+
<property name="name.java" value="cucumber-java"/>
8+
<property name="name.android" value="cucumber-android"/>
9+
<property name="file.metadata" value="maven-metadata.xml"/>
10+
<property name="file.dest" value="."/>
11+
<property name="file.libs" value="libs"/>
12+
<available file="${file.libs}" type="dir" property="file.libs.present"/>
13+
14+
<target name="libs.getmetadata">
15+
<get src="${url.base}/${name.cucumber}/${file.metadata}" dest="./"/>
16+
</target>
17+
18+
<target name="libs.getjar.libs" depends="libs.getmetadata" if="file.libs.present">
19+
<xmlproperty file="${file.metadata}" collapseAttributes="true"/>
20+
<get dest="${file.dest}/${file.libs}/">
21+
<url url="${url.base}/${name.core}/${metadata.versioning.latest}/${name.core}-${metadata.versioning.latest}.jar"/>
22+
<url url="${url.base}/${name.java}/${metadata.versioning.latest}/${name.java}-${metadata.versioning.latest}.jar"/>
23+
<url url="${url.base}/${name.android}/${metadata.versioning.latest}/${name.android}-${metadata.versioning.latest}.jar"/>
24+
</get>
25+
<delete file="${file.metadata}"/>
26+
</target>
27+
28+
<target name="libs.getjar.root" depends="libs.getmetadata" unless="file.libs.present">
29+
<xmlproperty file="${file.metadata}" collapseAttributes="true"/>
30+
<get dest="${file.dest}/">
31+
<url url="${url.base}/${name.core}/${metadata.versioning.latest}/${name.core}-${metadata.versioning.latest}.jar"/>
32+
<url url="${url.base}/${name.java}/${metadata.versioning.latest}/${name.java}-${metadata.versioning.latest}.jar"/>
33+
<url url="${url.base}/${name.android}/${metadata.versioning.latest}/${name.android}-${metadata.versioning.latest}.jar"/>
34+
</get>
35+
<delete file="${file.metadata}"/>
36+
</target>
37+
38+
<target name="libs.init" depends="libs.getjar.libs, libs.getjar.root"/>
39+
</project>

0 commit comments

Comments
 (0)