[52233] trunk/dports/java/junit

nox at macports.org nox at macports.org
Fri Jun 12 13:19:28 PDT 2009


Revision: 52233
          http://trac.macports.org/changeset/52233
Author:   nox at macports.org
Date:     2009-06-12 13:19:26 -0700 (Fri, 12 Jun 2009)
Log Message:
-----------
junit:
 * Use ant.
 * Fix hamcrest 1.2 incompatibilites.

Modified Paths:
--------------
    trunk/dports/java/junit/Portfile

Added Paths:
-----------
    trunk/dports/java/junit/files/
    trunk/dports/java/junit/files/patch-build.xml.diff
    trunk/dports/java/junit/files/patch-hamcrest-1.2-upgrade.diff
    trunk/dports/java/junit/files/patch-src-main-java-org-junit-matchers-package-info.java.diff

Modified: trunk/dports/java/junit/Portfile
===================================================================
--- trunk/dports/java/junit/Portfile	2009-06-12 20:04:59 UTC (rev 52232)
+++ trunk/dports/java/junit/Portfile	2009-06-12 20:19:26 UTC (rev 52233)
@@ -5,6 +5,7 @@
 
 name            junit
 version         4.6
+revision        1
 categories      java devel
 platforms       darwin
 maintainers     nox
@@ -24,88 +25,40 @@
                 sha1    98c8c625e999f0c7463397a684a5c47a0ea106e3 \
                 rmd160  4f87024e91b7252af89ad925db5cda0e17128525
 
+patchfiles      patch-build.xml.diff \
+                patch-src-main-java-org-junit-matchers-package-info.java.diff \
+                patch-hamcrest-1.2-upgrade.diff
+
 post-extract {
-    file mkdir ${worksrcpath}/src
-    system "cd ${worksrcpath}/src && jar -xvf ../${name}-${version}-src.jar"
-    
-    eval delete ${worksrcpath}/javadoc ${worksrcpath}/temp.hamcrest.source \
-        [glob -directory ${worksrcpath} *.jar]
-    
-    fs-traverse {f} ${worksrcpath} {
-        if {[string match *.class ${f}]} {
-            delete ${f}
-        }
-    }
+    file mkdir ${worksrcpath}/src/main/java
+    system "cd ${worksrcpath}/src/main/java && jar xvf ${worksrcpath}/${name}-${version}-src.jar"
 }
 
+
+depends_build   bin:ant:apache-ant
 depends_lib     port:hamcrest-core
 
 use_configure   no
 
+build.cmd       ant
+build.target    build
+build.args      -Dprefix=${prefix} \
+                -Dtestsrc=org/junit/tests \
+                -Ddist=.
+
 set docdir      ${prefix}/share/doc/${name}-${version}
 set javadir     ${prefix}/share/java
-set hamcrestpkg ${javadir}/hamcrest-core.jar
 set junitpkg    junit.jar
-set l           [string length ${worksrcpath}/]
 
-build {
-    set sources {}
-
-    fs-traverse {f} ${worksrcpath}/src {
-        if {[string match *.java ${f}]} {
-            lappend sources [string range ${f} ${l} end]
-        }
-    }
-    
-     file mkdir ${worksrcpath}/classes
-     foreach {source} ${sources} {
-         set cmdstring "cd ${worksrcpath} && javac -d classes -cp ${hamcrestpkg} -sourcepath src ${source}"
-         ui_debug ${cmdstring}
-         system ${cmdstring}
-     }
-
-    set cmdstring "cd ${worksrcpath} && jar -cf ${worksrcpath}/${junitpkg} -C classes ."
-    ui_debug ${cmdstring}
-    system ${cmdstring}
-}
-
-test {
-    set sources {}
-    
-    fs-traverse {f} "${worksrcpath}/junit/tests ${worksrcpath}/org/junit/tests" {
-        if {[string match *.java ${f}]} {
-            lappend sources [string range ${f} ${l} end]
-        }
-    }
-    
-     file mkdir ${worksrcpath}/classes
-     foreach {source} ${sources} {
-         set cmdstring "cd ${worksrcpath} && javac -d classes -cp ${hamcrestpkg}:${junitpkg} -sourcepath . ${source}"
-         ui_debug ${cmdstring}
-         system ${cmdstring}
-     }
-
-    foreach {p} {junit org.junit} {
-        set class ${p}.tests.AllTests
-        set cmdstring "cd ${worksrcpath} && java -cp classes:${junitpkg}:${hamcrestpkg} org.junit.runner.JUnitCore ${class}"
-        ui_debug ${cmdstring}
-        system ${cmdstring}
-    }
-}
-
 destroot {
+    system "jar cvf ${worksrcpath}/${junitpkg} -C ${worksrcpath}/target/main ."
     xinstall -d ${destroot}${javadir} ${destroot}${docdir}
     xinstall -m 0644 ${worksrcpath}/${junitpkg} ${destroot}${javadir}
     copy ${worksrcpath}/doc ${destroot}${docdir}/html
 }
 
 variant doc description {Install extra documentation} {
-    post-build {
-        file mkdir ${worksrcpath}/javadoc
-        set cmdstring "cd ${worksrcpath} && javadoc -d javadoc -sourcepath src -subpackages junit:org -classpath .:${hamcrestpkg}"
-        ui_debug ${cmdstring}
-        system ${cmdstring}
-    }
+    build.target-append javadoc
     
     post-destroot {
         file copy ${worksrcpath}/javadoc ${destroot}${docdir}/

Added: trunk/dports/java/junit/files/patch-build.xml.diff
===================================================================
--- trunk/dports/java/junit/files/patch-build.xml.diff	                        (rev 0)
+++ trunk/dports/java/junit/files/patch-build.xml.diff	2009-06-12 20:19:26 UTC (rev 52233)
@@ -0,0 +1,40 @@
+--- build.xml.orig	2009-06-12 21:55:56.000000000 +0200
++++ build.xml	2009-06-12 22:15:35.000000000 +0200
+@@ -18,7 +18,7 @@
+ 	<property name="javadocdir" location="${dist}/javadoc" />
+ 	<property name="javadoczip" location="${dist}-javadoc.zip" />
+ 	<property name="javadocpackages" value="org.junit, org.junit.runner, org.junit.runner.description, org.junit.runner.manipulation, org.junit.runner.notification, org.junit.runners, org.hamcrest.core, org.junit.matchers" />
+-	<property name="hamcrestlib" location="lib/hamcrest-core-1.1.jar" />
++	<property name="hamcrestlib" value="${prefix}/share/java/hamcrest-core.jar;${prefix}/share/java/hamcrest-library.jar" />
+ 	<property name="hamcrestsrc" location="${dist}/temp.hamcrest.source" />
+ 	
+ 	<target name="init">
+@@ -72,8 +72,6 @@
+ 	
+ 	<target name="build" depends="versiontag">
+ 		<junit_compilation srcdir="${src}" destdir="${bin}" classpath="${hamcrestlib}"/>
+-		<unjar src="${hamcrestlib}" dest="${bin}" />
+-		<junit_compilation srcdir="${testsrc}" destdir="${testbin}" classpath="${hamcrestlib};${bin}"/>
+ 	</target>
+ 
+ 	<target name="jars">
+@@ -106,17 +104,16 @@
+ 		<unjar src="${hamcrestlib}" dest="${hamcrestsrc}" />
+ 	</target>
+ 	
+-	<target name="javadoc" depends="unjar.hamcrest">
++	<target name="javadoc">
+ 		<javadoc packagenames="${javadocpackages}"
+ 		         destdir="${javadocdir}"
+ 		         author="false"
+ 		         version="false"
+ 		         use="false"
+ 		         windowtitle="JUnit API"
+-		         stylesheetfile="stylesheet.css"
++			 classpath="${hamcrestlib}"
+ 		>
+ 			<sourcepath location="${src}" />
+-			<sourcepath location="${hamcrestsrc}" />
+ 		</javadoc>
+ 	</target>
+ 

Added: trunk/dports/java/junit/files/patch-hamcrest-1.2-upgrade.diff
===================================================================
--- trunk/dports/java/junit/files/patch-hamcrest-1.2-upgrade.diff	                        (rev 0)
+++ trunk/dports/java/junit/files/patch-hamcrest-1.2-upgrade.diff	2009-06-12 20:19:26 UTC (rev 52233)
@@ -0,0 +1,281 @@
+--- src/main/java/org/junit/internal/matchers/CombinableMatcher.java	2009-06-12 05:01:46.000000000 +0200
++++ src/main/java/org/junit/internal/matchers/CombinableMatcher.java	2009-06-12 15:54:29.000000000 +0200
+@@ -1,34 +1,14 @@
+ package org.junit.internal.matchers;
+ 
+-import static org.hamcrest.CoreMatchers.allOf;
+-import static org.hamcrest.CoreMatchers.anyOf;
+-import org.hamcrest.BaseMatcher;
+-import org.hamcrest.Description;
+ import org.hamcrest.Matcher;
+ 
+-public class CombinableMatcher<T> extends BaseMatcher<T> {
+-
+-	private final Matcher<? extends T> fMatcher;
+-
+-	public CombinableMatcher(Matcher<? extends T> matcher) {
+-		fMatcher= matcher;
+-	}
+-
+-	public boolean matches(Object item) {
+-		return fMatcher.matches(item);
+-	}
+-
+-	public void describeTo(Description description) {
+-		description.appendDescriptionOf(fMatcher);
+-	}
+-	
+-	@SuppressWarnings("unchecked")
+-	public CombinableMatcher<T> and(Matcher<? extends T> matcher) {
+-		return new CombinableMatcher<T>(allOf(matcher, fMatcher));
+-	}
+-
+-	@SuppressWarnings("unchecked")
+-	public CombinableMatcher<T> or(Matcher<? extends T> matcher) {
+-		return new CombinableMatcher<T>(anyOf(matcher, fMatcher));
++/**
++ * @deprectated Use org.hamcrest.core.CombinableMatcher directly
++ */
++ at Deprecated
++public class CombinableMatcher<T> extends org.hamcrest.core.CombinableMatcher<T> {
++	// should only be using static factories
++	private CombinableMatcher(Matcher<? super T> matcher) {
++		super(matcher);
+ 	}
+ }
+\ No newline at end of file
+--- src/main/java/org/junit/internal/matchers/Each.java	2009-06-12 05:01:46.000000000 +0200
++++ src/main/java/org/junit/internal/matchers/Each.java	2009-06-12 15:54:29.000000000 +0200
+@@ -1,24 +1,15 @@
+ package org.junit.internal.matchers;
+ 
+-import static org.hamcrest.CoreMatchers.not;
+-import static org.junit.internal.matchers.IsCollectionContaining.hasItem;
+-import org.hamcrest.BaseMatcher;
+-import org.hamcrest.Description;
+ import org.hamcrest.Matcher;
++import org.hamcrest.core.Every;
+ 
++
++/**
++ * @deprecated use org.hamcrest.core.Every
++ */
++ at Deprecated
+ public class Each {
+ 	public static <T> Matcher<Iterable<T>> each(final Matcher<T> individual) {
+-		final Matcher<Iterable<T>> allItemsAre = not(hasItem(not(individual)));
+-		
+-		return new BaseMatcher<Iterable<T>>() {
+-			public boolean matches(Object item) {
+-				return allItemsAre.matches(item);
+-			}
+-			
+-			public void describeTo(Description description) {
+-				description.appendText("each ");
+-				individual.describeTo(description);
+-			}
+-		};
++		return Every.everyItem(individual);
+ 	}
+ }
+--- src/main/java/org/junit/internal/matchers/IsCollectionContaining.java	2009-06-12 05:01:46.000000000 +0200
++++ src/main/java/org/junit/internal/matchers/IsCollectionContaining.java	2009-06-12 15:54:29.000000000 +0200
+@@ -1,67 +1,16 @@
+ package org.junit.internal.matchers;
+ 
+-import static org.hamcrest.core.AllOf.allOf;
+-import static org.hamcrest.core.IsEqual.equalTo;
+-
+-import java.util.ArrayList;
+-import java.util.Collection;
+-
+-import org.hamcrest.Description;
+-import org.hamcrest.Factory;
+ import org.hamcrest.Matcher;
+ 
+ // Copied (hopefully temporarily) from hamcrest-library
+-public class IsCollectionContaining<T> extends TypeSafeMatcher<Iterable<T>> {
+-    private final Matcher<? extends T> elementMatcher;
+-
+-    public IsCollectionContaining(Matcher<? extends T> elementMatcher) {
+-        this.elementMatcher = elementMatcher;
+-    }
+-
+-    @Override
+-	public boolean matchesSafely(Iterable<T> collection) {
+-        for (T item : collection) {
+-            if (elementMatcher.matches(item)){
+-                return true;
+-            }
+-        }
+-        return false;
+-    }
+-
+-    public void describeTo(Description description) {
+-        description
+-        	.appendText("a collection containing ")
+-        	.appendDescriptionOf(elementMatcher);
+-    }
+-
+-    @Factory
+-    public static <T> Matcher<Iterable<T>> hasItem(Matcher<? extends T> elementMatcher) {
+-        return new IsCollectionContaining<T>(elementMatcher);
+-    }
+-
+-    @Factory
+-    public static <T> Matcher<Iterable<T>> hasItem(T element) {
+-        return hasItem(equalTo(element));
+-    }
+-
+-    @Factory
+-    public static <T> Matcher<Iterable<T>> hasItems(Matcher<? extends T>... elementMatchers) {
+-        Collection<Matcher<? extends Iterable<T>>> all
+-                = new ArrayList<Matcher<? extends Iterable<T>>>(elementMatchers.length);
+-        for (Matcher<? extends T> elementMatcher : elementMatchers) {
+-            all.add(hasItem(elementMatcher));
+-        }
+-        return allOf(all);
+-    }
+-
+-    @Factory
+-    public static <T> Matcher<Iterable<T>> hasItems(T... elements) {
+-        Collection<Matcher<? extends Iterable<T>>> all
+-                = new ArrayList<Matcher<? extends Iterable<T>>>(elements.length);
+-        for (T element : elements) {
+-            all.add(hasItem(element));
+-        }
+-        return allOf(all);
+-    }
+-
++/**
++ * @deprecated use org.hamcrest.core.IsCollectionContaining directly
++ */
++ at Deprecated 
++public class IsCollectionContaining<T> extends org.hamcrest.core.IsCollectionContaining<T> {
++	// Client code should just use static factories, so this should be OK
++	private IsCollectionContaining(Matcher<? super T> elementMatcher) {
++		super(elementMatcher);
++		// TODO Auto-generated constructor stub
++	}
+ }
+--- src/main/java/org/junit/matchers/JUnitMatchers.java	2009-06-12 05:01:47.000000000 +0200
++++ src/main/java/org/junit/matchers/JUnitMatchers.java	2009-06-12 15:54:29.000000000 +0200
+@@ -1,38 +1,46 @@
+ package org.junit.matchers;
+ 
++import org.hamcrest.CoreMatchers;
+ import org.hamcrest.Matcher;
+-import org.junit.internal.matchers.CombinableMatcher;
+-import org.junit.internal.matchers.Each;
+-import org.junit.internal.matchers.IsCollectionContaining;
+-import org.junit.internal.matchers.StringContains;
++import org.hamcrest.core.CombinableMatcher;
+ 
+ /**
+  * Convenience import class: these are useful matchers for use with the assertThat method, but they are
+  * not currently included in the basic CoreMatchers class from hamcrest.
++ * @deprecated as of JUnit 4.7, all of these matchers are found in the org.hamcrest.CoreMatchers
++ *             class instead.
+  */
++ at Deprecated
+ public class JUnitMatchers {
++	// TODO (May 27, 2009 11:46:27 AM): deprecate all?
+ 	/**
+ 	 * @param element
+ 	 * @return A matcher matching any collection containing element
++	 * @deprecated Use org.hamcrest.CoreMatchers.hasItem
+ 	 */
+-	public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> hasItem(T element) {
+-		return IsCollectionContaining.hasItem(element);
++	@Deprecated
++	public static <T> Matcher<Iterable<? super T>> hasItem(T element) {
++		return CoreMatchers.<T>hasItem(element);
+ 	}
+ 
+ 	/**
+ 	 * @param elementMatcher
+ 	 * @return A matcher matching any collection containing an element matching elementMatcher
++	 * @deprecated Use org.hamcrest.CoreMatchers.hasItem
+ 	 */
+-	public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> hasItem(org.hamcrest.Matcher<? extends T> elementMatcher) {
+-		return IsCollectionContaining.hasItem(elementMatcher);
++	@Deprecated
++    public static <T> Matcher<Iterable<? super T>> hasItem(Matcher<? super T> elementMatcher) {
++		return CoreMatchers.<T>hasItem(elementMatcher);
+ 	}
+ 
+ 	/**
+ 	 * @param elements
+ 	 * @return A matcher matching any collection containing every element in elements
++	 * @deprecated Use org.hamcrest.CoreMatchers.hasItems
+ 	 */
++	@Deprecated
+ 	public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> hasItems(T... elements) {
+-		return IsCollectionContaining.hasItems(elements);
++		return CoreMatchers.<T>hasItems(elements);
+ 	}
+ 
+ 	/**
+@@ -40,25 +48,31 @@
+ 	 * @return A matcher matching any collection containing at least one element that matches 
+ 	 *         each matcher in elementMatcher (this may be one element matching all matchers,
+ 	 *         or different elements matching each matcher)
++	 * @deprecated Use org.hamcrest.CoreMatchers.hasItems
+ 	 */
+-	public static <T> org.hamcrest.Matcher<java.lang.Iterable<T>> hasItems(org.hamcrest.Matcher<? extends T>... elementMatchers) {
+-		return IsCollectionContaining.hasItems(elementMatchers);
++	@Deprecated
++	public static <T> Matcher<Iterable<T>> hasItems(Matcher<? super T>... elementMatchers) {
++		return CoreMatchers.<T>hasItems(elementMatchers);
+ 	}
+ 
+ 	/**
+ 	 * @param elementMatcher
+ 	 * @return A matcher matching any collection in which every element matches elementMatcher
++	 * @deprecated use CoreMatchers.everyItem directly
+ 	 */
++	@Deprecated
+ 	public static <T> Matcher<Iterable<T>> everyItem(final Matcher<T> elementMatcher) {
+-		return Each.each(elementMatcher);
++		return CoreMatchers.everyItem(elementMatcher);
+ 	}
+ 
+ 	/**
+ 	 * @param substring
+ 	 * @return a matcher matching any string that contains substring
++	 * @deprecated Use org.hamcrest.CoreMatchers.containsString
+ 	 */
++	@Deprecated
+ 	public static org.hamcrest.Matcher<java.lang.String> containsString(java.lang.String substring) {
+-		return StringContains.containsString(substring);
++		return CoreMatchers.containsString(substring);
+ 	}
+ 	
+ 	/**
+@@ -66,9 +80,11 @@
+ 	 * <pre>
+ 	 *   assertThat(string, both(containsString("a")).and(containsString("b")));
+ 	 * </pre>
++	 * @deprecated Use org.hamcrest.CoreMatchers.both
+ 	 */
+-	public static <T> CombinableMatcher<T> both(Matcher<T> matcher) {
+-		return new CombinableMatcher<T>(matcher);
++	@Deprecated
++	public static <T> CombinableMatcher<T> both(Matcher<? super T> matcher) {
++		return CoreMatchers.both(matcher);
+ 	}
+ 	
+ 	/**
+@@ -76,8 +92,10 @@
+ 	 * <pre>
+ 	 *   assertThat(string, both(containsString("a")).and(containsString("b")));
+ 	 * </pre>
++	 * @deprecated Use org.hamcrest.CoreMatchers.either
+ 	 */
+-	public static <T> CombinableMatcher<T> either(Matcher<T> matcher) {
+-		return new CombinableMatcher<T>(matcher);
++	@Deprecated
++	public static <T> CombinableMatcher<T> either(Matcher<? super T> matcher) {
++		return CoreMatchers.either(matcher);
+ 	}	
+ }

Added: trunk/dports/java/junit/files/patch-src-main-java-org-junit-matchers-package-info.java.diff
===================================================================
--- trunk/dports/java/junit/files/patch-src-main-java-org-junit-matchers-package-info.java.diff	                        (rev 0)
+++ trunk/dports/java/junit/files/patch-src-main-java-org-junit-matchers-package-info.java.diff	2009-06-12 20:19:26 UTC (rev 52233)
@@ -0,0 +1,10 @@
+--- src/main/java/org/junit/matchers/package-info.java.orig	2009-06-12 22:13:05.000000000 +0200
++++ src/main/java/org/junit/matchers/package-info.java	2009-06-12 22:13:18.000000000 +0200
+@@ -4,6 +4,6 @@
+  * statement
+  *
+  * @since 4.0
+- * @see JUnitMatchers
++ * @see org.junit.matchers.JUnitMatchers
+  */
+ package org.junit.matchers;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090612/624babd3/attachment-0001.html>


More information about the macports-changes mailing list