Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes gh-309: build.xml uploads junitX.jar as junit-depX.jar

  • Loading branch information...
commit 9de54af85dc755addcfeee4dbbbb79311393f739 1 parent 61f0654
David Saff authored
View
79 build.xml
@@ -1,13 +1,14 @@
<project name="junit" default="dist" basedir="."
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<tstamp />
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<property file="${user.home}/.junit.properties" />
<property name="src" value="src/main/java" />
<property name="target" location="target" />
<property name="bin" location="${target}/main" />
- <property name="version-base" value="4.9" />
- <property name="version-status" value="" />
+ <property name="version-base" value="4.9.1" />
+ <property name="version-status" value="-SNAPSHOT" />
<property name="version" value="${version-base}${version-status}" />
<property name="dist" value="junit${version}" />
<property name="versionfile" value="${src}/junit/runner/Version.java" />
@@ -217,19 +218,18 @@
<!-- to do automatic build upload, you need the maven ant tasks jar. -->
<!-- therefore, you must run ant as ant -lib build/lib stage.maven -->
- <macrodef name="stage.maven.jar">
+ <macrodef name="push.maven.jar">
<attribute name="jar" />
<attribute name="pom" />
+ <attribute name="url" />
+ <attribute name="repo.id" />
<element name="artifact.args" implicit="true" optional="true" />
<sequential>
- <property name="maven-repository-url"
- value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" />
- <property name="maven-repository-id" value="sonatype-nexus-staging" />
- <echo message="Staging to maven: @{jar}" />
+ <echo message="Pushing to maven: @{jar} -> @{url}" />
<artifact:mvn failonerror="true">
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.1:sign-and-deploy-file" />
- <arg value="-Durl=${maven-repository-url}" />
- <arg value="-DrepositoryId=${maven-repository-id}" />
+ <arg value="-Durl=@{url}" />
+ <arg value="-DrepositoryId=@{repo.id}" />
<arg value="-DpomFile=@{pom}" />
<arg value="-Dfile=@{jar}" />
<artifact.args />
@@ -238,40 +238,77 @@
</sequential>
</macrodef>
- <macrodef name="stage.maven.artifactId">
+ <macrodef name="push.maven.artifact">
<attribute name="artifactId" />
+ <attribute name="url" />
+ <attribute name="repo.id" />
+ <attribute name="is.snapshot" default="false" />
<sequential>
+ <local name="m.prefix" />
<property name="m.prefix" value="${dist}/@{artifactId}-${version}" />
+ <local name="m.jar" />
<property name="m.jar" value="${m.prefix}.jar" />
+ <local name="m.sources.jar" />
<property name="m.sources.jar" value="${m.prefix}-src.jar" />
+ <local name="m.javadoc.jar" />
<property name="m.javadoc.jar" value="${m.prefix}-javadoc.jar" />
+ <local name="m.pom" />
<property name="m.pom" value="${dist}/pom-@{artifactId}.xml" />
<filter token="version" value="${version}" />
<filter token="artifactId" value="@{artifactId}" />
<copy
- file="pom-template.xml"
+ file="build/maven/pom-template.xml"
tofile="${m.pom}"
filtering="on"
overwrite="true"
/>
- <stage.maven.jar jar="${m.jar}" pom="${m.pom}" />
-
- <stage.maven.jar jar="${m.sources.jar}" pom="${m.pom}" >
- <arg value="-Dclassifier=sources" />
- </stage.maven.jar>
+ <push.maven.jar jar="${m.jar}" pom="${m.pom}"
+ url="@{url}" repo.id="@{repo.id}" />
+
+ <if>
+ <equals arg1="${is.snapshot}" arg2="false" />
+ <then>
+ <push.maven.jar jar="${m.sources.jar}" pom="${m.pom}"
+ url="@{url}" repo.id="@{repo.id}">
+ <arg value="-Dclassifier=sources" />
+ </push.maven.jar>
- <stage.maven.jar jar="${m.javadoc.jar}" pom="${m.pom}" >
- <arg value="-Dclassifier=javadoc" />
- </stage.maven.jar>
+ <push.maven.jar jar="${m.javadoc.jar}" pom="${m.pom}"
+ url="@{url}" repo.id="@{repo.id}">
+ <arg value="-Dclassifier=javadoc" />
+ </push.maven.jar>
+ </then>
+ </if>
</sequential>
</macrodef>
<target name="stage.maven" depends="all.maven.jars">
- <stage.maven.artifactId artifactId="junit" />
- <stage.maven.artifactId artifactId="junit-dep" />
+ <property name="stage.url"
+ value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" />
+ <property name="stage.repo.id" value="sonatype-nexus-staging" />
+
+ <push.maven.artifact artifactId="junit"
+ url="${stage.url}"
+ repo.id="${stage.repo.id}" />
+ <push.maven.artifact artifactId="junit-dep"
+ url="${stage.url}"
+ repo.id="${stage.repo.id}" />
+ </target>
+
+ <target name="snapshot.maven" depends="all.maven.jars">
+ <property name="snapshot.url"
+ value="https://oss.sonatype.org/content/repositories/snapshots/" />
+ <property name="snapshot.repo.id" value="sonatype-nexus-snapshots" />
+
+ <push.maven.artifact artifactId="junit"
+ url="${snapshot.url}"
+ repo.id="${snapshot.repo.id}" />
+ <push.maven.artifact artifactId="junit-dep"
+ url="${snapshot.url}"
+ repo.id="${snapshot.repo.id}" />
</target>
<target name="print.version">
View
BIN  build/lib/ant-contrib-1.0b3.jar
Binary file not shown
View
0  pom-template.xml → build/maven/pom-template.xml
File renamed without changes
View
49 build/maven/post_maven_tests.sh
@@ -0,0 +1,49 @@
+set -e
+set -o pipefail
+
+function TEST_junit_dep_49_plays_not_nicely_with_later_hamcrest {
+ # Make sure our system notices the bug (this broke because of a bad push)
+ ! runs_with_newer_hamcrest junit-dep 4.9
+}
+
+function TEST_junit_dep_snapshot_plays_nicely_with_later_hamcrest {
+ runs_with_newer_hamcrest junit-dep LATEST
+}
+
+function TEST_junit_snapshot_plays_not_nicely_with_later_hamcrest {
+ ! runs_with_newer_hamcrest junit LATEST
+}
+
+function runs_with_newer_hamcrest {
+ local artifact_id=$1
+ local version=$2
+ rm -rf ~/.m2/repository/junit
+ rm -rf uses_junit
+ cp -r sample_project_template uses_junit
+ sed -i '' -e "s/___ARTIFACT_ID___/$artifact_id/" uses_junit/pom.xml
+ sed -i '' -e "s/___VERSION___/$version/" uses_junit/pom.xml
+ in_dir uses_junit mvn test
+ finally rm -rf uses_junit
+}
+
+### <copied src="https://gist.github.com/1206506">
+function in_dir {
+ local dir=$1
+ shift
+ if [ ! -e $dir ]; then
+ echo "$dir does not exist"
+ return 1
+ fi
+ pushd $dir >/dev/null
+ "$@"
+ finally popd >/dev/null
+}
+
+function finally {
+ local return_this=$?
+ "$@"
+ return $return_this
+}
+### </copied>
+
+source ../run_tests.sh
View
61 build/maven/sample_project_template/pom.xml
@@ -0,0 +1,61 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.example</groupId>
+ <artifactId>junit-dependency-test</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <version.hamcrest>1.2.1</version.hamcrest>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>___ARTIFACT_ID___</artifactId>
+ <version>___VERSION___</version>
+ </dependency>
+
+ <!--
+ This dependency must be included *before* junit, because said JAR
+ contains an old hamcrest-core version. This is problematic at
+ runtime; see JunitDependencyTest.
+ If junit-dep has the right contents, the order should not matter.
+ -->
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ <version>${version.hamcrest}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <version>${version.hamcrest}</version>
+ </dependency>
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>Sonatype</id>
+ <url>https://oss.sonatype.org/content/groups/public</url>
+ <snapshots><enabled>true</enabled></snapshots>
+ <releases><enabled>true</enabled></releases>
+ </repository>
+ </repositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
View
33 build/maven/sample_project_template/src/test/java/JunitDependencyTest.java
@@ -0,0 +1,33 @@
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+public final class JunitDependencyTest {
+ /**
+ * JUnit dependency test.
+ *
+ * This class has three dependencies. These can be on the classpath in
+ * different orders. Of the two orderings below, the first one will cause a
+ * NoSuchMethodError, while the second one allows the test to pass
+ * successfully. See the explanation below for more information.
+ *
+ * Ordering 1: junit-4.9, hamcrest-core-1.2.1, hamcrest-library-1.2.1.
+ * Ordering 2: hamcrest-core-1.2.1, junit-4.9, hamcrest-library-1.2.1.
+ */
+ @Test
+ public void test() {
+ /*
+ * Note that we call Matchers#anyOf(Matcher<T>, Matcher<? super T>).
+ * This method is provided by hamcrest-library-1.2.1. Said module is
+ * compiled against hamcrest-core-1.2.1. Matchers#anyOf calls
+ * AnyOf#anyOf(Matcher<T>, Matcher<? super T>). The latter method is
+ * provided by hamcrest-core-1.2.1, but *not* by hamcrest-core-1.1.
+ *
+ * However, hamcrest-core-1.1 *does* contain a class called AnyOf. Now,
+ * since junit-4.9 incorporates hamcrest-core-1.1 we must make sure that
+ * hamcrest-core-1.2.1 is placed *before* junit-4.9 on the classpath.
+ * Failure to do so will cause the wrong AnyOf class to be used. The
+ * result is a NoSuchMethodError.
+ */
+ Matchers.anyOf(Matchers.nullValue(), Matchers.notNullValue());
+ }
+}
View
36 build/run_tests.sh
@@ -0,0 +1,36 @@
+# See maven/post_maven_tests.sh for an example use
+
+SCRIPT_NAME=$0
+TEST_NAME=${1:-ALL}
+
+function get_tests() {
+ if [ $TEST_NAME == "ALL" ]; then
+ part1=function
+ part2=TEST_
+ grep "$part1 $part2" $SCRIPT_NAME | sed 's/.*\(TEST_[A-Za-z0-9_]*\).*/\1/'
+ else
+ echo "TEST_${TEST_NAME}"
+ fi
+}
+
+function run_tests() {
+ local exit_code=0
+
+ for t in $(get_tests); do
+ echo "RUNNING: $t"
+ if "$t"; then
+ echo "PASSED: $t"
+ else
+ echo "FAILED: $t"
+ return 1
+ fi
+ done
+}
+
+if run_tests; then
+ echo "ALL TESTS PASSED"
+ exit 0
+else
+ echo "A TEST FAILED"
+ exit 1
+fi
View
35 build_tests.sh
@@ -1,9 +1,6 @@
set -e
set -o pipefail
-SCRIPT_NAME=$0
-TEST_NAME=${1:-ALL}
-
function TEST_BUILDING_in_zip {
version=$(get_junit_version)
ant zip
@@ -76,34 +73,4 @@ function get_junit_version {
ant print.version | grep echo | sed 's/.*echo..\([1-9].*\)/\1/'
}
-function get_tests() {
- if [ $TEST_NAME == "ALL" ]; then
- part1=function
- part2=TEST_
- grep "$part1 $part2" $SCRIPT_NAME | sed 's/.*\(TEST_[A-Za-z0-9_]*\).*/\1/'
- else
- echo "TEST_${TEST_NAME}"
- fi
-}
-
-function run_tests() {
- local exit_code=0
-
- for t in $(get_tests); do
- echo "RUNNING: $t"
- if "$t"; then
- echo "PASSED: $t"
- else
- echo "FAILED: $t"
- return 1
- fi
- done
-}
-
-if run_tests; then
- echo "ALL TESTS PASSED"
- exit 0
-else
- echo "A TEST FAILED"
- exit 1
-fi
+source build/run_tests.sh
View
4 doc/ReleaseNotes4.9.1.html
@@ -0,0 +1,4 @@
+
+Can't open /Users/saff/git-repos/stems_and_seeds/junit/doc/ReleaseNotes4.9.1.txt: No such file or directory at build/Markdown.pl line 218.
+Use of uninitialized value $text in substitution (s///) at build/Markdown.pl line 245.
+Use of uninitialized value $text in substitution (s///) at build/Markdown.pl line 246.
View
12 pom-template.xml.asc
@@ -1,12 +0,0 @@
------BEGIN PGP SIGNATURE-----
-Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
-Comment: GPGTools - http://gpgtools.org
-
-iQEcBAABAgAGBQJNmdc8AAoJEIiqH+6DGn6J1GwH/j7bKXkEJuzC3JfL8cE5WJSt
-5Ld7PP8QbXYB1Ko2X7o4cofWfaWDI8/j723LzKPW8UNs16m+jILMMvQXYY+VW/XV
-UVm/wRY+fjgjoYb2HrREKKP/M2bO4hSHjVQxPT6nga33kKCfoBQ27tVaWdQe01/Q
-siQfhKVekK21D+Odxd7TqDlSi1CN7M5HsLms6YufXwoJmjZdtiCrFlFlPBQy8vBA
-LwjmbDCpe85rWqwsOSUev5p2MA+IWX0OM6D2b1kOWYjhuGrpLg38lpcJm3yGILH/
-OewOxsvYOXoxjJ8eaEljvbW+E1+rBxwNbd24T7yRFDA/pUUx9Dz2YYtIo69NCSg=
-=wLGS
------END PGP SIGNATURE-----
View
2  src/main/java/junit/runner/Version.java
@@ -9,7 +9,7 @@ private Version() {
}
public static String id() {
- return "4.9";
+ return "4.9.1-SNAPSHOT";
}
public static void main(String[] args) {
Please sign in to comment.
Something went wrong with that request. Please try again.