pax_global_header00006660000000000000000000000064116337347720014527gustar00rootroot0000000000000052 comment=a39f639ea011a77f5c4fc300141d032b44a0b565 animal-sniffer-1.7/000077500000000000000000000000001163373477200142715ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-annotations/000077500000000000000000000000001163373477200215175ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-annotations/pom.xml000066400000000000000000000047531163373477200230450ustar00rootroot00000000000000 4.0.0 org.codehaus.mojo animal-sniffer-parent 1.7 animal-sniffer-annotations Animal Sniffer Annotations org.apache.maven.plugins maven-enforcer-plugin enforce-java enforce Annotations require Java 1.5+ to compile [1.5,) maven-compiler-plugin 1.5 1.5 animal-sniffer-1.7/animal-sniffer-annotations/src/000077500000000000000000000000001163373477200223065ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-annotations/src/main/000077500000000000000000000000001163373477200232325ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-annotations/src/main/java/000077500000000000000000000000001163373477200241535ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-annotations/src/main/java/org/000077500000000000000000000000001163373477200247425ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-annotations/src/main/java/org/codehaus/000077500000000000000000000000001163373477200265355ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-annotations/src/main/java/org/codehaus/mojo/000077500000000000000000000000001163373477200275015ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-annotations/src/main/java/org/codehaus/mojo/animal_sniffer/000077500000000000000000000000001163373477200324565ustar00rootroot00000000000000IgnoreJRERequirement.java000066400000000000000000000031071163373477200372500ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-annotations/src/main/java/org/codehaus/mojo/animal_snifferpackage org.codehaus.mojo.animal_sniffer; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import static java.lang.annotation.RetentionPolicy.CLASS; import java.lang.annotation.Target; /** * @author Kohsuke Kawaguchi */ @Retention(CLASS) @Documented @Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE}) public @interface IgnoreJRERequirement { } animal-sniffer-1.7/animal-sniffer-annotations/src/site/000077500000000000000000000000001163373477200232525ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-annotations/src/site/apt/000077500000000000000000000000001163373477200240365ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-annotations/src/site/apt/index.apt.vm000066400000000000000000000114501163373477200262750ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Animal Sniffer Annotations ----- Stephen Connolly ----- 2009-11-03 ----- Animal Sniffer Annotations Animal Sniffer Annotations provides Java 1.5+ annotations which allow marking methods which Animal Sniffer should ignore signature violations of. * Introduction Animal Sniffer is designed to detect when you have used classes/methods/fields which are not part of the JRE that you are targetting. There are certain situations when you might be compiling with a newer JDK than the JRE you are targetting. For example newer versions of MacOS do not have JDK 1.5 available and so only JDK 1.6 can be used. Another case is where you are targetting JRE 1.5, but you need to work around some bugs in the JDK 1.5 compiler (there are some well known bugs to do with generics) and so you compile with JDK 1.6. There are some situations where you may want to make use of some of the classes that are available on the newer JRE when your program is executed on the newer JDK. For example, JDK 1.6 introduced <<>>. In these cases you would wrap the use of the newer classes inside a <<>> block, e.g. --- ... import javax.awt.SplashScreen; ... public final class Someclass { ... public static void main(String[] args) { ... // long running initialization ... try { SplashScreen.getSplashScreen().close(); } catch (LinkageError e) { // JDK 5 doesn't display a splash screen, no need to hide it } ... } ... } --- The above code will require JDK 1.6 or newer to compile, but will safely run on JRE 1.5. When you run animal-sniffer over the above class with the signatures for JRE 1.5, however, animal sniffer will report a signature failure. Animal Sniffer Annotations provides an annotation <<<@IgnoreJRERequirement>>> which you can use to annotate methods which are to be ignored by animal sniffer, e.g. --- public final class MapFactory { ... @IgnoreJRERequirement public ConcurrentMap newConcurrentMap() { try { // Note this map implementation is only available in JRE 1.6+ return new ConcurrentSkipListMap(); } catch (LinkageError e) { // fall back to JRE 1.5's only concurrent map return new ConcurrentHashMap(); } } ... } --- Note: if you have compiled with the <<>> you do not have to change anything as animal-sniffer automatically detects this annotation as well (even although it is in a different package. * Using animal-sniffer-annotations in Maven projects To annotate your methods, you need to add either an optional and/or provided dependency on <<>>, (technically optional is the correct way, but to work around some incorrectly written maven plugins, you may end up using scope provided) e.g. --- ... ... ${project.groupId} ${project.artifactId} ${project.version} true ... ... ... ... maven-compiler-plugin ... ... 1.5 1.5 ... ... ... ... --- animal-sniffer-1.7/animal-sniffer-annotations/src/site/site.xml000066400000000000000000000024771163373477200247520ustar00rootroot00000000000000 animal-sniffer-1.7/animal-sniffer-ant-tasks/000077500000000000000000000000001163373477200210675ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/pom.xml000066400000000000000000000106741163373477200224140ustar00rootroot00000000000000 4.0.0 org.codehaus.mojo animal-sniffer-parent 1.7 org.codehaus.mojo animal-sniffer-ant-tasks jar Animal Sniffer Ant Tasks Animal Sniffer Ant Tasks. org.codehaus.mojo animal-sniffer 1.7 org.apache.ant ant 1.7.1 provided org.apache.maven.plugins maven-shade-plugin 1.2.1 package shade false true junit:junit org.objectweb.asm org.codehaus.mojo.animal_sniffer.asm.shaded maven-invoker-plugin */pom.xml run-its verify org.apache.maven.plugins maven-invoker-plugin 1.4 integration-test install run false true animal-sniffer-1.7/animal-sniffer-ant-tasks/src/000077500000000000000000000000001163373477200216565ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/000077500000000000000000000000001163373477200222725ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/000077500000000000000000000000001163373477200243465ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/build.xml000066400000000000000000000135461163373477200262000ustar00rootroot00000000000000 animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/invoker.properties000066400000000000000000000021631163373477200301430ustar00rootroot00000000000000# # The MIT License # # Copyright (c) 2009 codehaus.org. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # invoker.goals=validate animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/pom.xml000066400000000000000000000077261163373477200256770ustar00rootroot00000000000000 4.0.0 integration-test merge-test pom 1.0-SNAPSHOT Check that signature files can be merged. maven-clean-plugin 2.3 maven-source-plugin 2.0.4 maven-dependency-plugin 2.1 maven-resources-plugin 2.3 maven-surefire-plugin 2.4.3 maven-install-plugin 2.2 maven-deploy-plugin 2.4 maven-site-plugin 2.0-beta-6 maven-compiler-plugin 2.0.2 org.apache.maven.plugins maven-antrun-plugin 1.3 maven-jar-plugin 2.2 org.apache.maven.plugins maven-antrun-plugin validate run UTF-8 UTF-8 UTF-8 animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/000077500000000000000000000000001163373477200251355ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api1/000077500000000000000000000000001163373477200257675ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api1/java/000077500000000000000000000000001163373477200267105ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api1/java/localdomain/000077500000000000000000000000001163373477200311725ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api1/java/localdomain/localhost/000077500000000000000000000000001163373477200331625ustar00rootroot00000000000000Api.java000066400000000000000000000023121163373477200344550ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api1/java/localdomain/localhostpackage localdomain.localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public interface Api { void checkVersion1(); }animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api2/000077500000000000000000000000001163373477200257705ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api2/java/000077500000000000000000000000001163373477200267115ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api2/java/localdomain/000077500000000000000000000000001163373477200311735ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api2/java/localdomain/localhost/000077500000000000000000000000001163373477200331635ustar00rootroot00000000000000Api.java000066400000000000000000000023451163373477200344640ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api2/java/localdomain/localhostpackage localdomain.localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public interface Api { void checkVersion1(); void checkVersion2(); }animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api3/000077500000000000000000000000001163373477200257715ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api3/java/000077500000000000000000000000001163373477200267125ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api3/java/localdomain/000077500000000000000000000000001163373477200311745ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api3/java/localdomain/localhost/000077500000000000000000000000001163373477200331645ustar00rootroot00000000000000OtherApi.java000066400000000000000000000023171163373477200354660ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/api3/java/localdomain/localhostpackage localdomain.localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public interface OtherApi { void checkVersion3(); }animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/main/000077500000000000000000000000001163373477200260615ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/main/java/000077500000000000000000000000001163373477200270025ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/merge-test/src/main/java/JDK15.java000066400000000000000000000025221163373477200304240ustar00rootroot00000000000000/* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import localdomain.localhost.Api; import localdomain.localhost.OtherApi; public class JDK15 { public void doChecks(Api api, OtherApi other) { api.checkVersion2(); other.checkVersion3(); } }animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/000077500000000000000000000000001163373477200250515ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/build.xml000066400000000000000000000113211163373477200266700ustar00rootroot00000000000000 animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/invoker.properties000066400000000000000000000022171163373477200306460ustar00rootroot00000000000000# # The MIT License # # Copyright (c) 2009 codehaus.org. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # invoker.goals=validate invoker.buildResult=failure animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/pom.xml000066400000000000000000000077371163373477200264040ustar00rootroot00000000000000 4.0.0 integration-test negative-test pom 1.0-SNAPSHOT Test that a signature mismatch fails the build. maven-clean-plugin 2.3 maven-source-plugin 2.0.4 maven-dependency-plugin 2.1 maven-resources-plugin 2.3 maven-surefire-plugin 2.4.3 maven-install-plugin 2.2 maven-deploy-plugin 2.4 maven-site-plugin 2.0-beta-6 maven-compiler-plugin 2.0.2 org.apache.maven.plugins maven-antrun-plugin 1.3 maven-jar-plugin 2.2 org.apache.maven.plugins maven-antrun-plugin validate run UTF-8 UTF-8 UTF-8 animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/000077500000000000000000000000001163373477200256405ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/api1/000077500000000000000000000000001163373477200264725ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/api1/java/000077500000000000000000000000001163373477200274135ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/api1/java/localdomain/000077500000000000000000000000001163373477200316755ustar00rootroot00000000000000000077500000000000000000000000001163373477200336065ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/api1/java/localdomain/localhostApi.java000066400000000000000000000023121163373477200351600ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/api1/java/localdomain/localhostpackage localdomain.localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public interface Api { void checkVersion1(); }animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/api2/000077500000000000000000000000001163373477200264735ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/api2/java/000077500000000000000000000000001163373477200274145ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/api2/java/localdomain/000077500000000000000000000000001163373477200316765ustar00rootroot00000000000000000077500000000000000000000000001163373477200336075ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/api2/java/localdomain/localhostApi.java000066400000000000000000000023451163373477200351670ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/api2/java/localdomain/localhostpackage localdomain.localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public interface Api { void checkVersion1(); void checkVersion2(); }animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/main/000077500000000000000000000000001163373477200265645ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/main/java/000077500000000000000000000000001163373477200275055ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/negative-test/src/main/java/JDK15.java000066400000000000000000000023741163373477200311340ustar00rootroot00000000000000/* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import localdomain.localhost.Api; public class JDK15 { public void doChecks(Api api) { api.checkVersion2(); } }animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/settings.xml000066400000000000000000000045451163373477200246640ustar00rootroot00000000000000 it-repo true central file:///@localRepository@ true ignore never true ignore never central file:///@localRepository@ true ignore never true ignore never animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/000077500000000000000000000000001163373477200243655ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/build.xml000066400000000000000000000113161163373477200262100ustar00rootroot00000000000000 animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/invoker.properties000066400000000000000000000021631163373477200301620ustar00rootroot00000000000000# # The MIT License # # Copyright (c) 2009 codehaus.org. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # invoker.goals=validate animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/pom.xml000066400000000000000000000077451163373477200257170ustar00rootroot00000000000000 4.0.0 integration-test smoke-test pom 1.0-SNAPSHOT Test that the basic functionality works (positive test). maven-clean-plugin 2.3 maven-source-plugin 2.0.4 maven-dependency-plugin 2.1 maven-resources-plugin 2.3 maven-surefire-plugin 2.4.3 maven-install-plugin 2.2 maven-deploy-plugin 2.4 maven-site-plugin 2.0-beta-6 maven-compiler-plugin 2.0.2 org.apache.maven.plugins maven-antrun-plugin 1.3 maven-jar-plugin 2.2 org.apache.maven.plugins maven-antrun-plugin validate run UTF-8 UTF-8 UTF-8 animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/000077500000000000000000000000001163373477200251545ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/api1/000077500000000000000000000000001163373477200260065ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/api1/java/000077500000000000000000000000001163373477200267275ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/api1/java/localdomain/000077500000000000000000000000001163373477200312115ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/api1/java/localdomain/localhost/000077500000000000000000000000001163373477200332015ustar00rootroot00000000000000Api.java000066400000000000000000000023121163373477200344740ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/api1/java/localdomain/localhostpackage localdomain.localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public interface Api { void checkVersion1(); }animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/api2/000077500000000000000000000000001163373477200260075ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/api2/java/000077500000000000000000000000001163373477200267305ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/api2/java/localdomain/000077500000000000000000000000001163373477200312125ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/api2/java/localdomain/localhost/000077500000000000000000000000001163373477200332025ustar00rootroot00000000000000Api.java000066400000000000000000000023451163373477200345030ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/api2/java/localdomain/localhostpackage localdomain.localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public interface Api { void checkVersion1(); void checkVersion2(); }animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/main/000077500000000000000000000000001163373477200261005ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/main/java/000077500000000000000000000000001163373477200270215ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/it/smoke-test/src/main/java/JDK15.java000066400000000000000000000023741163373477200304500ustar00rootroot00000000000000/* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import localdomain.localhost.Api; public class JDK15 { public void doChecks(Api api) { api.checkVersion2(); } }animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/000077500000000000000000000000001163373477200226025ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/java/000077500000000000000000000000001163373477200235235ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/java/org/000077500000000000000000000000001163373477200243125ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/java/org/codehaus/000077500000000000000000000000001163373477200261055ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/java/org/codehaus/mojo/000077500000000000000000000000001163373477200270515ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/java/org/codehaus/mojo/animal_sniffer/000077500000000000000000000000001163373477200320265ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/java/org/codehaus/mojo/animal_sniffer/ant/000077500000000000000000000000001163373477200326105ustar00rootroot00000000000000AntLogger.java000066400000000000000000000046701163373477200352650ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/java/org/codehaus/mojo/animal_sniffer/antpackage org.codehaus.mojo.animal_sniffer.ant; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.codehaus.mojo.animal_sniffer.logging.Logger; import org.apache.tools.ant.Task; import org.apache.tools.ant.Project; /** * An animal sniffer logger that delegates to a maven log. * * @author connollys * @since 1.3 */ public final class AntLogger implements Logger { private final Task delegate; public AntLogger( Task delegate ) { this.delegate = delegate; } public void info( String message ) { delegate.log( message, Project.MSG_INFO ); } public void info( String message, Throwable t ) { delegate.log( message, t, Project.MSG_INFO ); } public void debug( String message ) { delegate.log( message, Project.MSG_DEBUG ); } public void debug( String message, Throwable t ) { delegate.log( message, t, Project.MSG_DEBUG ); } public void warn( String message ) { delegate.log( message, Project.MSG_WARN ); } public void warn( String message, Throwable t ) { delegate.log( message, t, Project.MSG_WARN ); } public void error( String message ) { delegate.log( message, Project.MSG_ERR ); } public void error( String message, Throwable t ) { delegate.log( message, t, Project.MSG_ERR ); } }BuildSignaturesTask.java000066400000000000000000000132151163373477200373250ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/java/org/codehaus/mojo/animal_sniffer/antpackage org.codehaus.mojo.animal_sniffer.ant; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Path; import org.codehaus.mojo.animal_sniffer.SignatureBuilder; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Iterator; import java.util.Vector; /** * @author Kohsuke Kawaguchi */ public class BuildSignaturesTask extends Task { private File destfile; private Vector paths = new Vector(); private Vector signatures = new Vector(); private Vector includeClasses = new Vector(); private Vector excludeClasses = new Vector(); public void setDestfile( File dest ) { this.destfile = dest; } public void addPath( Path path ) { paths.add( path ); } public Signature createSignature() { Signature signature = new Signature(); signatures.add( signature ); return signature; } public Ignore createIncludeClasses() { final Ignore result = new Ignore(); includeClasses.add( result ); return result; } public Ignore createExcludeClasses() { final Ignore result = new Ignore(); excludeClasses.add( result ); return result; } protected void validate() { if ( destfile == null ) { throw new BuildException( "destfile not set" ); } if ( paths.size() < 1 ) { throw new BuildException( "path not set" ); } Iterator i = signatures.iterator(); while ( i.hasNext() ) { Signature signature = (Signature) i.next(); if ( signature.getSrc() == null ) { throw new BuildException( "signature src not set" ); } if ( !signature.getSrc().isFile() ) { throw new BuildException( "signature " + signature.getSrc() + " does not exist" ); } } i = includeClasses.iterator(); while ( i.hasNext() ) { Ignore tmp = (Ignore) i.next(); if ( tmp.getClassName() == null ) { throw new BuildException( "includeClasses className not set" ); } } i = excludeClasses.iterator(); while ( i.hasNext() ) { Ignore tmp = (Ignore) i.next(); if ( tmp.getClassName() == null ) { throw new BuildException( "excludeClasses className not set" ); } } } public void execute() throws BuildException { validate(); try { Vector inStreams = new Vector(); Iterator i = signatures.iterator(); while ( i.hasNext() ) { Signature signature = (Signature) i.next(); log( "Importing signatures from " + signature.getSrc() ); inStreams.add( new FileInputStream( signature.getSrc() ) ); } SignatureBuilder builder = new SignatureBuilder( (InputStream[]) inStreams.toArray( new InputStream[inStreams.size()] ), new FileOutputStream( destfile ), new AntLogger( this ) ); i = includeClasses.iterator(); while ( i.hasNext() ) { Ignore tmp = (Ignore) i.next(); builder.addInclude( tmp.getClassName() ); } i = excludeClasses.iterator(); while ( i.hasNext() ) { Ignore tmp = (Ignore) i.next(); builder.addExclude( tmp.getClassName() ); } i = paths.iterator(); while ( i.hasNext() ) { Path path = (Path) i.next(); final String[] files = path.list(); for ( int j = 0; j < files.length; j++ ) { log( "Capturing signatures from " + files[j], Project.MSG_INFO ); process( builder, new File( files[j] ) ); } } builder.close(); } catch ( IOException e ) { throw new BuildException( e ); } } private void process( SignatureBuilder builder, File f ) throws IOException { if ( f.exists() ) { builder.process( f ); } } } CheckSignatureTask.java000066400000000000000000000142171163373477200371230ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/java/org/codehaus/mojo/animal_sniffer/antpackage org.codehaus.mojo.animal_sniffer.ant; /* * The MIT License * * Copyright (c) 2009, codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.types.resources.FileResource; import org.codehaus.mojo.animal_sniffer.ClassFileVisitor; import org.codehaus.mojo.animal_sniffer.ClassListBuilder; import org.codehaus.mojo.animal_sniffer.SignatureChecker; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Iterator; import java.util.Set; import java.util.Vector; /** * Checks the files against the provided signature. * * @author connollys * @since 1.3 */ public class CheckSignatureTask extends Task { private File signature; private Path classpath; private Vector paths = new Vector(); private Vector ignores = new Vector(); public void addPath( Path path ) { paths.add( path ); } public Ignore createIgnore( ) { final Ignore result = new Ignore(); ignores.add( result ); return result; } public void setSignature( File signature ) { this.signature = signature; } public Path createClasspath() { log( "In createClasspath", Project.MSG_INFO ); if ( this.classpath == null ) { this.classpath = new Path( getProject() ); } return this.classpath.createPath(); } public void setClasspath( Path classpath ) { log( "In setClasspath", Project.MSG_INFO ); if ( this.classpath == null ) { this.classpath = classpath; } else { this.classpath.append( classpath ); } } public void setClasspathRef( Reference r ) { log( "In setClasspathRef", Project.MSG_INFO ); createClasspath().setRefid( r ); } public void execute() throws BuildException { validate(); try { log( "Checking unresolved references to " + signature, Project.MSG_INFO ); if ( !signature.isFile() ) { throw new BuildException( "Could not find signature: " + signature ); } final Set ignoredPackages = buildPackageList(); Iterator i = ignores.iterator(); while ( i.hasNext() ) { Ignore ignore = (Ignore) i.next(); if (ignore == null|| ignore.getClassName()== null) continue; ignoredPackages.add( ignore.getClassName().replace( '.', '/' ) ); } final SignatureChecker signatureChecker = new SignatureChecker( new FileInputStream( signature ), ignoredPackages, new AntLogger( this ) ); i = paths.iterator(); while ( i.hasNext() ) { Path path = (Path) i.next(); final String[] files = path.list(); for ( int j = 0; j < files.length; j++ ) { signatureChecker.process( new File( files[j] ) ); } } if ( signatureChecker.isSignatureBroken() ) { throw new BuildException( "Signature errors found. Verify them and put @IgnoreJRERequirement on them.", getLocation() ); } } catch ( IOException e ) { throw new BuildException( "Failed to check signatures", e ); } } protected void validate() { if ( signature == null ) { throw new BuildException( "signature not set" ); } if ( paths.size() < 1 ) { throw new BuildException( "path not set" ); } } /** * List of packages defined in the application. */ private Set buildPackageList() throws IOException { ClassListBuilder plb = new ClassListBuilder( new AntLogger( this ) ); apply( plb ); return plb.getPackages(); } private void apply( ClassFileVisitor v ) throws IOException { Iterator i = paths.iterator(); while ( i.hasNext() ) { Path path = (Path) i.next(); final String[] files = path.list(); for ( int j = 0; j < files.length; j++ ) { log( "Ignoring the signatures from file to be checked: " + files[j], Project.MSG_INFO ); v.process( new File( files[j] ) ); } } if ( classpath != null ) { i = classpath.iterator(); while ( i.hasNext() ) { Object next = i.next(); if ( next instanceof FileResource ) { final File file = ( (FileResource) next ).getFile(); log( "Ignoring the signatures from classpath: " + file, Project.MSG_INFO ); v.process( file ); } } } } }Ignore.java000066400000000000000000000040561163373477200346240ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/java/org/codehaus/mojo/animal_sniffer/antpackage org.codehaus.mojo.animal_sniffer.ant; /* * The MIT License * * Copyright (c) 2009, codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ /** * Created by IntelliJ IDEA. * * @author Stephen Connolly * @since 07-Sep-2009 16:55:55 */ public class Ignore { private String className; public String getClassName() { return className; } public void setClassName( String className ) { this.className = className; } public boolean equals( Object o ) { if ( this == o ) { return true; } if ( !( o instanceof Ignore ) ) { return false; } Ignore ignore = (Ignore) o; if ( className != null ? !className.equals( ignore.className ) : ignore.className != null ) { return false; } return true; } public int hashCode() { return 0; } public String toString() { return "Ignore{" + "className='" + className + '\'' + '}'; } } Signature.java000066400000000000000000000032741163373477200353430ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/java/org/codehaus/mojo/animal_sniffer/antpackage org.codehaus.mojo.animal_sniffer.ant; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.io.File; /** * Created by IntelliJ IDEA. * * @author Stephen Connolly * @since 07-Sep-2009 19:58:20 */ public class Signature { private File src; public File getSrc() { return src; } public void setSrc( File src ) { this.src = src; } public boolean equals( Object o ) { if ( this == o ) { return true; } if ( !( o instanceof Signature ) ) { return false; } Signature signature = (Signature) o; if ( src != null ? !src.equals( signature.src ) : signature.src != null ) { return false; } return true; } public int hashCode() { return src != null ? src.hashCode() : 0; } public String toString() { return "Signature{" + "src=" + src + '}'; } } animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/resources/000077500000000000000000000000001163373477200246145ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/resources/org/000077500000000000000000000000001163373477200254035ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/resources/org/codehaus/000077500000000000000000000000001163373477200271765ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/resources/org/codehaus/mojo/000077500000000000000000000000001163373477200301425ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/resources/org/codehaus/mojo/animal_sniffer/000077500000000000000000000000001163373477200331175ustar00rootroot00000000000000antlib.xml000066400000000000000000000025501163373477200350350ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/main/resources/org/codehaus/mojo/animal_sniffer animal-sniffer-1.7/animal-sniffer-ant-tasks/src/site/000077500000000000000000000000001163373477200226225ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/site/apt/000077500000000000000000000000001163373477200234065ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/site/apt/examples/000077500000000000000000000000001163373477200252245ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-ant-tasks/src/site/apt/examples/checking-signatures.apt.vm000066400000000000000000000146321163373477200323160ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Checking signatures ----- Stephen Connolly ------ 2009-11-05 ------ Checking signatures * Basic example In order to check your classes against an API signature, you use the <<>> task: --- ... ... --- The path provided will be recursively searched for jar files and class files, all of which will be checked against the supplied signature. When you run the <<>> task as in the above example, the task will fail if your classes reference any class, method or field that is not either: * in the signatures; or * on the path you provided [] If you have compiled your classes against a classpath that you have already verified against the signature of your target platform, you can speed up the checking process by giving the <<>> task the classpathRef of your compile classpath. For example, if you are checking a web application against signatures for the Java EE Servlet specification, you might reference the classpath of the WEB-INF/lib folder when checking your WEB-INF/classes path. The following example illustrates how to achieve this: --- ... ... ... ... --- * Ignoring classes not in the signature In certain situations you may want to reference classes which are missing from the signature you are checking. This is usually the case where you are compiling with a newer JDK than the JDK you are targetting <> you are writing some code which safely makes use of the features in the newer JDK when running on the newer JDK. For example, if you have code like: --- public final class MapFactory { private MapFactory() { new IllegalAccessError("This is a utility class"); } public static Map newHashMap() { try { // we'd prefer the concurrent version return new ConcurrentHashMap(); } catch (LinkageError e) { // oh dear, looks like we're running on something // earlier than JDK 1.5. This will be slower // but still safe for concurrent access return Collections.synchronizedMap(new HashMap()); } } } --- The above code will require JDK 1.5 or newer to compile, and can run on earlier JDKs (although with degraded performance, and we are assuming you have set the -source and -target options correctly for the earlier JDKs). When you run animal-sniffer against the above class using the JDK 1.4 signatures, you will get a build failure because <<>> is not in the JDK 1.4 signature. If you are sure that where you have used <<>> you have correctly encapsulated it within <<>> blocks or their equivalent, you can tell animal-sniffer to ignore the class, e.g. --- ... ... ... ... ... ... --- We can specify multiple classes, and we can also use wildcards to match multiple classes, for example, to ignore <<>>, <<>> and <<>> you would use a configuration like: --- ... ... ... ... ... ... --- * When your minimum target JRE is 1.5 or newer If you are targetting JRE 1.5 or newer (i.e. the lowest version of Java that your project will support is a version that supports annotations) it is preferable to annotate your <<>> safe methods rather than using the <<>> configuration element. To annotate your methods, you need to add <<>> to your compile classpath. Then whenever you safely reference a newer class, you just annotate the method with <<<@IgnoreJRERequirement>>> for example: --- public final class Someclass { ... @IgnoreJRERequirement public void doSomething() { try { // try it the JDK 6 way } catch (LinkageError e) { // fall back to the JDK 5 way } } ... } --- Note: if you have compiled with the <<>> you do not have to change anything as animal-sniffer automatically detects this annotation as well (even although it is in a different package. animal-sniffer-1.7/animal-sniffer-ant-tasks/src/site/apt/examples/generating-signatures.apt.vm000066400000000000000000000115661163373477200326710ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Generating signatures ----- Stephen Connolly ------ 2009-11-05 ------ Generating signatures * Basic To generate signatures of any API, you simple construct a invoke the <<>> task and provide the path(s) of all the classes / jar files which form the API. For example: --- ... ... ... ... --- * Generating "pure" signatures The above examples generate signatures of the every class in the provided path. There are some situations where you may not want to include all the classes on the provided path, for example when generating the signature of the JRE, as that includes all the implementation classes which are not part of the public contract of the JRE. For example sun.misc.BASE64Encoder is part of Sun's JRE runtime libraries, but is not part of the JRE specification and if you run on a JRE produced by a different vendor, it is highly likely that that class will not be available to your program. In order to ensure that the Java signatures you generate only include those classes which you want, you may need to tune your signatures. ** Inclusion based tuning One technique is to only include those classes which you know are part of the JRE public specification. For example: --- ... ... ... ... ... ... --- This requires that you known exactly what classes to include. ** Exclusion based tuning The other technique is to specify which classes are not to be included (Note that a combination of the two can also be used.) For example: --- ... ... ... ... ... ... --- * Extending signatures In some cases you may want to generate a signature which extends another signature, this is achieved by adding the required signatures to the <<>> task. For example: --- ... ... ... ... ... ... --- Note: The resulting signature will be the union of: * any the provided signatures * any classes or jar files you provide via <<>> elements [] In addition, prior to writing the final signatures out: * (if any <<>> are specified) only classes which match at least one <<>> rule will be written to the signature. * (if any <<>> are specified) any classes which match at least one <<>> rule will be excluded from the signature. * if both <<>> and <<>> rules are specified, the <<>> rules over-rule the <<>> rules. [] animal-sniffer-1.7/animal-sniffer-ant-tasks/src/site/apt/examples/sample-project.apt.vm000066400000000000000000000116661163373477200313120ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Sample project ----- Stephen Connolly ------ 2009-11-06 ------ Sample project * Sample project The following sample project is based on the integration tests for this antlib (but with the hacks to make it work when invoked from Maven removed) --- --- animal-sniffer-1.7/animal-sniffer-ant-tasks/src/site/apt/index.apt000066400000000000000000000066211163373477200252300ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ------ Introduction ------ Stephen Connolly ------ 2009-11-05 ------ Animal Sniffer ANT Tasks The Animal Sniffer ANT Tasks can be used to build signatures of APIs and to check your classes against previously generated signatures. * Tasks Overview The Animal Sniffer ANT Tasks inlcude the following tasks. * <<>> creates a signature of an API. * <<>> checks a classes against an API signature. * Usage General instructions on how to use the Animal Sniffer ANT Tasks can be found on the {{{usage.html}usage page}}. Some more specific use cases are described in the examples given below. Last but not least, users occasionally contribute additional examples, tips or errata to the {{{http://docs.codehaus.org/display/MAVENUSER/Animal+Sniffer+ANT+Tasks}ANT Tasks's wiki page}}. In case you still have questions regarding the ANT Tasks's usage, please feel free to contact the {{{mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the {{{mail-lists.html}mail archive}}. If you feel like the ANT Tasks are missing a feature or have a defect, you can fill a feature request or bug report in our {{{issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, <<>>s or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our {{{source-repository.html}source repository}} and will find supplementary information in the {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. * Examples To provide you with better understanding of some usages of Animal Sniffer ANT Tasks, you can take a look into the following examples: * {{{examples/generating-signatures.html}Generating signatures}} * {{{examples/checking-signatures.html}Checking signatures}} * {{{examples/sample-project.html}A sample project}} [] animal-sniffer-1.7/animal-sniffer-ant-tasks/src/site/apt/usage.apt.vm000066400000000000000000000112271163373477200256440ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Usage ----- Stephen Connolly ------ 2009-11-05 ------ Usage The ANT Tasks include tasks for checking classes against the signatures of an API as well as goals for generating signatures of APIs. * Basic Usage ** Defining the ANT Tasks Before you can use the Animal Sniffer ANT Tasks you need to inform ANT about these tasks. There are several techniques for defining custom tasks in ANT. Our preferred technique (and the technique that we will assume you use) is to use a namespace and the <<>> from within the Animal Sniffer ANT Tasks jar file, for example: --- ... ... --- Note: if you want to use any of the other techniques for importing ANT tasks, we (Maven developers) assume that you (ANT developer) know how to convert our examples into the technique you are using. This namespace based techique is the way the authors of this document know. ** Checking a classes against an API signature In order to check your classes against an API signature, you use the <<>> task: --- ... ... ... ... --- The path provided will be recursively searched for jar files and class files, all of which will be checked against the supplied signature. When you run the <<>> task as in the above example, the task will fail if your classes reference any class, method or field that is not either: * in the signatures; or * on the path you provided [] If you have compiled your classes against a classpath that you have already verified against the signature of your target platform, you can speed up the checking process by giving the <<>> task the classpathRef of your compile classpath. For example, if you are checking a web application against signatures for the Java EE Servlet specification, you might reference the classpath of the WEB-INF/lib folder when checking your WEB-INF/classes path. The following example illustrates how to achieve this: --- ... ... ... ... --- For more detailed examples of how to configure this task see: * {{{examples/checking-signatures.html} Checking signatures}}. [] ** Generating API signatures To generate the signatures of an API, simply invoke the <<>> tasks providing the path of the API you want to generate the signatures for, e.g. --- ... ... ... ... --- For more detailed examples of how to configure this goal see: * {{{examples/generating-signatures.html}Generating signatures}} [] animal-sniffer-1.7/animal-sniffer-ant-tasks/src/site/site.xml000066400000000000000000000032031163373477200243060ustar00rootroot00000000000000 animal-sniffer-1.7/animal-sniffer-enforcer-rule/000077500000000000000000000000001163373477200217325ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/pom.xml000066400000000000000000000114451163373477200232540ustar00rootroot00000000000000 4.0.0 org.codehaus.mojo animal-sniffer-parent 1.7 org.codehaus.mojo animal-sniffer-enforcer-rule jar Animal Sniffer Maven Enforcer Rule Animal Sniffer Maven Enforcer Rule. 1.0 2.0.9 1.4 org.codehaus.mojo animal-sniffer 1.7 org.apache.maven.enforcer enforcer-api ${enforcer-api.version} org.apache.maven maven-project ${maven.version} org.apache.maven maven-core ${maven.version} org.apache.maven maven-artifact ${maven.version} org.apache.maven maven-plugin-api ${maven.version} org.codehaus.plexus plexus-container-default 1.0-alpha-9 junit junit 3.8.1 test maven-invoker-plugin setup-*/pom.xml */pom.xml ${build-helper.version} org.codehaus.mojo build-helper-maven-plugin ${build-helper.version} run-its verify maven-invoker-plugin integration-test install run false true animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/000077500000000000000000000000001163373477200225215ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/000077500000000000000000000000001163373477200231355ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/settings.xml000066400000000000000000000045451163373477200255270ustar00rootroot00000000000000 it-repo true central file:///@localRepository@ true ignore never true ignore never central file:///@localRepository@ true ignore never true ignore never animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-001/000077500000000000000000000000001163373477200245735ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-001/invoker.properties000066400000000000000000000021621163373477200303670ustar00rootroot00000000000000# # The MIT License # # Copyright (c) 2009 codehaus.org. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # invoker.goals=install animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-001/pom.xml000066400000000000000000000071341163373477200261150ustar00rootroot00000000000000 4.0.0 localdomain.localhost api 1-SNAPSHOT pom Dummy API Signature maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 org.codehaus.mojo build-helper-maven-plugin @build-helper.version@ attach-artifacts package attach-artifact src/main/signatures/api-1-SNAPSHOT.signature signature UTF-8 UTF-8 UTF-8 animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-001/src/000077500000000000000000000000001163373477200253625ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-001/src/main/000077500000000000000000000000001163373477200263065ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-001/src/main/signatures/000077500000000000000000000000001163373477200304725ustar00rootroot00000000000000api-1-SNAPSHOT.signature000066400000000000000000000004251163373477200345030ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-001/src/main/signatures‹eO½J1ž;ÏF„;µ²°m; ,¶¹BÆ\v7k6‰IV—ìîô)´V| _B,|“]Å©†oæû{ú‚EgaSÛœ0=åÖŽTºÔ•¨P^8%²Œ[r$q6ƒnz}$0PXq«I‰7H%ªœŽ½*ßK`ɉ\¡¯-w†ÝGí…¤cîÛsm¸ ’Î]Ã=ô&0l‘3å¹ÍEÖÚä¿pc<¬KÍPNu…BÑv/´óôЈÐc%RHt"§èŠàöv<x|}Ù]hÌírH?Ú?èZx±‚³«”['´ÚÙÚN›€ý¹ž_–œ…¿YHDÉO–ç÷ôãsã£žù¾K›Lanimal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-002/000077500000000000000000000000001163373477200245745ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-002/invoker.properties000066400000000000000000000021621163373477200303700ustar00rootroot00000000000000# # The MIT License # # Copyright (c) 2009 codehaus.org. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # invoker.goals=install animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-002/pom.xml000066400000000000000000000071201163373477200261110ustar00rootroot00000000000000 4.0.0 localdomain.localhost api 2-SNAPSHOT jar Dummy API maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 org.codehaus.mojo build-helper-maven-plugin @build-helper.version@ attach-artifacts package attach-artifact src/main/signatures/api-2-SNAPSHOT.signature signature UTF-8 UTF-8 UTF-8 animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-002/src/000077500000000000000000000000001163373477200253635ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-002/src/main/000077500000000000000000000000001163373477200263075ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-002/src/main/java/000077500000000000000000000000001163373477200272305ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-002/src/main/java/localdomain/000077500000000000000000000000001163373477200315125ustar00rootroot00000000000000000077500000000000000000000000001163373477200334235ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-002/src/main/java/localdomain/localhostApi.java000066400000000000000000000023511163373477200350000ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-002/src/main/java/localdomain/localhostpackage localdomain.localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public interface Api { void checkVersion1(); void checkVersion2(); }animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-002/src/main/signatures/000077500000000000000000000000001163373477200304735ustar00rootroot00000000000000api-2-SNAPSHOT.signature000066400000000000000000000004351163373477200345060ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/setup-002/src/main/signatures‹e½J1…ïŽk#®ZYØ.Ú$(v* * l±0ÍrÍff2f’1Éè° v>‚>…ÖŠáKˆ…ï`2«z«ËwÎ9Ÿ°h ´ÉÓžcmI© MP‰å¹U"M¹!G§S˜W'‚n ]…%w°xT¢ÊèÈ¡²½–¬ÈºÚpë 7ߨtÄ];®+nüKk¯à:cèµäL9nRdájmüÿqS9X—š¡œè…¢mŸkëèa%|Ž•pB‚9E›{µ×ã»û‡—çÝ€¦ºYöîûûmŠÈAŸåœ]&ÜX¡ÕöæVòíxÔxökdxQpæsýØ#’o{OoÉûÇÆì$ ZA¢úÍçÂ>_animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/smoke-test/000077500000000000000000000000001163373477200252305ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/smoke-test/invoker.properties000066400000000000000000000023521163373477200310250ustar00rootroot00000000000000# # The MIT License # # Copyright (c) 2009 codehaus.org. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # invoker.goals.1=verify invoker.profiles.1=positive-test invoker.goals.2=verify invoker.profiles.2=negative-test invoker.buildResult.2=failureanimal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/smoke-test/pom.xml000066400000000000000000000137171163373477200265560ustar00rootroot00000000000000 4.0.0 localhost.localdomain smoke-test 1.0-SNAPSHOT jar Smoke Test Tests that the enforcer rule works. localdomain.localhost api 2-SNAPSHOT maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 maven-enforcer-plugin 1.0 @project.groupId@ @project.artifactId@ @project.version@ positive-test maven-enforcer-plugin check-jdk test enforce localdomain.localhost api 2-SNAPSHOT java.* javax.* false negative-test maven-enforcer-plugin check-jdk test enforce localdomain.localhost api 1-SNAPSHOT java.* javax.* false UTF-8 UTF-8 UTF-8 animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/smoke-test/src/000077500000000000000000000000001163373477200260175ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/smoke-test/src/main/000077500000000000000000000000001163373477200267435ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/smoke-test/src/main/java/000077500000000000000000000000001163373477200276645ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/it/smoke-test/src/main/java/JDK15.java000066400000000000000000000023741163373477200313130ustar00rootroot00000000000000/* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import localdomain.localhost.Api; public class JDK15 { public void doChecks(Api api) { api.checkVersion2(); } }animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/main/000077500000000000000000000000001163373477200234455ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/main/java/000077500000000000000000000000001163373477200243665ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/main/java/org/000077500000000000000000000000001163373477200251555ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/main/java/org/codehaus/000077500000000000000000000000001163373477200267505ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/main/java/org/codehaus/mojo/000077500000000000000000000000001163373477200277145ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/main/java/org/codehaus/mojo/animal_sniffer/000077500000000000000000000000001163373477200326715ustar00rootroot00000000000000000077500000000000000000000000001163373477200344155ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/main/java/org/codehaus/mojo/animal_sniffer/enforcerCheckSignatureRule.java000066400000000000000000000155001163373477200410100ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/main/java/org/codehaus/mojo/animal_sniffer/enforcerpackage org.codehaus.mojo.animal_sniffer.enforcer; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.enforcer.rule.api.EnforcerRule; import org.apache.maven.enforcer.rule.api.EnforcerRuleException; import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; import org.apache.maven.project.MavenProject; import org.codehaus.mojo.animal_sniffer.ClassFileVisitor; import org.codehaus.mojo.animal_sniffer.ClassListBuilder; import org.codehaus.mojo.animal_sniffer.SignatureChecker; import org.codehaus.mojo.animal_sniffer.logging.Logger; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Random; import java.util.Set; /** * Created by IntelliJ IDEA. * * @author connollys * @since Sep 4, 2009 2:44:29 PM */ public class CheckSignatureRule implements EnforcerRule { /** * Signature module to use. * * @required * @parameter */ protected Signature signature; /** * Class names to ignore signatures for (wildcards accepted). * * @parameter */ protected String[] ignores; /** * Should dependencies be ignored. * * @parameter default-value="true" */ protected boolean ignoreDependencies = true; public void execute( EnforcerRuleHelper helper ) throws EnforcerRuleException { try { List classpathElements = (List) helper.evaluate( "${project.compileClasspathElements}" ); File outputDirectory = new File( (String) helper.evaluate( "${project.build.outputDirectory}" ) ); ArtifactResolver resolver = (ArtifactResolver) helper.getComponent( ArtifactResolver.class ); MavenProject project = (MavenProject) helper.evaluate( "${project}" ); ArtifactRepository localRepository = (ArtifactRepository) helper.evaluate( "${localRepository}" ); ArtifactFactory artifactFactory = (ArtifactFactory) helper.getComponent( ArtifactFactory.class ); helper.getLog().info( "Checking unresolved references to " + signature ); org.apache.maven.artifact.Artifact a = signature.createArtifact( artifactFactory ); resolver.resolve( a, project.getRemoteArtifactRepositories(), localRepository ); // just check code from this module MavenLogger logger = new MavenLogger( helper.getLog() ); final Set ignoredPackages = buildPackageList( outputDirectory, classpathElements, logger ); if ( ignores != null ) { for ( int i = 0; i < ignores.length; i++ ) { String ignore = ignores[i]; if ( ignore == null ) { continue; } ignoredPackages.add( ignore.replace( '.', '/' ) ); } } final SignatureChecker signatureChecker = new SignatureChecker( new FileInputStream( a.getFile() ), ignoredPackages, logger ); signatureChecker.setCheckJars( false ); // don't want to decend into jar files that have been copied to // the output directory as resources. signatureChecker.process( outputDirectory ); if ( signatureChecker.isSignatureBroken() ) { throw new EnforcerRuleException( "Signature errors found. Verify them and put @IgnoreJRERequirement on them." ); } } catch ( IOException e ) { throw new EnforcerRuleException( "Failed to check signatures", e ); } catch ( AbstractArtifactResolutionException e ) { throw new EnforcerRuleException( "Failed to obtain signature: " + signature, e ); } catch ( ComponentLookupException e ) { throw new EnforcerRuleException( "Unable to lookup a component " + e.getLocalizedMessage(), e ); } catch ( ExpressionEvaluationException e ) { throw new EnforcerRuleException( "Unable to lookup an expression " + e.getLocalizedMessage(), e ); } } /** * List of packages defined in the application. * * @param outputDirectory * @param logger */ private Set buildPackageList( File outputDirectory, List classpathElements, Logger logger ) throws IOException { ClassListBuilder plb = new ClassListBuilder( logger ); apply( plb, outputDirectory, classpathElements ); return plb.getPackages(); } private void apply( ClassFileVisitor v, File outputDirectory, List classpathElements ) throws IOException { v.process( outputDirectory ); if ( ignoreDependencies ) { Iterator itr = classpathElements.iterator(); while ( itr.hasNext() ) { String path = (String) itr.next(); v.process( new File( path ) ); } } } public boolean isCacheable() { return false; } public boolean isResultValid( EnforcerRule enforcerRule ) { return false; } public String getCacheId() { return getClass().getName() + new Random().nextLong(); } } MavenLogger.java000066400000000000000000000044661163373477200375000ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/main/java/org/codehaus/mojo/animal_sniffer/enforcerpackage org.codehaus.mojo.animal_sniffer.enforcer; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.apache.maven.plugin.logging.Log; import org.codehaus.mojo.animal_sniffer.logging.Logger; /** * An animal sniffer logger that delegates to a maven log. * * @author connollys * @since 1.3 */ public final class MavenLogger implements Logger { private final Log delegate; public MavenLogger( Log delegate ) { this.delegate = delegate; } public void info( String message ) { delegate.info( message ); } public void info( String message, Throwable t ) { delegate.info( message, t ); } public void debug( String message ) { delegate.debug( message ); } public void debug( String message, Throwable t ) { delegate.debug( message, t ); } public void warn( String message ) { delegate.warn( message ); } public void warn( String message, Throwable t ) { delegate.warn( message, t ); } public void error( String message ) { delegate.error( message ); } public void error( String message, Throwable t ) { delegate.error( message, t ); } }Signature.java000066400000000000000000000044141163373477200372240ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/main/java/org/codehaus/mojo/animal_sniffer/enforcerpackage org.codehaus.mojo.animal_sniffer.enforcer; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.apache.maven.artifact.factory.ArtifactFactory; /** * Represents artifact in Maven POM. * Maven binds this automatically to XML. * * @author Kohsuke Kawaguchi */ public class Signature { private String groupId; private String artifactId; private String version; public String getGroupId() { return groupId; } public void setGroupId( String groupId ) { this.groupId = groupId; } public String getArtifactId() { return artifactId; } public void setArtifactId( String artifactId ) { this.artifactId = artifactId; } public String getVersion() { return version; } public void setVersion( String version ) { this.version = version; } public org.apache.maven.artifact.Artifact createArtifact( ArtifactFactory factory ) { return factory.createArtifact( groupId, artifactId, version, null, "signature"/*don't really care*/ ); } public String toString() { return groupId + ":" + artifactId + ":" + version; } }animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/site/000077500000000000000000000000001163373477200234655ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/site/apt/000077500000000000000000000000001163373477200242515ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/site/apt/examples/000077500000000000000000000000001163373477200260675ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/site/apt/examples/checking-signatures.apt.vm000066400000000000000000000273351163373477200331650ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Checking a project against API signatures ----- Stephen Connolly ------ 2009-11-04 ------ Checking a project against API signatures * Basic example In order to check your project against an API signature, you must add the enforcer rule as a dependency to the maven-enforcer-plugin and then configure your the maven-enforcer-plugin to run the rule: --- ... ... ... maven-enforcer-plugin 1.0-beta-1 ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... .... check-signatures test enforce ... ___group id of signature___ ___artifact id of signature___ ___version of signature___ ... ... ... ... ... ... --- Once you have configured your project with details of the signature to check, maven-enforcer will be able to throw a build error if your any of your classes reference a class, a method, or a field which is not in either the signature or your project's dependencies. * Ignoring classes not in the signature In certain situations you may want to reference classes which are missing from the signature you are checking. This is usually the case where you are compiling with a newer JDK than the JDK you are targetting <> you are writing some code which safely makes use of the features in the newer JDK when running on the newer JDK. For example, if you have code like: --- public final class MapFactory { private MapFactory() { new IllegalAccessError("This is a utility class"); } public static Map newHashMap() { try { // we'd prefer the concurrent version return new ConcurrentHashMap(); } catch (LinkageError e) { // oh dear, looks like we're running on something // earlier than JDK 1.5. This will be slower // but still safe for concurrent access return Collections.synchronizedMap(new HashMap()); } } } --- The above code will require JDK 1.5 or newer to compile, and can run on earlier JDKs (although with degraded performance, and we are assuming you have set the -source and -target options correctly for the earlier JDKs). When you run animal-sniffer against the above class using the JDK 1.4 signatures, you will get a build failure because <<>> is not in the JDK 1.4 signature. If you are sure that where you have used <<>> you have correctly encapsulated it within <<>> blocks or their equivalent, you can tell animal-sniffer to ignore the class, e.g. --- ... ... ... maven-enforcer-plugin 1.0-beta-1 ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... .... check-signatures test enforce ... ... java.util.concurrent.ConcurrentHashMap ... ... ... ... ... ... ... --- We can specify multiple classes, and we can also use wildcards to match multiple classes, for example, to ignore <<>>, <<>> and <<>> you would use a configuration like: --- ... ... ... maven-enforcer-plugin 1.0-beta-1 ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... .... check-signatures test enforce ... java.util.concurrent.ConcurrentHashMap java.util.concurrent.ConcurrentMap javax.servlet.* ... ... ... ... ... ... --- * When your minimum target JRE is 1.5 or newer If you are targetting JRE 1.5 or newer (i.e. the lowest version of Java that your project will support is a version that supports annotations) it is preferable to annotate your <<>> safe methods rather than using the <<>> configuration element. To annotate your methods, you need to add either an optional and/or provided dependency on <<>>, (technically optional is the correct way, but to work around some incorrectly written maven plugins, you may end up using scope provided) e.g. --- ... ... ${project.parent.groupId} animal-sniffer-annotations ${project.parent.version} true ... ... ... ... maven-compiler-plugin ... ... 1.5 1.5 ... ... ... ... --- Then whenever you safely reference a newer class, you just annotate the method with <<<@IgnoreJRERequirement>>> for example: --- public final class Someclass { ... @IgnoreJRERequirement public void doSomething() { try { // try it the JDK 6 way } catch (LinkageError e) { // fall back to the JDK 5 way } } ... } --- Note: if you have compiled with the <<>> you do not have to change anything as animal-sniffer automatically detects this annotation as well (even although it is in a different package. * Referencing classes from dependencies By default, animal-sniffer will automatically ignore any classes and methods defined in your dependencies. This is usually what you want. In certain rare situations, you may want to ignore your project dependencies by setting the <<>> parameter to <<>>. For example, you might be compiling your project against the JavaEE 5 specification but want to check compatibility against the J2EE 1.4 specification. You will have a signature corresponding to the exposed J2EE 1.4 api's. If you check against this signature, because all of the JavaEE 1.5 API dependencies are ignored your project will never fail even if it uses JavaEE 1.5 only methods. In this situation, you would want to turn off the default behaviour, e.g. --- ... ... ... maven-enforcer-plugin 1.0-beta-1 ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... .... check-signatures test enforce ... false ... ... ... ... ... ... --- animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/site/apt/index.apt.vm000066400000000000000000000070611163373477200265130ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Animal Sniffer Enforcer Rule ----- Stephen Connolly ----- 2009-11-04 ----- Animal Sniffer Enforcer Rule The Animal Sniffer Enforcer Rule is used to check your classes against previously generated signatures. This enforcer rule is called animal sniffer because the principal signatures that are used are those of the Java Runtime, and since Sun traditionally names the different versions of its Java Runtimes after different animals, the original project from which this enforcer rule was developed was called "Animal Sniffer". * Rules Overview The Animal Sniffer Enforcer Rule has the following rule. * <<>> checks a project against an API signature. * Usage General instructions on how to use the Animal Sniffer Enforcer Rule can be found on the {{{usage.html}usage page}}. Some more specific use cases are described in the examples given below. Last but not least, users occasionally contribute additional examples, tips or errata to the {{{http://docs.codehaus.org/display/MAVENUSER/Animal+Sniffer+Enforcer+Rule}enforcer rule's wiki page}}. In case you still have questions regarding the enforcer rule's usage, feel free to contact the {{{mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the {{{mail-lists.html}mail archive}}. If you feel like the enforcer rule is missing a feature or has a defect, you can fill a feature request or bug report in our {{{issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our {{{source-repository.html}source repository}} and will find supplementary information in the {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. * Examples To provide you with better understanding of some usages of Animal Sniffer Enforcer Rule, you can take a look into the following examples: * {{{examples/checking-signatures.html}Checking a project against API signatures}} [] animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/site/apt/usage.apt.vm000066400000000000000000000075601163373477200265140ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Usage ----- Stephen Connolly ------ 2009-11-04 ------ Usage The enforcer rule offers a rule for checking projects against the signatures of an API. * Basic Usage ** Checking a project against an API signature In order to check your project against an API signature, you must add the enforcer rule as a dependency to the maven-enforcer-plugin and then configure the maven-enforcer-plugin to run the rule: --- ... ... ... maven-enforcer-plugin 1.0-beta-1 ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... .... check-signatures test enforce ... org.codehaus.mojo.signature java15 1.0 ... ... ... ... ... ... --- The example above configures the signature for JRE 1.5. For a list of other ready-made signatures, please visit the {{{http://mojo.codehaus.org/signatures/}Animal Scents subproject}}. Once you have configured your project with details of the signature to check, maven-enforcer will be able to throw a build error if your any of your classes reference a class, a method, or a field which is not in either the signature or your project's dependencies. if you want to check against multiple separate APIs (e.g. check against the Tomcat, JBoss, and Jetty servlet containers, or check against multiple java versions) then you will probably want to keep the signature configuration inside each of your multiple executions otherwise your project will be checked against the union of all the signatures specified, which is probably not what you wanted. {{{examples/checking-signatures.html} Some more detailed examples of the <<>> rule}}. animal-sniffer-1.7/animal-sniffer-enforcer-rule/src/site/site.xml000066400000000000000000000027731163373477200251640ustar00rootroot00000000000000 animal-sniffer-1.7/animal-sniffer-maven-plugin/000077500000000000000000000000001163373477200215645ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/pom.xml000066400000000000000000000112571163373477200231070ustar00rootroot00000000000000 4.0.0 org.codehaus.mojo animal-sniffer-parent 1.7 org.codehaus.mojo animal-sniffer-maven-plugin maven-plugin Animal Sniffer Maven Plugin Animal Sniffer Maven Plugin. http://mojo.codehaus.org/animal-sniffer-parent/animal-sniffer-maven-plugin codehaus.org Mojo Website dav:https://dav.codehaus.org/mojo/animal-sniffer-maven-plugin org.codehaus.mojo animal-sniffer 1.7 org.codehaus.mojo java-boot-classpath-detector 1.7 org.apache.maven maven-plugin-api 2.0.1 org.apache.maven maven-core 2.0.1 org.apache.maven maven-project 2.0.1 org.apache.maven maven-artifact 2.0.1 org.apache.maven maven-toolchain 2.2.1 org.apache.maven.shared maven-common-artifact-filters 1.2 org.codehaus.plexus plexus-utils 1.5.6 maven-invoker-plugin */pom.xml ${env.JAVA_HOME} run-its verify maven-invoker-plugin integration-test install run false true animal-sniffer-1.7/animal-sniffer-maven-plugin/src/000077500000000000000000000000001163373477200223535ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/000077500000000000000000000000001163373477200227675ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk14-with-sig14/000077500000000000000000000000001163373477200256025ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk14-with-sig14/invoker.properties000066400000000000000000000000251163373477200313720ustar00rootroot00000000000000invoker.goals=verify animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk14-with-sig14/pom.xml000066400000000000000000000076701163373477200271310ustar00rootroot00000000000000 4.0.0 localdomain.localhost real-test 1.0-SNAPSHOT jar Real Test Tests that real signatures work. maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 maven-compiler-plugin 1.5 1.5 ${pluginGroupId} ${pluginArtifactId} ${pluginVersion} verify check org.codehaus.mojo.signature java14 1.0 UTF-8 UTF-8 UTF-8 @project.groupId@ @project.artifactId@ @project.version@ animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk14-with-sig14/src/000077500000000000000000000000001163373477200263715ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk14-with-sig14/src/main/000077500000000000000000000000001163373477200273155ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk14-with-sig14/src/main/java/000077500000000000000000000000001163373477200302365ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk14-with-sig14/src/main/java/localhost/000077500000000000000000000000001163373477200322265ustar00rootroot00000000000000Main.java000066400000000000000000000025011163373477200336740ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk14-with-sig14/src/main/java/localhostpackage localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public class Main { public static void main( String[] args ) { if ( "".length() == 0 ) { System.out.println( "All is good" ); } } } animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig14/000077500000000000000000000000001163373477200256035ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig14/invoker.properties000066400000000000000000000000351163373477200313740ustar00rootroot00000000000000invoker.buildResult=failure animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig14/pom.xml000066400000000000000000000076661163373477200271370ustar00rootroot00000000000000 4.0.0 localdomain.localhost real-test 1.0-SNAPSHOT jar Real Test Tests that real signatures work. maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 maven-compiler-plugin 1.5 1.5 ${pluginGroupId} ${pluginArtifactId} ${pluginVersion} test check org.codehaus.mojo.signature java14 1.0 UTF-8 UTF-8 UTF-8 @project.groupId@ @project.artifactId@ @project.version@ animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig14/src/000077500000000000000000000000001163373477200263725ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig14/src/main/000077500000000000000000000000001163373477200273165ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig14/src/main/java/000077500000000000000000000000001163373477200302375ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig14/src/main/java/localhost/000077500000000000000000000000001163373477200322275ustar00rootroot00000000000000Main.java000066400000000000000000000025471163373477200337070ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig14/src/main/java/localhostpackage localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public class Main { public static void main( String[] args ) { if ( new java.util.concurrent.ConcurrentHashMap().isEmpty() ) { System.out.println( "All is good" ); } } } animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig15/000077500000000000000000000000001163373477200256045ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig15/pom.xml000066400000000000000000000076661163373477200271400ustar00rootroot00000000000000 4.0.0 localdomain.localhost real-test 1.0-SNAPSHOT jar Real Test Tests that real signatures work. maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 maven-compiler-plugin 1.5 1.5 ${pluginGroupId} ${pluginArtifactId} ${pluginVersion} test check org.codehaus.mojo.signature java15 1.0 UTF-8 UTF-8 UTF-8 @project.groupId@ @project.artifactId@ @project.version@ animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig15/src/000077500000000000000000000000001163373477200263735ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig15/src/main/000077500000000000000000000000001163373477200273175ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig15/src/main/java/000077500000000000000000000000001163373477200302405ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig15/src/main/java/localhost/000077500000000000000000000000001163373477200322305ustar00rootroot00000000000000Main.java000066400000000000000000000025471163373477200337100ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jdk15-with-sig15/src/main/java/localhostpackage localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public class Main { public static void main( String[] args ) { if ( new java.util.concurrent.ConcurrentHashMap().isEmpty() ) { System.out.println( "All is good" ); } } } animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jre-test/000077500000000000000000000000001163373477200245245ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/jre-test/pom.xml000066400000000000000000000071761163373477200260540ustar00rootroot00000000000000 4.0.0 localdomain.localhost jre-test 1.0-SNAPSHOT pom JRE Test Tests that JRE signatures can be captured. maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 ${pluginGroupId} ${pluginArtifactId} ${pluginVersion} generate package build @java.home@ UTF-8 UTF-8 UTF-8 @project.groupId@ @project.artifactId@ @project.version@ animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-6/000077500000000000000000000000001163373477200261255ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-6/pom.xml000066400000000000000000000114011163373477200274370ustar00rootroot00000000000000 4.0.0 localdomain.localhost real-test 1.0-SNAPSHOT jar MANIMALSNIFFER-9 Tests that a borked artifact does not cause us to blow up without a nice explanation org.apache.httpcomponents httpclient 4.1.1 test maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 maven-dependency-plugin generate-resources copy-dependencies test true ${project.build.outputDirectory}/resources maven-compiler-plugin 1.5 1.5 ${pluginGroupId} ${pluginArtifactId} ${pluginVersion} test check org.codehaus.mojo.signature java15 1.0 UTF-8 UTF-8 UTF-8 @project.groupId@ @project.artifactId@ @project.version@ animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-6/src/000077500000000000000000000000001163373477200267145ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-6/src/main/000077500000000000000000000000001163373477200276405ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-6/src/main/java/000077500000000000000000000000001163373477200305615ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-6/src/main/java/localhost/000077500000000000000000000000001163373477200325515ustar00rootroot00000000000000Main.java000066400000000000000000000024101163373477200342160ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-6/src/main/java/localhostpackage localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public class Main { public static void main( String[] args ) { System.out.println( "All is good" ); } } animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-9/000077500000000000000000000000001163373477200261305ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-9/invoker.properties000066400000000000000000000021701163373477200317230ustar00rootroot00000000000000# # The MIT License # # Copyright (c) 2009 codehaus.org. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # invoker.buildResult=failure animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-9/pom.xml000066400000000000000000000102411163373477200274430ustar00rootroot00000000000000 4.0.0 localdomain.localhost real-test 1.0-SNAPSHOT jar MANIMALSNIFFER-9 Tests that a borked artifact does not cause us to blow up without a nice explanation com.ibm.icu icu4j 2.6.1 maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 maven-compiler-plugin 1.5 1.5 ${pluginGroupId} ${pluginArtifactId} ${pluginVersion} test check org.codehaus.mojo.signature java15 1.0 UTF-8 UTF-8 UTF-8 @project.groupId@ @project.artifactId@ @project.version@ animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-9/src/000077500000000000000000000000001163373477200267175ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-9/src/main/000077500000000000000000000000001163373477200276435ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-9/src/main/java/000077500000000000000000000000001163373477200305645ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-9/src/main/java/localhost/000077500000000000000000000000001163373477200325545ustar00rootroot00000000000000Main.java000066400000000000000000000024101163373477200342210ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-9/src/main/java/localhostpackage localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public class Main { public static void main( String[] args ) { System.out.println( "All is good" ); } } animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/manimalsniffer-9/verify.bsh000066400000000000000000000032511163373477200301330ustar00rootroot00000000000000 /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import java.io.*; import java.util.regex.*; import org.codehaus.plexus.util.FileUtils; try { File file = new File( basedir, "build.log" ); String buf = FileUtils.fileRead( file, "UTF-8" ); Pattern p = Pattern.compile( "Bad class file .*\\Qicu4j-2.6.1.jar:com/ibm/icu/impl/data/LocaleElements_zh__PINYIN.class\\E" ); if ( !p.matcher( buf ).find() ) { System.err.println( "User friendly error message not displayed" ); return false; } } catch( Throwable t ) { t.printStackTrace(); return false; } return true; animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/000077500000000000000000000000001163373477200250435ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/api/000077500000000000000000000000001163373477200256145ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/api/pom.xml000066400000000000000000000043651163373477200271410ustar00rootroot00000000000000 4.0.0 localdomain.localhost merge-test 1.0-SNAPSHOT localdomain.localhost api 1-SNAPSHOT jar Dummy API ${pluginGroupId} ${pluginArtifactId} ${pluginVersion} generate package build false animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/api/src/000077500000000000000000000000001163373477200264035ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/api/src/main/000077500000000000000000000000001163373477200273275ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/api/src/main/java/000077500000000000000000000000001163373477200302505ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/api/src/main/java/localdomain/000077500000000000000000000000001163373477200325325ustar00rootroot00000000000000000077500000000000000000000000001163373477200344435ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/api/src/main/java/localdomain/localhostApi.java000066400000000000000000000023121163373477200360150ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/api/src/main/java/localdomain/localhostpackage localdomain.localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public interface Api { void checkVersion1(); }animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/invoker.properties000066400000000000000000000021611163373477200306360ustar00rootroot00000000000000# # The MIT License # # Copyright (c) 2009 codehaus.org. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # invoker.goals=verify animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/other/000077500000000000000000000000001163373477200261645ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/other/pom.xml000066400000000000000000000047341163373477200275110ustar00rootroot00000000000000 4.0.0 localdomain.localhost merge-test 1.0-SNAPSHOT localdomain.localhost other 1-SNAPSHOT jar Dummy Other API localdomain.localhost api 1-SNAPSHOT signature @project.groupId@ @project.artifactId@ @project.version@ generate package build false animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/other/src/000077500000000000000000000000001163373477200267535ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/other/src/main/000077500000000000000000000000001163373477200276775ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/other/src/main/java/000077500000000000000000000000001163373477200306205ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/other/src/main/java/localdomain/000077500000000000000000000000001163373477200331025ustar00rootroot00000000000000000077500000000000000000000000001163373477200350135ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/other/src/main/java/localdomain/localhostOtherApi.java000066400000000000000000000023171163373477200373740ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/other/src/main/java/localdomain/localhostpackage localdomain.localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public interface OtherApi { void checkVersion3(); }animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/merge-test/pom.xml000066400000000000000000000062661163373477200263720ustar00rootroot00000000000000 4.0.0 localdomain.localhost merge-test 1.0-SNAPSHOT pom Merge Test Tests that signatures can be merged. api other maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 UTF-8 UTF-8 UTF-8 @project.groupId@ @project.artifactId@ @project.version@ animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/settings.xml000066400000000000000000000045451163373477200253610ustar00rootroot00000000000000 it-repo true central file:///@localRepository@ true ignore never true ignore never central file:///@localRepository@ true ignore never true ignore never animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/000077500000000000000000000000001163373477200250625ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-1/000077500000000000000000000000001163373477200257715ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-1/pom.xml000066400000000000000000000043631163373477200273140ustar00rootroot00000000000000 4.0.0 localdomain.localhost build-test 1.0-SNAPSHOT localdomain.localhost api 1-SNAPSHOT jar Dummy API ${pluginGroupId} ${pluginArtifactId} ${pluginVersion} generate package build false animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-1/src/000077500000000000000000000000001163373477200265605ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-1/src/main/000077500000000000000000000000001163373477200275045ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-1/src/main/java/000077500000000000000000000000001163373477200304255ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-1/src/main/java/localdomain/000077500000000000000000000000001163373477200327075ustar00rootroot00000000000000000077500000000000000000000000001163373477200346205ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-1/src/main/java/localdomain/localhostApi.java000066400000000000000000000023121163373477200361720ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-1/src/main/java/localdomain/localhostpackage localdomain.localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public interface Api { void checkVersion1(); }animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-2/000077500000000000000000000000001163373477200257725ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-2/pom.xml000066400000000000000000000044521163373477200273140ustar00rootroot00000000000000 4.0.0 localdomain.localhost build-test 1.0-SNAPSHOT localdomain.localhost api 2-SNAPSHOT jar Dummy API ${pluginGroupId} ${pluginArtifactId} ${pluginVersion} generate package build false false animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-2/src/000077500000000000000000000000001163373477200265615ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-2/src/main/000077500000000000000000000000001163373477200275055ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-2/src/main/java/000077500000000000000000000000001163373477200304265ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-2/src/main/java/localdomain/000077500000000000000000000000001163373477200327105ustar00rootroot00000000000000000077500000000000000000000000001163373477200346215ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-2/src/main/java/localdomain/localhostApi.java000066400000000000000000000023511163373477200361760ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/api-2/src/main/java/localdomain/localhostpackage localdomain.localhost; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ public interface Api { void checkVersion1(); void checkVersion2(); }animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/client/000077500000000000000000000000001163373477200263405ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/client/pom.xml000066400000000000000000000100121163373477200276470ustar00rootroot00000000000000 4.0.0 localdomain.localhost build-test 1.0-SNAPSHOT localdomain.localhost client 1-SNAPSHOT jar Dummy API Client localdomain.localhost api 2-SNAPSHOT positive-test ${pluginGroupId} ${pluginArtifactId} ${pluginVersion} check-jdk test check localdomain.localhost api 2-SNAPSHOT java.* javax.* false negative-test ${pluginGroupId} ${pluginArtifactId} ${pluginVersion} check-jdk test check localdomain.localhost api 1-SNAPSHOT java.* javax.* false animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/client/src/000077500000000000000000000000001163373477200271275ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/client/src/main/000077500000000000000000000000001163373477200300535ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/client/src/main/java/000077500000000000000000000000001163373477200307745ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/client/src/main/java/JDK15.java000066400000000000000000000023741163373477200324230ustar00rootroot00000000000000/* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import localdomain.localhost.Api; public class JDK15 { public void doChecks(Api api) { api.checkVersion2(); } }animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/invoker.properties000066400000000000000000000026471163373477200306660ustar00rootroot00000000000000# # The MIT License # # Copyright (c) 2009 codehaus.org. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # invoker.goals.1=install invoker.profiles.1=setup-1 invoker.goals.2=install invoker.profiles.2=setup-2 invoker.goals.3=verify invoker.profiles.3=positive-test invoker.goals.4=verify invoker.profiles.4=negative-test invoker.buildResult.4=failure invoker.goals.5=verify -Danimal.sniffer.skip=true invoker.profiles.5=negative-test animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/smoke-test/pom.xml000066400000000000000000000072351163373477200264060ustar00rootroot00000000000000 4.0.0 localdomain.localhost build-test 1.0-SNAPSHOT pom Build Test Tests that signatures can be built and then tested. setup-1 api-1 setup-2 api-2 positive-test client negative-test client maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 UTF-8 UTF-8 UTF-8 @project.groupId@ @project.artifactId@ @project.version@ animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/toolchain-test/000077500000000000000000000000001163373477200257245ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/toolchain-test/invoker.properties000066400000000000000000000021711163373477200315200ustar00rootroot00000000000000# # The MIT License # # Copyright (c) 2009 codehaus.org. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # invoker.maven.version=2.0.9+ animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/toolchain-test/pom.xml000066400000000000000000000073141163373477200272460ustar00rootroot00000000000000 4.0.0 localdomain.localhost jre-test 1.0-SNAPSHOT pom Toolchain Test Tests that JRE signatures can be captured from JDK specified in by toolchains. maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 ${pluginGroupId} ${pluginArtifactId} ${pluginVersion} generate package build [1.4,) UTF-8 UTF-8 UTF-8 @project.groupId@ @project.artifactId@ @project.version@ animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/000077500000000000000000000000001163373477200246735ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/invoker.properties000066400000000000000000000000251163373477200304630ustar00rootroot00000000000000invoker.goals=verify animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/pom.xml000066400000000000000000000102501163373477200262060ustar00rootroot00000000000000 4.0.0 with-deps localdomain.localhost 1.0-SNAPSHOT with-deps Verifies that methods provided from dependencies do not trigger signature failures. commons-codec commons-codec provided 1.3 junit junit 3.8.1 test maven-clean-plugin 2.2 maven-compiler-plugin 2.0.2 maven-deploy-plugin 2.3 maven-install-plugin 2.2 maven-jar-plugin 2.2 maven-resources-plugin 2.2 maven-site-plugin 2.0 maven-surefire-plugin 2.4.2 maven-compiler-plugin 1.4 1.4 @project.groupId@ @project.artifactId@ @project.version@ org.codehaus.mojo.signature java14 1.0 check-java-version verify check UTF-8 UTF-8 UTF-8 animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/src/000077500000000000000000000000001163373477200254625ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/src/main/000077500000000000000000000000001163373477200264065ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/src/main/java/000077500000000000000000000000001163373477200273275ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/src/main/java/test/000077500000000000000000000000001163373477200303065ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/src/main/java/test/SSOException.java000066400000000000000000000012061163373477200334730ustar00rootroot00000000000000package test; public class SSOException extends Exception { /** * */ public SSOException() { super(); } /** * @param message * @param cause */ protected SSOException(final String message, final Throwable cause) { super(message, cause); } /** * @param message */ protected SSOException(final String message) { super(message); } /** * @param cause */ protected SSOException(final Throwable cause) { super(cause); } /** * serialVersionUID */ private static final long serialVersionUID = 1L; } animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/src/main/java/test/SSOUtils.java000066400000000000000000000031671163373477200326450ustar00rootroot00000000000000package test; import java.text.SimpleDateFormat; import org.apache.commons.codec.binary.Base64; /** * Classe fournissant des méthodes utilitaires pour la vérification et la génération des tickets de SSO */ public final class SSOUtils { /** * Le truc qui permet de passer en base 64 */ private static final Base64 BASE64_ENCODER = new Base64(); /** * Durée de vie par défaut d'un ticket : 1 heure */ private static final int DEFAULT_TICKET_LIFE_TIME = 3600; /** * La durée de vie d'un ticket exprimée en secondes */ private static int ticketLifeTimeSeconds = SSOUtils.DEFAULT_TICKET_LIFE_TIME; /** * @param ticketLifeTimeSeconds * the ticketLifeTimeSeconds to set */ public static void setTicketLifeTimeSeconds(final int ticketLifeTimeSeconds) { SSOUtils.ticketLifeTimeSeconds = ticketLifeTimeSeconds; } /** * La phrase secrète qui permet de sceller les tickets */ private static String secretPhrase = "toto"; /** * @param secretPhrase * the secretPhrase to set */ public static void setSecretPhrase(final String secretPhrase) { SSOUtils.secretPhrase = secretPhrase; } /** * Le format de date à utiliser pour la gestion du SSO */ public static final SimpleDateFormat SSO_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd:HH-mm-ss"); private SSOUtils() { init(); } /** * Initialise les données de SSOUtils */ private void init() { // TODO alimenter #secretPhrase // TODO alimenter #ticketLifeTimeSeconds } } animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/src/test/000077500000000000000000000000001163373477200264415ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/src/test/java/000077500000000000000000000000001163373477200273625ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/src/test/java/test/000077500000000000000000000000001163373477200303415ustar00rootroot00000000000000SSOTicketGenerator.java000066400000000000000000000002741163373477200346070ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/it/with-deps/src/test/java/test/** * */ package test; /** * @author djeanprost */ public class SSOTicketGenerator { /** * @param args */ public static void main(final String[] args) { } } animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/000077500000000000000000000000001163373477200232775ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/java/000077500000000000000000000000001163373477200242205ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/java/org/000077500000000000000000000000001163373477200250075ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/java/org/codehaus/000077500000000000000000000000001163373477200266025ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/java/org/codehaus/mojo/000077500000000000000000000000001163373477200275465ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/java/org/codehaus/mojo/animal_sniffer/000077500000000000000000000000001163373477200325235ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/java/org/codehaus/mojo/animal_sniffer/maven/000077500000000000000000000000001163373477200336315ustar00rootroot00000000000000BuildSignaturesMojo.java000066400000000000000000000651501163373477200403550ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/java/org/codehaus/mojo/animal_sniffer/mavenpackage org.codehaus.mojo.animal_sniffer.maven; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; import org.apache.maven.shared.artifact.filter.PatternExcludesArtifactFilter; import org.apache.maven.shared.artifact.filter.PatternIncludesArtifactFilter; import org.apache.maven.toolchain.MisconfiguredToolchainException; import org.apache.maven.toolchain.Toolchain; import org.apache.maven.toolchain.ToolchainManager; import org.apache.maven.toolchain.ToolchainManagerPrivate; import org.apache.maven.toolchain.ToolchainPrivate; import org.apache.maven.toolchain.java.JavaToolChain; import org.codehaus.mojo.animal_sniffer.SignatureBuilder; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.cli.CommandLineException; import org.codehaus.plexus.util.cli.CommandLineUtils; import org.codehaus.plexus.util.cli.Commandline; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; /** * Generates an API Signature from at least one of: the java runtime, the * module dependencies and the module classes. * * @author Stephen Connolly * @goal build * @configurator override * @requiresDependencyResolution compile * @threadSafe */ public class BuildSignaturesMojo extends AbstractMojo { /** * Should the signatures from java home be included. * * @parameter expression="${includeJavaHome}" default-value="true" * @since 1.3 */ private boolean includeJavaHome; /** * Should no signatures be generated if no java home is available. * * @parameter expression="${skipIfNoJavaHome}" default-value="false" * @since 1.3 */ private boolean skipIfNoJavaHome; /** * Should the signatures from this module's classes be included.. * * @parameter expression="${includeJavaHome}" default-value="true" * @since 1.3 */ private boolean includeModuleClasses; /** * Classes to generate signatures of. * * @parameter * @since 1.3 */ private String[] includeClasses = null; /** * Classes to exclude from generating signatures of. * * @parameter * @since 1.3 */ private String[] excludeClasses = null; /** * A list of artifact patterns to include. Follows the pattern "groupId:artifactId:type:classifier:version". * * @parameter * @since 1.3 */ private String[] includeDependencies = null; /** * A list of artifact patterns to exclude. Follows the pattern "groupId:artifactId:type:classifier:version". * * @parameter * @since 1.3 */ private String[] excludeDependencies = null; /** * The java home to generate the signatures of, if not specified only the signatures of dependencies will be * included. This parameter is overridden by {@link #javaHomeClassPath}. This parameter overrides {@link #jdk} * and any java home specified by maven-toolchains-plugin. * * @parameter expression="${javaHome}" * @since 1.3 */ private String javaHome; /** * Use this configuration option only if the automatic boot classpath detection does not work for the specific * {@link #javaHome} or {@link #jdk}. For example, the automatic boot classpath detection does not work with * Sun Java 1.1. This parameter overrides {@link #javaHome}, {@link #jdk} and the maven-toolchains-plugin. * * @parameter * @since 1.3 */ private File[] javaHomeClassPath; /** * Where to put the generated signatures. * * @parameter expression="${project.build.directory}" * @required * @since 1.3 */ private File outputDirectory; /** * Where to find this modules classes. * * @parameter expression="${project.build.outputDirectory}" * @required * @since 1.3 */ private File classesDirectory; /** * The name of the generated signatures. * * @parameter expression="${project.build.finalName}" * @required * @since 1.3 */ private String signaturesName; /** * The classifier to add to the generated signatures. * * @parameter * @since 1.3 */ private String classifier; /** * @component */ private MavenProjectHelper projectHelper; /** * The maven project. * * @parameter expression="${project}" * @required * @readonly */ private MavenProject project; /** * @component */ private ToolchainManager toolchainManager; /** * @component */ private ToolchainManagerPrivate toolchainManagerPrivate; /** * The current build session instance. This is used for toolchain manager API calls. * * @parameter expression="${session}" * @required * @readonly */ private MavenSession session; /** * The JDK Toolchain to use. This parameter can be overridden by {@link #javaHome} or {@link #javaHomeClassPath}. * This parameter overrides any toolchain specified with maven-toolchains-plugin. * * @parameter * @since 1.3 */ private JdkToolchain jdk; /** * @parameter expression="${plugin.artifacts}" * @required * @readonly */ private List/**/ pluginArtifacts; /** * The groupId of the Java Boot Classpath Detector to use. The plugin's dependencies will be searched for a * dependency of type jar with this groupId and the artifactId specified in {@link #jbcpdArtifactId}. * The dependency should be a standalone executable jar file which outputs the java boot classpath as a single * line separated using {@link File#pathSeparatorChar} or else exits with a non-zero return code if it cannot determine * the java boot classpath. * * @parameter default-value="${plugin.groupId}" * @since 1.3 */ private String jbcpdGroupId; /** * The artifactId of the Java Boot Classpath Detector to use. The plugin's dependencies will be searched for a * dependency of type jar with this artifactId and the groupId specified in {@link #jbcpdGroupId}. * The dependency should be a standalone executable jar file which outputs the java boot classpath as a single * line separated using {@link File#pathSeparatorChar} or else exits with a non-zero return code if it cannot determine * the java boot classpath. * * @parameter default-value="java-boot-classpath-detector" * @since 1.3 */ private String jbcpdArtifactId; public void execute() throws MojoExecutionException, MojoFailureException { if ( includeJavaHome && ( javaHomeClassPath == null || javaHomeClassPath.length == 0 ) ) { if ( javaHome != null ) { getLog().warn( "Toolchains are ignored, 'javaHome' parameter is set to " + javaHome ); if ( !new File( javaHome ).isDirectory() ) { if ( skipIfNoJavaHome ) { getLog().warn( "Skipping signature generation as java home (" + javaHome + ") does not exist" ); return; } throw new MojoFailureException( "Cannot include java home if specified java home does not exist" ); } if ( !detectJavaBootClasspath( new File( new File( javaHome, "bin" ), "java" ).getAbsolutePath() ) ) { return; } } else { Toolchain tc = getToolchain(); if ( tc == null && jdk == null ) { String jvm = null; tc = toolchainManager.getToolchainFromBuildContext( "jdk", //NOI18N session ); getLog().info( "Toolchain from session: " + tc ); //assign the path to executable from toolchains if ( tc != null ) { jvm = tc.findTool( "java" ); //NOI18N } if ( jvm == null ) { if ( skipIfNoJavaHome ) { getLog().warn( "Skipping signature generation as could not find java home" ); return; } throw new MojoFailureException( "Cannot include java home if java home is not specified (either via javaClassPath, javaHome or jdk)" ); } if ( !detectJavaBootClasspath( jvm ) ) { return; } } else if ( tc != null && tc instanceof JavaToolChain ) { getLog().info( "Toolchain in animal-sniffer-maven-plugin: " + tc ); //when the executable to use is explicitly set by user in mojo's parameter, ignore toolchains. //assign the path to executable from toolchains String jvm = tc.findTool( "java" ); //NOI18N if ( jvm == null ) { if ( skipIfNoJavaHome ) { getLog().warn( "Skipping signature generation as could not find java home" ); return; } throw new MojoFailureException( "Cannot include java home if java home is not specified (either via javaClassPath, javaHome or jdk)" ); } if ( !detectJavaBootClasspath( jvm ) ) { return; } } else if ( tc == null && jdk != null && jdk.getParameters() != null ) { if ( skipIfNoJavaHome ) { getLog().warn( "Skipping signature generation as could not find jdk toolchain to match " + jdk.getParameters() ); return; } throw new MojoFailureException( "Could not find jdk toolchain to match " + jdk.getParameters() ); } else { if ( skipIfNoJavaHome ) { getLog().warn( "Skipping signature generation as could not find java home" ); return; } throw new MojoFailureException( "Cannot include java home if java home is not specified (either via javaClassPath, javaHome, " + "jdk or maven-toolchains-plugin)" ); } } } displayJavaBootClasspath(); File sigFile = getTargetFile( outputDirectory, signaturesName, classifier, "signature" ); try { outputDirectory.mkdirs(); SignatureBuilder builder = new SignatureBuilder( getBaseSignatures(), new FileOutputStream( sigFile ), new MavenLogger( getLog() ) ); if ( includeClasses != null ) { getLog().info( "Restricting signatures to include only the following classes:" ); for ( int i = 0; i < includeClasses.length; i++ ) { getLog().info( " " + includeClasses[i] ); builder.addInclude( includeClasses[i] ); } } if ( excludeClasses != null ) { getLog().info( "Restricting signatures to exclude the following classes:" ); for ( int i = 0; i < excludeClasses.length; i++ ) { getLog().info( " " + excludeClasses[i] ); builder.addExclude( excludeClasses[i] ); } } processJavaBootClasspath( builder ); processModuleDependencies( builder ); processModuleClasses( builder ); builder.close(); projectHelper.attachArtifact( project, "signature", classifier, sigFile ); } catch ( IOException e ) { throw new MojoExecutionException( e.getMessage(), e ); } } private boolean detectJavaBootClasspath( String javaExecutable ) throws MojoFailureException, MojoExecutionException { getLog().info( "Attempting to auto-detect the boot classpath for " + javaExecutable ); Iterator i = pluginArtifacts.iterator(); Artifact javaBootClasspathDetector = null; while ( i.hasNext() && javaBootClasspathDetector == null ) { Artifact candidate = (Artifact) i.next(); if ( StringUtils.equals( jbcpdGroupId, candidate.getGroupId() ) && StringUtils.equals( jbcpdArtifactId, candidate.getArtifactId() ) && candidate.getFile() != null && candidate.getFile().isFile() ) { javaBootClasspathDetector = candidate; } } if ( javaBootClasspathDetector == null ) { if ( skipIfNoJavaHome ) { getLog().warn( "Skipping signature generation as could not find boot classpath detector (" + ArtifactUtils.versionlessKey( jbcpdGroupId, jbcpdArtifactId ) + ")." ); return false; } throw new MojoFailureException( "Could not find boot classpath detector (" + ArtifactUtils.versionlessKey( jbcpdGroupId, jbcpdArtifactId ) + ")." ); } try { if ( !detectJavaClasspath( javaBootClasspathDetector, javaExecutable ) ) { return false; } } catch ( CommandLineException e ) { throw new MojoExecutionException( e.getLocalizedMessage(), e ); } return true; } private boolean detectJavaClasspath( Artifact javaBootClasspathDetector, String javaExecutable ) throws CommandLineException, MojoFailureException { final Commandline cli = new Commandline(); cli.setWorkingDirectory( project.getBasedir().getAbsolutePath() ); cli.setExecutable( javaExecutable ); cli.addEnvironment( "CLASSPATH", "" ); cli.addEnvironment( "JAVA_HOME", "" ); cli.addArguments( new String[]{ "-jar", javaBootClasspathDetector.getFile().getAbsolutePath() } ); final CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); final CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode = CommandLineUtils.executeCommandLine( cli, stdout, stderr ); if ( exitCode != 0 ) { getLog().debug( "Stdout: " + stdout.getOutput() ); getLog().debug( "Stderr: " + stderr.getOutput() ); getLog().debug( "Exit code = " + exitCode ); if ( skipIfNoJavaHome ) { getLog().warn( "Skipping signature generation as could not auto-detect java boot classpath for " + javaExecutable ); return false; } throw new MojoFailureException( "Could not auto-detect java boot classpath for " + javaExecutable ); } String[] classpath = StringUtils.split( stdout.getOutput(), File.pathSeparator ); javaHomeClassPath = new File[classpath.length]; for ( int j = 0; j < classpath.length; j++ ) { javaHomeClassPath[j] = new File( classpath[j] ); } return true; } private void displayJavaBootClasspath() { if ( includeJavaHome ) { getLog().info( "Java Classpath:" ); if ( javaHomeClassPath == null ) { getLog().info( " Empty" ); } else { for ( int j = 0; j < javaHomeClassPath.length; j++ ) { getLog().info( " [" + j + "] = " + javaHomeClassPath[j] ); } } } } private void processModuleDependencies( SignatureBuilder builder ) throws IOException { PatternIncludesArtifactFilter includesFilter = includeDependencies == null ? null : new PatternIncludesArtifactFilter( Arrays.asList( includeDependencies ) ); PatternExcludesArtifactFilter excludesFilter = excludeDependencies == null ? null : new PatternExcludesArtifactFilter( Arrays.asList( excludeDependencies ) ); for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); ) { Artifact artifact = (Artifact) i.next(); if ( includesFilter != null && !includesFilter.include( artifact ) ) { getLog().debug( "Artifact " + artifactId( artifact ) + " ignored as it does not match include rules." ); continue; } if ( excludesFilter != null && !excludesFilter.include( artifact ) ) { getLog().debug( "Artifact " + artifactId( artifact ) + " ignored as it does matches exclude rules." ); continue; } if ( StringUtils.equals( "jar", artifact.getType() ) ) { getLog().info( "Parsing sigantures from " + artifactId( artifact ) ); builder.process( artifact.getFile() ); } } } private void processModuleClasses( SignatureBuilder builder ) throws IOException { if ( includeModuleClasses && classesDirectory.isDirectory() ) { getLog().info( "Parsing sigantures from " + classesDirectory ); builder.process( classesDirectory ); } } private void processJavaBootClasspath( SignatureBuilder builder ) throws IOException { if ( includeJavaHome && javaHomeClassPath != null && javaHomeClassPath.length > 0 ) { getLog().debug( "Parsing sigantures java classpath:" ); for ( int i = 0; i < javaHomeClassPath.length; i++ ) { if ( javaHomeClassPath[i].isFile() || javaHomeClassPath[i].isDirectory() ) { getLog().debug( "Processing " + javaHomeClassPath[i] ); builder.process( javaHomeClassPath[i] ); } else { getLog().warn( "Could not add signatures from boot classpath element: " + javaHomeClassPath[i] + " as it does not exist." ); } } } } private InputStream[] getBaseSignatures() throws FileNotFoundException { List baseSignatures = new ArrayList(); for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); ) { Artifact artifact = (Artifact) i.next(); if ( StringUtils.equals( "signature", artifact.getType() ) ) { getLog().info( "Importing sigantures from " + artifact.getFile() ); baseSignatures.add( new FileInputStream( artifact.getFile() ) ); } } final InputStream[] baseSignatureInputStreams = (InputStream[]) baseSignatures.toArray( new InputStream[baseSignatures.size()] ); return baseSignatureInputStreams; } /** * Gets the toolchain to use. * * @return the toolchain to use or null if no toolchain is configured or if no toolchain can be found. * @throws MojoExecutionException if toolchains are misconfigured. */ private Toolchain getToolchain() throws MojoExecutionException { Toolchain tc = getToolchainFromConfiguration(); if ( tc == null ) { tc = getToolchainFromContext(); } return tc; } /** * Gets the toolchain specified for the current context, e.g. specified via the maven-toolchain-plugin * * @return the toolchain from the context or null if there is no such toolchain. */ private Toolchain getToolchainFromContext() { if ( toolchainManager != null ) { return toolchainManager.getToolchainFromBuildContext( "jdk", //NOI18N session ); } return null; } /** * Gets the toolchain from this plugin's configuration. * * @return the toolchain from this plugin's configuration, or null if no matching toolchain can be * found. * @throws MojoExecutionException if the toolchains are configured incorrectly. */ private Toolchain getToolchainFromConfiguration() throws MojoExecutionException { if ( toolchainManager != null && jdk != null && jdk.getParameters() != null ) { try { final ToolchainPrivate[] tcp = getToolchains( jdk.getToolchain() ); for ( int i = 0; i < tcp.length; i++ ) { if ( tcp[i].matchesRequirements( jdk.getParameters() ) ) { return tcp[i]; } } } catch ( MisconfiguredToolchainException e ) { throw new MojoExecutionException( e.getLocalizedMessage(), e ); } } return null; } private static String artifactId( Artifact artifact ) { return ArtifactUtils.artifactId( artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(), artifact.getClassifier(), artifact.getBaseVersion() ); } private ToolchainPrivate[] getToolchains( String type ) throws MojoExecutionException, MisconfiguredToolchainException { // The toolchain API has moved about quite a bit... this method tries to navigate through to a // successful enumeration of all the toolchains of the required type. // This method is only ever called in versions of Maven that have toolchain support. Class managerClass = toolchainManagerPrivate.getClass(); try { try { // try 3.x style API Method newMethod = managerClass.getMethod( "getToolchainsForType", new Class[]{ String.class, MavenSession.class } ); return (ToolchainPrivate[]) newMethod.invoke( toolchainManagerPrivate, new Object[]{ type, session } ); } catch ( NoSuchMethodException e1 ) { try { // try 2.2.1 style API Method oldMethod = managerClass.getMethod( "getToolchainsForType", new Class[]{ String.class } ); return (ToolchainPrivate[]) oldMethod.invoke( toolchainManagerPrivate, new Object[]{ type } ); } catch ( NoSuchMethodException e2 ) { e2.initCause( e1 ); throw e2; } } } catch ( NoSuchMethodException e ) { StringBuilder buf = new StringBuilder( "Incompatible toolchain API." ); buf.append( "\n\nCannot find a suitable 'getToolchainsForType' method. Available methods are:\n" ); Method[] methods = managerClass.getMethods(); for ( int i = 0; i < methods.length; i++ ) { buf.append( " " ).append( methods[i] ).append( '\n' ); } throw new MojoExecutionException( buf.toString(), e ); } catch ( IllegalAccessException e ) { throw new MojoExecutionException( "Incompatible toolchain API", e ); } catch ( InvocationTargetException e ) { Throwable cause = e.getCause(); if ( cause instanceof RuntimeException ) { throw (RuntimeException) cause; } if ( cause instanceof MisconfiguredToolchainException ) { throw (MisconfiguredToolchainException) cause; } throw new MojoExecutionException( "Incompatible toolchain API", e ); } } private static File getTargetFile( File basedir, String finalName, String classifier, String type ) { if ( classifier == null ) { classifier = ""; } else if ( classifier.trim().length() > 0 && !classifier.startsWith( "-" ) ) { classifier = "-" + classifier; } return new File( basedir, finalName + classifier + "." + type ); } } CheckSignatureMojo.java000066400000000000000000000145711163373477200401510ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/java/org/codehaus/mojo/animal_sniffer/mavenpackage org.codehaus.mojo.animal_sniffer.maven; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import org.codehaus.mojo.animal_sniffer.ClassFileVisitor; import org.codehaus.mojo.animal_sniffer.ClassListBuilder; import org.codehaus.mojo.animal_sniffer.SignatureChecker; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Set; /** * Checks the classes compiled by this module. * * @author Kohsuke Kawaguchi * @phase process-classes * @requiresDependencyResolution compile * @goal check * @threadSafe */ public class CheckSignatureMojo extends AbstractMojo { /** * Project classpath. * * @parameter expression="${project.compileClasspathElements}" * @required * @readonly */ protected List classpathElements; /** * The directory for compiled classes. * * @parameter expression="${project.build.outputDirectory}" * @required * @readonly */ protected File outputDirectory; /** * Signature module to use. * * @required * @parameter */ protected Signature signature; /** * Class names to ignore signatures for (wildcards accepted). * * @parameter */ protected String[] ignores; /** * Should dependencies be ignored. * * @parameter default-value="true" */ protected boolean ignoreDependencies; /** * Should signature checking be skipped? * * @parameter default-value="false" expression="${animal.sniffer.skip}" */ protected boolean skip; /** * @component * @readonly */ protected ArtifactResolver resolver; /** * @parameter expression="${project}" * @readonly */ protected MavenProject project; /** * @parameter expression="${localRepository}" * @readonly */ protected ArtifactRepository localRepository; /** * @component * @readonly */ protected ArtifactFactory artifactFactory; public void execute() throws MojoExecutionException, MojoFailureException { if ( skip ) { getLog().info( "Signature checking is skipped." ); return; } try { getLog().info( "Checking unresolved references to " + signature ); org.apache.maven.artifact.Artifact a = signature.createArtifact( artifactFactory ); resolver.resolve( a, project.getRemoteArtifactRepositories(), localRepository ); // just check code from this module final Set ignoredPackages = buildPackageList(); if ( ignores != null ) { for ( int i = 0; i < ignores.length; i++ ) { String ignore = ignores[i]; if ( ignore == null ) { continue; } ignoredPackages.add( ignore.replace( '.', '/' ) ); } } if ( getLog().isDebugEnabled() ) { getLog().debug( ignoredPackages.toString() ); } final SignatureChecker signatureChecker = new SignatureChecker( new FileInputStream( a.getFile() ), ignoredPackages, new MavenLogger( getLog() ) ); signatureChecker.setCheckJars( false ); // don't want to decend into jar files that have been copied to // the output directory as resources. signatureChecker.process( outputDirectory ); if ( signatureChecker.isSignatureBroken() ) { throw new MojoFailureException( "Signature errors found. Verify them and put @IgnoreJRERequirement on them." ); } } catch ( IOException e ) { throw new MojoExecutionException( "Failed to check signatures", e ); } catch ( AbstractArtifactResolutionException e ) { throw new MojoExecutionException( "Failed to obtain signature: " + signature, e ); } } /** * List of packages defined in the application. */ private Set buildPackageList() throws IOException { ClassListBuilder plb = new ClassListBuilder( new MavenLogger( getLog() ) ); apply( plb ); return plb.getPackages(); } private void apply( ClassFileVisitor v ) throws IOException { v.process( outputDirectory ); if ( ignoreDependencies ) { Iterator itr = classpathElements.iterator(); while ( itr.hasNext() ) { String path = (String) itr.next(); v.process( new File( path ) ); } } } } JdkToolchain.java000066400000000000000000000043471163373477200367760ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/java/org/codehaus/mojo/animal_sniffer/mavenpackage org.codehaus.mojo.animal_sniffer.maven; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import java.util.Map; /** * Represents the details of the jdk toolchain required. * * @author Stephen Connolly */ public class JdkToolchain { private Map parameters; public String getToolchain() { return "jdk"; } public Map getParameters() { return parameters; } public void setParameters( Map parameters ) { this.parameters = parameters; } public boolean equals( Object o ) { if ( this == o ) { return true; } if ( o == null || getClass() != o.getClass() ) { return false; } JdkToolchain that = (JdkToolchain) o; if ( parameters != null ? !parameters.equals( that.parameters ) : that.parameters != null ) { return false; } return true; } public int hashCode() { return parameters != null ? parameters.hashCode() : 0; } public String toString() { return "JdkToolchain{" + "parameters=" + parameters + '}'; } } JdkToolchainConverter.java000066400000000000000000000100721163373477200406560ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/java/org/codehaus/mojo/animal_sniffer/mavenpackage org.codehaus.mojo.animal_sniffer.maven; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ConfigurationListener; import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter; import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * Plexus ConfigurationConverter * * @author Stephen Connolly */ public class JdkToolchainConverter extends AbstractConfigurationConverter { public static final String ROLE = ConfigurationConverter.class.getName(); /** * @see org.codehaus.plexus.component.configurator.converters.ConfigurationConverter#canConvert(java.lang.Class) */ public boolean canConvert( Class type ) { return JdkToolchain.class.isAssignableFrom( type ); } /** * @see org.codehaus.plexus.component.configurator.converters.ConfigurationConverter#fromConfiguration(org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup, org.codehaus.plexus.configuration.PlexusConfiguration, java.lang.Class, java.lang.Class, java.lang.ClassLoader, org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator, org.codehaus.plexus.component.configurator.ConfigurationListener) */ public Object fromConfiguration( ConverterLookup converterLookup, PlexusConfiguration configuration, Class type, Class baseType, ClassLoader classLoader, ExpressionEvaluator expressionEvaluator, ConfigurationListener listener ) throws ComponentConfigurationException { return fromConfiguration( configuration, expressionEvaluator ); } private JdkToolchain fromConfiguration( PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator ) throws ComponentConfigurationException { PlexusConfiguration[] params = configuration.getChildren(); Map parameters = new HashMap(); for ( int j = 0; j < params.length; j++ ) { try { String name = params[j].getName(); String val = params[j].getValue(); parameters.put( name, val ); } catch ( PlexusConfigurationException ex ) { throw new ComponentConfigurationException( ex ); } } final JdkToolchain result = new JdkToolchain(); result.setParameters( Collections.unmodifiableMap( parameters ) ); return result; } } MavenLogger.java000066400000000000000000000044361163373477200366320ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/java/org/codehaus/mojo/animal_sniffer/mavenpackage org.codehaus.mojo.animal_sniffer.maven; /* * The MIT License * * Copyright (c) 2009, codehaus.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.codehaus.mojo.animal_sniffer.logging.Logger; import org.apache.maven.plugin.logging.Log; /** * An animal sniffer logger that delegates to a maven log. * * @author connollys * @since 1.3 */ public final class MavenLogger implements Logger { private final Log delegate; public MavenLogger( Log delegate ) { this.delegate = delegate; } public void info( String message ) { delegate.info( message ); } public void info( String message, Throwable t ) { delegate.info( message, t ); } public void debug( String message ) { delegate.debug( message ); } public void debug( String message, Throwable t ) { delegate.debug( message, t ); } public void warn( String message ) { delegate.warn( message ); } public void warn( String message, Throwable t ) { delegate.warn( message, t ); } public void error( String message ) { delegate.error( message ); } public void error( String message, Throwable t ) { delegate.error( message, t ); } } Signature.java000066400000000000000000000043651163373477200363660ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/java/org/codehaus/mojo/animal_sniffer/mavenpackage org.codehaus.mojo.animal_sniffer.maven; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.apache.maven.artifact.factory.ArtifactFactory; /** * Represents artifact in Maven POM. * Maven binds this automatically to XML. * * @author Kohsuke Kawaguchi */ public class Signature { private String groupId; private String artifactId; private String version; public String getGroupId() { return groupId; } public void setGroupId( String groupId ) { this.groupId = groupId; } public String getArtifactId() { return artifactId; } public void setArtifactId( String artifactId ) { this.artifactId = artifactId; } public String getVersion() { return version; } public void setVersion( String version ) { this.version = version; } public org.apache.maven.artifact.Artifact createArtifact( ArtifactFactory factory ) { return factory.createArtifact( groupId, artifactId, version, null, "signature" ); } public String toString() { return groupId + ":" + artifactId + ":" + version; } } animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/resources/000077500000000000000000000000001163373477200253115ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/resources/META-INF/000077500000000000000000000000001163373477200264515ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/resources/META-INF/plexus/000077500000000000000000000000001163373477200277715ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/main/resources/META-INF/plexus/components.xml000066400000000000000000000050011163373477200326740ustar00rootroot00000000000000 org.codehaus.plexus.component.configurator.ComponentConfigurator override org.codehaus.plexus.component.configurator.BasicComponentConfigurator org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup override org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup override org.codehaus.plexus.component.configurator.converters.lookup.DefaultConverterLookup org.codehaus.plexus.component.configurator.converters.ConfigurationConverter JdkToolchain customConverters org.codehaus.plexus.component.configurator.converters.ConfigurationConverter JdkToolchain org.codehaus.mojo.animal_sniffer.maven.JdkToolchainConverter animal-sniffer-1.7/animal-sniffer-maven-plugin/src/site/000077500000000000000000000000001163373477200233175ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/site/apt/000077500000000000000000000000001163373477200241035ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/site/apt/examples/000077500000000000000000000000001163373477200257215ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/site/apt/examples/checking-signatures.apt.vm000066400000000000000000000226601163373477200330130ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Checking a project against API signatures ----- Stephen Connolly ------ 2010-03-10 ------ Checking a project against API signatures * Basic example In order to check your project against an API signature, you must configure your <<>> to reference the signature to check against: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... ___group id of signature___ ___artifact id of signature___ ___version of signature___ ... ... ... ... ... --- Once you have configured your project with details of the signature to check, you have two ways to check your classes against this signature: * Invoke the <<>> goal directly, e.g. --- mvn animal-sniffer:check --- * Make the checks part of your build process add an execution to your configuration, e.g. --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ___id of execution___ ... test ... check ... ... ... ... ... --- [] In either case, if any of your classes reference a class, a method, or a field which is not in either the signature or your project's dependencies then a build error will be thrown. * Ignoring classes not in the signature In certain situations you may want to reference classes which are missing from the signature you are checking. This is usually the case where you are compiling with a newer JDK than the JDK you are targetting <> you are writing some code which safely makes use of the features in the newer JDK when running on the newer JDK. For example, if you have code like: --- public final class MapFactory { private MapFactory() { new IllegalAccessError("This is a utility class"); } public static Map newHashMap() { try { // we'd prefer the concurrent version return new ConcurrentHashMap(); } catch (LinkageError e) { // oh dear, looks like we're running on something // earlier than JDK 1.5. This will be slower // but still safe for concurrent access return Collections.synchronizedMap(new HashMap()); } } } --- The above code will require JDK 1.5 or newer to compile, and can run on earlier JDKs (although with degraded performance, and we are assuming you have set the -source and -target options correctly for the earlier JDKs). When you run animal-sniffer against the above class using the JDK 1.4 signatures, you will get a build failure because <<>> is not in the JDK 1.4 signature. If you are sure that where you have used <<>> you have correctly encapsulated it within <<>> blocks or their equivalent, you can tell animal-sniffer to ignore the class, e.g. --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... ... java.util.concurrent.ConcurrentHashMap ... ... ... ... ... ... --- We can specify multiple classes, and we can also use wildcards to match multiple classes, for example, to ignore <<>>, <<>> and <<>> you would use a configuration like: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... java.util.concurrent.ConcurrentHashMap java.util.concurrent.ConcurrentMap javax.servlet.* ... ... ... ... ... --- * When your minimum target JRE is 1.5 or newer If you are targetting JRE 1.5 or newer (i.e. the lowest version of Java that your project will support is a version that supports annotations) it is preferable to annotate your <<>> safe methods rather than using the <<>> configuration element. To annotate your methods, you need to add either an optional and/or provided dependency on <<>>. Technically optional is the correct way, but to work around some incorrectly written Maven plugins, you may end up using scope provided. --- ... ... ${project.parent.groupId} animal-sniffer-annotations ${project.parent.version} true ... ... ... ... maven-compiler-plugin ... ... 1.5 1.5 ... ... ... ... --- Then whenever you safely reference a newer class, you just annotate the method with <<<@IgnoreJRERequirement>>> for example: --- public final class Someclass { ... @IgnoreJRERequirement public void doSomething() { try { // try it the JDK 6 way } catch (LinkageError e) { // fall back to the JDK 5 way } } ... } --- <> If you have compiled with the <<>> you do not have to change anything as animal-sniffer automatically detects this annotation as well (even though it is in a different package. * Referencing classes from dependencies By default, animal-sniffer will automatically ignore any classes and methods defined in your dependencies. This is usually what you want. In certain rare situations, you may want to ignore your project dependencies by setting the <<>> parameter to <<>>. For example, you might be compiling your project against the JavaEE 5 specification but want to check compatibility against the J2EE 1.4 specification. You will have a signature corresponding to the exposed J2EE 1.4 api's. If you check against this signature, because all of the JavaEE 1.5 API dependencies are ignored your project will never fail even if it uses JavaEE 1.5 only methods. In this situation, you would want to turn off the default behaviour, e.g. --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... false ... ... ... ... ... --- generating-java-signatures.apt.vm000066400000000000000000000301001163373477200342070ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/site/apt/examples ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Generating signatures of the Java Runtime ----- Stephen Connolly ------ 2010-03-10 ------ Generating signatures of the Java Runtime * Basic To generate signatures of any API, you simple construct a project with the appropriate dependencies exposed by the API and then add an execution of the <<>> goal to your project. In the case of the Java Runtime, this is a project with no dependencies, e.g. --- 4.0.0 ____ ____ ____ pom ${project.groupId} ${project.artifactId} ${project.version} ___id of execution___ package build --- Then you just build this project with the appropriate Java Runtime, and it will generate the signatures of that Java Runtime. The observant reader may have spotted that it may not always be possible to run Maven with the Java Runtime that you want to generate the signatures of. In these cases you have a number of solutions: * Use Maven Toolchains support and the <<>> parameter to define what toolchain you require. This will use automatic boot classpath detection, which does not work for Java 1.1 or earlier and may not work on some exotic Java Runtimes. An example of using the <<>> parameter is: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... [1.6.0,1.6.1) sun ... ... ... ... ... --- * Use the <<>> parameter to specify the Java Home that you want to generate the signatures of. This will use automatic boot classpath detection, which does not work for Java 1.1 or earlier and may not work on some exotic Java Runtimes. An example of using the <<>> parameter is: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... C:\Program Files\Java\jdk_1.6.0_14 ... ... ... ... ... --- * Use the <<>> parameter to specify the exact classpath to generate the signatures of. This is the only way to specify the Java Runtime when automatic boot classpath detection fails. An example of this technique is: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... C:\Program Files\Java\jdk_1.6.0_14\jre\lib\rt.jar C:\Program Files\Java\jdk_1.6.0_14\jre\lib\jsse.jar ... ... ... ... ... --- [] * Generating "pure" signatures The above examples generate signatures of the entire classpath of the JRE. That will include all the implementation classes which are not part of the public contract of the JRE. For example sun.misc.BASE64Encoder is part of Sun's JRE runtime libraries, but is not part of the JRE specification and if you run on a JRE produced by a different vendor, it is highly likely that that class will not be available to your program. In order to ensure that the Java signatures you generate only include those classes which are officially published by the JRE, you will need to tune your signatures. ** Inclusion based tuning One technique is to only include those classes which you know are part of the JRE public specification. For example: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... [1.4.0,1.5.0) java.* javax.* org.omg.* org.w3c.dom.* ... ... ... ... ... ... --- This requires that you known exactly what classes are part of the JRE specification. ** Exclusion based tuning The other technique is to specify which classes are not to be included. Note that a combination of the two can also be used. For example: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... [1.4.0,1.5.0) com.sun.* sun.* ... ... ... ... ... ... --- * When the version of Java you require is not available By default, if the version of Java that you require is not available, the animal-sniffer plugin will fail the build. If you are generating multiple signatures, this may not be exactly what you want. For example you may be generating signatures for JREs on Windows, Linux and MacOS from the same project. This would require building the same project at least three times and setting the <<>> option to <<>> for example --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... true ... ... windows ... ... windows [1.4.0,1.5.0) windows ... ... linux ... ... linux [1.4.0,1.5.0) linux ... ... ... ... ... --- * Automatic boot classpath detection Animal sniffer uses a helper module to try and determine the boot classpath of the Java Home that has been specified. This can be done in one of two ways: * Indirectly via a toolchain reference using the <<>> configuration option * Directly using the <<>> option [] The {{{../../animal-sniffer/java-boot-classpath-detector/}helper module}} should work for most common versions of Java providing they are at least Java 1.2. If the default helper module does not work for the version of Java that you need to generate signatures of, you can replace the helper module with your own module. The replacement module must meet the following specification: * Must be an executable JAR file * If the Java boot classpath cannot be detected, it must return with exit code 1. * If the Java boot classpath has been detected, it must print the boot class path to <<>> as a single line with each element of the boot classpath separated from the next using <<>> and return with exit code 0. [] When invoking the helper module, animal-sniffer will: * Clear the CLASSPATH environment variable in the forked execution environment. * Clear the JAVA_HOME environment variable in the forked execution environment. * Invoke the <<>> command in the <<>> or <<>> that has been configured with the options <<<-jar>>> and the full path to the Java boot classpath detector module specified in the configuration of the animal-sniffer plugin. Note: this module JAR file will be located in the Maven local repository. [] A replacement module must be added to the <<>> section of and the groupId and artifactId must be configured using the <<>> and <<>> configuration options. For example, if your custom boot classpath detector is com.mycompany:detect-boot-classpath:1.2.0:jar then you could configure animal-sniffer to use this with the following: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... com.mycompany detect-boot-classpath ... ... ... com.mycompany detect-boot-classpath 1.2.0 ... ... ... ... ... --- generating-other-api-signatures.apt.vm000066400000000000000000000171261163373477200351730ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/site/apt/examples ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Generating signatures of other APIs ----- Stephen Connolly ------ 2010-03-10 ------ Generating signatures of other APIs * Basic To generate signatures of any API, you simply construct a project with the appropriate dependencies exposed by the API and then add an execution of the <<>> goal to your project, e.g. --- 4.0.0 ____ ____ ____ ... ${project.groupId} ${project.artifactId} ${project.version} ___id of execution___ package build --- * Controlling the Java Runtime signatures in your API signature By default, the signatures of the Java Runtime that you use to build with will be included in the signatures of the API. Since the Java Runtime forms part of any Java API (as your API extends <<>>) in general the Java Runtime signatures should form part of your API's signatures. If you want different Java Runtime signatures used, you can either use the techniques described in {{{generating-java-signatures.html}Generating signatures of the Java Runtime}} to control what Java Runtime to include or you can base your API off an existing Java Runtime signature. For example: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... org.codehaus.mojo.animal_sniffer java 1.0 java-1.4-generic false ... ... ... ... ... --- <> You can include multiple signatures, and the signatures you include do not have to include a Java Runtime (but ultimately if you are checking against a signature which does not include the Java Runtime, your check will always fail). * Excluding dependencies from signatures Sometimes you may not want to include your module dependencies in the signature. For example, your module might define the public API but depend on the private implementations of that API. In that case you would use either the <<>> to define the subset of module dependencies to include or <<>> to define the subset of module dependencies to exclude (or a combination of the two. Note: includes are processed before excludes). For example, to include all artifacts with groupId <<>> and the servlet-api version 2.5 you would use something like: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... com.mycompany:* javax.servlet:servlet-api:2.5:jar ... ... ... ... ... --- * Excluding module classes from signatures In some cases you may not want to include your module classes in the generated signature. To exclude module classes from the generated signature set the <<>> to <<>> for example: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... false ... ... ... ... ... --- * Tuning exactly which classes are part of the signatures The above examples generate signatures of all the classes in scope. In some situations you may want to only include specific classes from the dependencies or your module. This can be achieved using the <<>> and <<>> configuration options. ** Inclusion based tuning One technique is to only include those classes which you want to be part of the API signature. For example: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... com.mycompany.myapi.* com.mycompany.mydatamodel.ApiConfig ... ... ... ... ... ... --- ** Exclusion based tuning The other technique is to specify which classes are not to be included. Note that a combination of the two can also be used. For example: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... com.mycompany.impl.* ... ... ... ... ... ... --- animal-sniffer-1.7/animal-sniffer-maven-plugin/src/site/apt/index.apt000066400000000000000000000075031163373477200257250ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ------ Introduction ------ Stephen Connolly ------ 2009-10-27 ------ Animal Sniffer Maven Plugin The Animal Sniffer Plugin is used to build signatures of APIs and to check your classes against previously generated signatures. This plugin is called animal sniffer because the principal signatures that are used are those of the Java Runtime, and since Sun traditionally names the different versions of its Java Runtimes after different animals, the plugin that detects what Java Runtime your code requires was called "Animal Sniffer". * Goals Overview The Animal Sniffer Plugin has the following goals. * {{{build-mojo.html}animal-sniffer:build}} creates a signature of an API. * {{{check-mojo.html}animal-sniffer:check}} checks a project against an API signature. * Usage General instructions on how to use the Animal Sniffer Plugin can be found on the {{{usage.html}usage page}}. Some more specific use cases are described in the examples given below. Last but not least, users occasionally contribute additional examples, tips or errata to the {{{http://docs.codehaus.org/display/MAVENUSER/Animal+Sniffer+Maven+Plugin}plugin's wiki page}}. In case you still have questions regarding the plugin's usage, please have a look at the {{{faq.html}FAQ}} and feel free to contact the {{{mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the {{{mail-lists.html}mail archive}}. If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in our {{{issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our {{{source-repository.html}source repository}} and will find supplementary information in the {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. * Examples To provide you with better understanding of some usages of Animal Sniffer, you can take a look into the following examples: * {{{examples/generating-java-signatures.html}Generating signatures of the Java Runtime}} * {{{examples/generating-other-api-signatures.html}Generating signatures of other APIs}} * {{{examples/checking-signatures.html}Checking a project against API signatures}} [] animal-sniffer-1.7/animal-sniffer-maven-plugin/src/site/apt/usage.apt.vm000066400000000000000000000115271163373477200263440ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Usage ----- Stephen Connolly ------ 2010-03-10 ------ Usage The plugin offers goals for checking projects against the signatures of an API as well as goals for generating signatures of APIs. * Basic Usage ** Checking a project against an API signature In order to check your project against an API signature, you must configure your <<>> to reference the signature to check against: --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ... org.codehaus.mojo.signature java15 1.0 ... ... ... ... ... --- The example above configures the signature for JRE 1.5. For a list of other ready-made signatures, please visit the {{{http://mojo.codehaus.org/signatures/}Animal Scents subproject}}. In order to check your project against the signature you have just configured, either invoke the <<>> goal directly, e.g. --- mvn animal-sniffer:check --- or to make the checks part of your build process add an execution to your configuration, e.g. --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ___id of execution___ ... test ... check ... ... ... ... ... --- <> If you are attaching the plugin to your build process, and you want to check against multiple separate APIs (e.g. check against the Tomcat, JBoss, and Jetty servlet containers, or check against multiple Java versions) then you will probably want to move the signature configuration inside each of your multiple executions otherwise your project will be checked against the union of all the signatures specified, which is probably not what you want. {{{examples/checking-signatures.html} Some more detailed examples of the <<>> goal}}. ** Generating API signatures To generate the signatures of an API, simply construct a project with the appropriate dependencies exposed by the API and then add an execution of the <<>> goal to your project, e.g. --- ... ... ... ${project.groupId} ${project.artifactId} ${project.version} ... ___id of execution___ ... package ... build ... ... ... ... ... --- For more detailed examples of how to configure this goal see: * {{{examples/generating-java-signatures.html}Generating signatures of the Java Runtime}} * {{{examples/generating-other-api-signatures.html}Generating signatures of other APIs}} [] animal-sniffer-1.7/animal-sniffer-maven-plugin/src/site/fml/000077500000000000000000000000001163373477200240755ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer-maven-plugin/src/site/fml/faq.fml000066400000000000000000000075631163373477200253570ustar00rootroot00000000000000 General What does the Animal Sniffer Maven Plugin do?

The Animal Sniffer Maven Plugin provides a means to verify that your classes only use the classes, methods and fields provided by specific API signatures that you specify. The plugin also provides a means to generate API signatures from your project and/or a specific JDK.

Why the name?

The plugin's original author (Kohsuke Kawaguchi) named the plugin animal-sniffer because it was originally designed to detect which version of a JRE had been used to compile your classes. As such it was detecting the "scent" of each JRE.

Sun has traditionally named each of the major versions of its JRE after different animals. For example 1.5 (a.k.a Java SE 5.0) was known as Tiger; 1.6 (a.k.a. Java SE 6.0) was known as Mustang. Since this plugin detects the "scent" of each of these "animals" it got the name "animal-sniffer".

Which is the "official" animal-sniffer host: Codehaus or java.net?

This project is the "official" project. The java.net project was started by Kohsuke Kawaguchi before he was granted commit access to the mojo project. Since Kohsuke was granted commit access in part to allow the migration of animal-sniffer to Codehaus, he has decreed the Codehaus version the "official" version as well as re-licensed the Codehaus version under the MIT License. The java.net version remains licensed under CDDL.

This version (by virtue of belonging to mojo.codehaus.org) has the advantage of being available in the Maven Central repository which means that projects which publish to the Maven Central repository can use this version in their pom.xml. Note: Projects which publish to the Maven Central repository must only reference dependencies and plugins available from the Maven Central repository and may not reference other repositories.

In addition, this version has been subject to on-going development effort.

animal-sniffer-1.7/animal-sniffer-maven-plugin/src/site/site.xml000066400000000000000000000040431163373477200250060ustar00rootroot00000000000000 animal-sniffer-1.7/animal-sniffer/000077500000000000000000000000001163373477200171645ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/pom.xml000066400000000000000000000045731163373477200205120ustar00rootroot00000000000000 4.0.0 org.codehaus.mojo animal-sniffer-parent 1.7 org.codehaus.mojo animal-sniffer jar Animal Sniffer Animal Sniffer. junit junit 3.8.1 test asm asm-all 3.3.1 maven-jar-plugin org.codehaus.mojo.animal_sniffer.Main animal-sniffer-1.7/animal-sniffer/src/000077500000000000000000000000001163373477200177535ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/000077500000000000000000000000001163373477200206775ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/java/000077500000000000000000000000001163373477200216205ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/java/org/000077500000000000000000000000001163373477200224075ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/000077500000000000000000000000001163373477200242025ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/000077500000000000000000000000001163373477200251465ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/animal_sniffer/000077500000000000000000000000001163373477200301235ustar00rootroot00000000000000ClassFileVisitor.java000066400000000000000000000102071163373477200341340ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/animal_snifferpackage org.codehaus.mojo.animal_sniffer; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; /** * @author Kohsuke Kawaguchi */ public abstract class ClassFileVisitor { /** * Whether to check inside .jar files */ private boolean checkJars = true; public boolean isCheckJars() { return checkJars; } public void setCheckJars( boolean checkJars ) { this.checkJars = checkJars; } /** * Multi-arg version of {@link #process(File)}. */ public void process( File[] files ) throws IOException { for ( int i = 0; i < files.length; i++ ) { process( files[i] ); } } /** * Recursively finds class files and invokes {@link #process(String, InputStream)} * * @param file Directory full of class files or jar files (in which case all of them are processed recursively), * or a class file (in which case that single class is processed), * or a jar file (in which case all the classes in this jar file are processed.) */ public void process( File file ) throws IOException { if ( file.isDirectory() ) { processDirectory( file ); } else if ( file.getName().endsWith( ".class" ) ) { processClassFile( file ); } else if ( file.getName().endsWith( ".jar" ) && checkJars ) { processJarFile( file ); } // ignore other files } protected void processDirectory( File dir ) throws IOException { File[] files = dir.listFiles(); if ( files == null ) { return; } process( files ); } protected void processJarFile( File file ) throws IOException { JarFile jar = new JarFile( file ); Enumeration e = jar.entries(); while ( e.hasMoreElements() ) { JarEntry x = (JarEntry) e.nextElement(); if ( !x.getName().endsWith( ".class" ) ) { continue; } InputStream is = jar.getInputStream( x ); try { process( file.getPath() + ':' + x.getName(), is ); } finally { is.close(); } } } protected void processClassFile( File file ) throws IOException { InputStream in = new FileInputStream( file ); try { process( file.getPath(), in ); } finally { in.close(); } } /** * @param name Displayable name to identify what class file we are processing * @param image Class file image. */ protected abstract void process( String name, InputStream image ) throws IOException; } ClassListBuilder.java000066400000000000000000000055171163373477200341270ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/animal_snifferpackage org.codehaus.mojo.animal_sniffer; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.codehaus.mojo.animal_sniffer.logging.Logger; import org.objectweb.asm.ClassReader; import org.objectweb.asm.commons.EmptyVisitor; import java.io.IOException; import java.io.InputStream; import java.util.HashSet; import java.util.Set; /** * List up classes seen. * * @author Kohsuke Kawaguchi */ public class ClassListBuilder extends ClassFileVisitor { private final Set packages; private final Logger logger; public Set getPackages() { return packages; } public ClassListBuilder( Set packages, Logger logger ) { this.packages = packages; this.logger = logger; } public ClassListBuilder( Logger logger ) { this( new HashSet(), logger ); } protected void process( String name, InputStream image ) throws IOException { try { ClassReader cr = new ClassReader( image ); cr.accept( new EmptyVisitor() { public void visit( int version, int access, String name, String signature, String superName, String[] interfaces ) { packages.add( name.replace( '/', '.' ) ); } }, 0 ); } catch ( ArrayIndexOutOfBoundsException e ) { logger.error( "Bad class file " + name ); // MANIMALSNIFFER-9 it is a pity that ASM does not throw a nicer error on encountering a malformed // class file. IOException ioException = new IOException( "Bad class file " + name ); ioException.initCause( e ); throw ioException; } } } animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/animal_sniffer/Clazz.java000066400000000000000000000102121163373477200320450ustar00rootroot00000000000000package org.codehaus.mojo.animal_sniffer; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import java.io.Serializable; import java.util.Arrays; import java.util.HashSet; import java.util.Set; /** * Represents a class signature. * * @author Kohsuke Kawaguchi */ public final class Clazz implements Serializable { /** * The name of the class. */ private final String name; /** * The set of methods and constants that form the signature of the class. */ private final Set signatures; /** * The superclass of the class. */ private final String superClass; /** * The list of interfaces implemented by the class. */ private final String[] superInterfaces; /** * Creates a new class signature. * * @param name the name of the class. * @param signatures the signatures. * @param superClass the superclass. * @param superInterfaces the interfaces implemented by the class. */ public Clazz( String name, Set signatures, String superClass, String[] superInterfaces ) { this.name = name; this.signatures = signatures; this.superClass = superClass; this.superInterfaces = (String[]) superInterfaces.clone(); } /** * Merges two class instances. * * @param defA the first instance. * @param defB the second instance * @throws ClassCastException if the two instances have different names or if the superclasses differ. */ public Clazz( Clazz defA, Clazz defB ) { if ( !defA.name.equals( defB.name ) ) { // nothing we can do... this is an invalid argument throw new ClassCastException( "Cannot merge different classes: " + defA.name + " and " + defB.name ); } if ( !defA.superClass.equals( defB.superClass ) ) { // nothing we can do... this is a breaking change throw new ClassCastException( "Cannot merger class " + defB.name + " as it has changed superclass:" ); } Set superInterfaces = new HashSet(); if ( defA.superInterfaces != null ) { superInterfaces.addAll( Arrays.asList( defA.superInterfaces ) ); } if ( defB.superInterfaces != null ) { superInterfaces.addAll( Arrays.asList( defB.superInterfaces ) ); } Set signatures = new HashSet(); signatures.addAll( defA.signatures ); signatures.addAll( defB.signatures ); this.name = defA.getName(); this.signatures = signatures; this.superClass = defA.superClass; this.superInterfaces = (String[]) superInterfaces.toArray( new String[superInterfaces.size()] ); } public String getName() { return name; } public Set getSignatures() { return signatures; } public String getSuperClass() { return superClass; } public String[] getSuperInterfaces() { return superInterfaces; } private static final long serialVersionUID = 1L; } animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/animal_sniffer/Main.java000066400000000000000000000101561163373477200316550ustar00rootroot00000000000000package org.codehaus.mojo.animal_sniffer; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import java.io.DataInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * @author Kohsuke Kawaguchi */ public class Main extends ClassFileVisitor { private boolean humanReadableName = false; private String maximumVersion = "00.0"; public static void main( String[] args ) throws IOException { if ( args.length == 0 ) { System.err.println( "Usage: java -jar animal-sniffer.jar [JAR/CLASS FILES]" ); System.err.println(" -h : show a human readable Java version number"); System.err.println(" -t N : return exit code 1 if any file has a class file version number > N"); System.exit( -1 ); } Main m = new Main(); String threshold = null; List files = new ArrayList(); for ( int i = 0; i < args.length; i++ ) { if (args[i].equals("-h")) { m.humanReadableName = true; continue; } if (args[i].equals("-t")) { threshold = args[++i]; for (Iterator j=HUMAN_READABLE_NAME.entrySet().iterator(); j.hasNext(); ) { Map.Entry v = ((Map.Entry)j.next()); if (v.getValue().equals(threshold)) { threshold = (String)v.getKey(); break; } } continue; } files.add(new File(args[i])); } for (int i = 0; i < files.size(); i++) { m.process((File) files.get(i)); } if (threshold!=null && m.maximumVersion.compareTo(threshold)>0) System.exit(1); } protected void process( String name, InputStream image ) throws IOException { DataInputStream dis = new DataInputStream( image ); byte[] buf = new byte[8]; dis.readFully( buf ); String v = u2(buf[6], buf[7]) + "." + u2(buf[4], buf[5]); if (maximumVersion.compareTo(v)<0) { maximumVersion = v; } if (humanReadableName) { String hn = (String)HUMAN_READABLE_NAME.get(v); if (hn!=null) v = hn; } System.out.println( v + " " + name ); } private static int u2( byte u, byte d ) { return ( (int) u ) * 256 + d; } private static final Map HUMAN_READABLE_NAME = new HashMap(); static { HUMAN_READABLE_NAME.put("45.0","Java1"); HUMAN_READABLE_NAME.put("46.0","Java2"); HUMAN_READABLE_NAME.put("47.0","Java3"); HUMAN_READABLE_NAME.put("48.0","Java4"); HUMAN_READABLE_NAME.put("49.0","Java5"); HUMAN_READABLE_NAME.put("50.0","Java6"); } } animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/animal_sniffer/RegexUtils.java000066400000000000000000000116341163373477200330660ustar00rootroot00000000000000package org.codehaus.mojo.animal_sniffer; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.regex.Pattern; /** * Utility methods to help with regex manipulation. * * @author Stephen Connolly * @since 1.3 */ public final class RegexUtils { /** * The end of a regex literal sequence. * * @since 1.3 */ public static final String REGEX_QUOTE_END = "\\E"; /** * The start of a regex literal sequence. * * @since 1.3 */ public static final String REGEX_QUOTE_START = "\\Q"; /** * Escape the escapes. * * @since 1.3 */ public static final String REGEX_QUOTE_END_ESCAPED = REGEX_QUOTE_END + '\\' + REGEX_QUOTE_END + REGEX_QUOTE_START; private RegexUtils() { throw new IllegalAccessError( "Utility classes should never be instantiated" ); } /** * Takes a string and returns the regex that will match that string exactly. * * @param s The string to match. * @return The regex that will match the string exactly. * @since 1.3 */ public static String quote( String s ) { int i = s.indexOf( REGEX_QUOTE_END ); if ( i == -1 ) { // we're safe as nobody has a crazy \E in the string return REGEX_QUOTE_START + s + REGEX_QUOTE_END; } // damn there's at least one \E in the string StringBuffer sb = new StringBuffer( s.length() + 32 ); // each escape-escape takes 10 chars... // hope there's less than 4 of them sb.append( REGEX_QUOTE_START ); int pos = 0; do { // we are safe from pos to i sb.append( s.substring( pos, i ) ); // now escape-escape sb.append( REGEX_QUOTE_END_ESCAPED ); // move the working start pos = i + REGEX_QUOTE_END.length(); i = s.indexOf( REGEX_QUOTE_END, pos ); } while ( i != -1 ); sb.append( s.substring( pos, s.length() ) ); sb.append( REGEX_QUOTE_END ); return sb.toString(); } /** * Converts a wildcard rule to a regex rule. * * @param wildcardRule the wildcard rule. * @param exactMatch true results in an regex that will match the entire string, while * false will match the start of the string. * @return The regex rule. */ public static String convertWildcardsToRegex( String wildcardRule, boolean exactMatch ) { StringBuffer regex = new StringBuffer(); int index = 0; final int len = wildcardRule.length(); while ( index < len ) { final int nextQ = wildcardRule.indexOf( '?', index ); final int nextS = wildcardRule.indexOf( '*', index ); if ( nextQ == -1 && nextS == -1 ) { regex.append( quote( wildcardRule.substring( index ) ) ); break; } int nextIndex; if ( nextQ == -1 ) { nextIndex = nextS; } else if ( nextS == -1 ) { nextIndex = nextQ; } else { nextIndex = Math.min( nextQ, nextS ); } if ( index < nextIndex ) { // we have some characters to match regex.append( quote( wildcardRule.substring( index, nextIndex ) ) ); } char c = wildcardRule.charAt( nextIndex ); if ( c == '?' ) { regex.append( '.' ); } else { regex.append( ".*" ); } index = nextIndex + 1; } if ( !exactMatch ) { regex.append( ".*" ); } return regex.toString(); } /** * Compiles a pattern matcher using wildcard based matching. * @param wildcard The wildcards rule to match. * @return A pattern to match the supplied wildcards rule. */ public static Pattern compileWildcard( String wildcard ) { return Pattern.compile( convertWildcardsToRegex( wildcard, true ) ); } } SignatureBuilder.java000066400000000000000000000167111163373477200341650ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/animal_snifferpackage org.codehaus.mojo.animal_sniffer; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.codehaus.mojo.animal_sniffer.logging.Logger; import org.codehaus.mojo.animal_sniffer.logging.PrintWriterLogger; import org.objectweb.asm.ClassReader; import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.commons.EmptyVisitor; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; /** * Builds up a signature list from the given classes. * * @author Kohsuke Kawaguchi */ public class SignatureBuilder extends ClassFileVisitor { private boolean foundSome; private final Logger logger; private List/**/ includeClasses; private List/**/ excludeClasses; private final Map classes = new TreeMap(); public static void main( String[] args ) throws IOException { SignatureBuilder builder = new SignatureBuilder( new FileOutputStream( "signature" ), new PrintWriterLogger( System.out ) ); builder.process( new File( System.getProperty( "java.home" ), "lib/rt.jar" ) ); builder.close(); } private final ObjectOutputStream oos; public SignatureBuilder( OutputStream out, Logger logger ) throws IOException { this( null, out, logger ); } public void addInclude( String className ) { if ( includeClasses == null ) { includeClasses = new ArrayList(); } includeClasses.add( RegexUtils.compileWildcard( className ) ); } public void addExclude( String className ) { if ( excludeClasses == null ) { excludeClasses = new ArrayList(); } excludeClasses.add( RegexUtils.compileWildcard( className ) ); } public SignatureBuilder( InputStream[] in, OutputStream out, Logger logger ) throws IOException { this.logger = logger; if ( in != null ) { for ( int i = 0; i < in.length; i++ ) { ObjectInputStream ois = new ObjectInputStream( new GZIPInputStream( in[i] ) ); try { while ( true ) { Clazz c = (Clazz) ois.readObject(); if ( c == null ) { break; // finished } classes.put( c.getName(), c ); } } catch ( ClassNotFoundException e ) { final IOException ioException = new IOException( "Could not read base signatures" ); ioException.initCause( e ); throw ioException; } finally { ois.close(); } } } oos = new ObjectOutputStream( new GZIPOutputStream( out ) ); } public void close() throws IOException { int count = 0; Iterator i = classes.entrySet().iterator(); while ( i.hasNext() ) { Map.Entry entry = (Map.Entry) i.next(); final String className = ( (String) entry.getKey() ).replace( '/', '.' ); if ( includeClasses != null ) { boolean included = false; Iterator j = includeClasses.iterator(); while ( !included && j.hasNext() ) { Pattern p = (Pattern) j.next(); included = p.matcher( className ).matches(); } if ( !included ) { continue; } } if ( excludeClasses != null ) { boolean excluded = false; Iterator j = excludeClasses.iterator(); while ( !excluded && j.hasNext() ) { Pattern p = (Pattern) j.next(); excluded = p.matcher( className ).matches(); } if ( excluded ) { continue; } } count++; logger.debug( className ); oos.writeObject( entry.getValue() ); } oos.writeObject( null ); // EOF marker logger.info( "Wrote signatures for " + count + " classes." ); oos.close(); if ( !foundSome ) { throw new IOException( "No index is written" ); } } protected void process( String name, InputStream image ) throws IOException { logger.debug( name ); foundSome = true; ClassReader cr = new ClassReader( image ); SignatureVisitor v = new SignatureVisitor(); cr.accept( v, 0 ); v.end(); } private class SignatureVisitor extends EmptyVisitor { private Clazz clazz; public void visit( int version, int access, String name, String signature, String superName, String[] interfaces ) { this.clazz = new Clazz( name, new HashSet(), superName, interfaces ); } public void end() throws IOException { Clazz cur = (Clazz) classes.get( clazz.getName() ); if ( cur == null ) { classes.put( clazz.getName(), clazz ); } else { classes.put( clazz.getName(), new Clazz( clazz, cur ) ); } } public MethodVisitor visitMethod( int access, String name, String desc, String signature, String[] exceptions ) { clazz.getSignatures().add( name + desc ); return null; } public FieldVisitor visitField( int access, String name, String desc, String signature, Object value ) { clazz.getSignatures().add( name + "#" + desc ); return null; } } } SignatureChecker.java000066400000000000000000000271071163373477200341440ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/animal_snifferpackage org.codehaus.mojo.animal_sniffer; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.codehaus.mojo.animal_sniffer.logging.Logger; import org.codehaus.mojo.animal_sniffer.logging.PrintWriterLogger; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.ClassReader; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.commons.EmptyVisitor; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; /** * Checks the signature against classes in this list. * * @author Kohsuke Kawaguchi */ public class SignatureChecker extends ClassFileVisitor { private final Map/**/ classes = new HashMap(); private final Logger logger; /** * Classes in this packages are considered to be resolved elsewhere and * thus not a subject of the error checking when referenced. */ private final List ignoredPackageRules; private final Set ignoredPackages; private boolean hadError = false; public static void main( String[] args ) throws Exception { Set ignoredPackages = new HashSet(); ignoredPackages.add( "org.jvnet.animal_sniffer.*" ); ignoredPackages.add( "org.codehaus.mojo.animal_sniffer.*" ); ignoredPackages.add( "org.objectweb.*" ); new SignatureChecker( new FileInputStream( "signature" ), ignoredPackages, new PrintWriterLogger( System.out ) ).process( new File( "target/classes" ) ); } public SignatureChecker( InputStream in, Set ignoredPackages, Logger logger ) throws IOException { this.ignoredPackages = new HashSet(); this.ignoredPackageRules = new LinkedList(); Iterator i = ignoredPackages.iterator(); while ( i.hasNext() ) { String wildcard = (String) i.next(); if ( wildcard.indexOf( '*' ) == -1 && wildcard.indexOf( '?' ) == -1 ) { this.ignoredPackages.add( wildcard.replace( '.', '/' ) ); } else { this.ignoredPackageRules.add( newMatchRule( wildcard.replace( '.', '/' ) ) ); } } this.logger = logger; ObjectInputStream ois = null; try { ois = new ObjectInputStream( new GZIPInputStream( in ) ); while ( true ) { Clazz c = (Clazz) ois.readObject(); if ( c == null ) { return; // finished } classes.put( c.getName(), c ); } } catch ( ClassNotFoundException e ) { throw new NoClassDefFoundError( e.getMessage() ); } finally { if ( ois != null ) { try { ois.close(); } catch ( IOException e ) { // ignore } } } } protected void process( final String name, InputStream image ) throws IOException { ClassReader cr = new ClassReader( image ); try { cr.accept( new CheckingVisitor( name ), 0 ); } catch ( ArrayIndexOutOfBoundsException e ) { logger.error( "Bad class file " + name ); // MANIMALSNIFFER-9 it is a pity that ASM does not throw a nicer error on encountering a malformed // class file. IOException ioException = new IOException( "Bad class file " + name ); ioException.initCause( e ); throw ioException; } } private static interface MatchRule { boolean matches( String text ); } private static class PrefixMatchRule implements SignatureChecker.MatchRule { private final String prefix; public PrefixMatchRule( String prefix ) { this.prefix = prefix; } public boolean matches( String text ) { return text.startsWith( prefix ); } } private static class ExactMatchRule implements SignatureChecker.MatchRule { private final String match; public ExactMatchRule( String match ) { this.match = match; } public boolean matches( String text ) { return match.equals( text ); } } private static class RegexMatchRule implements SignatureChecker.MatchRule { private final Pattern regex; public RegexMatchRule( Pattern regex ) { this.regex = regex; } public boolean matches( String text ) { return regex.matcher( text ).matches(); } } private SignatureChecker.MatchRule newMatchRule( String matcher ) { int i = matcher.indexOf( '*' ); if ( i == -1 ) { return new ExactMatchRule( matcher ); } if ( i == matcher.length() - 1 ) { return new PrefixMatchRule( matcher.substring( 0, i ) ); } return new RegexMatchRule( RegexUtils.compileWildcard( matcher ) ); } public boolean isSignatureBroken() { return hadError; } private class CheckingVisitor extends EmptyVisitor { private final Set ignoredPackageCache; private final Set warned; private final String name; public CheckingVisitor( String name ) { this.ignoredPackageCache = new HashSet( 50 * ignoredPackageRules.size() ); this.warned = new HashSet(); this.name = name; } public MethodVisitor visitMethod( int access, String name, String desc, String signature, String[] exceptions ) { return new EmptyVisitor() { /** * True if @IgnoreJRERequirement is set. */ boolean ignoreError = false; public AnnotationVisitor visitAnnotation( String desc, boolean visible ) { if ( desc.equals( "Lorg/jvnet/animal_sniffer/IgnoreJRERequirement;" ) ) { ignoreError = true; } if ( desc.equals( "Lorg/codehaus/mojo/animal_sniffer/IgnoreJRERequirement;" ) ) { ignoreError = true; } return super.visitAnnotation( desc, visible ); } public void visitMethodInsn( int opcode, String owner, String name, String desc ) { check( owner, name + desc ); } public void visitTypeInsn( int opcode, String type ) { if ( shouldBeIgnored( type ) ) { return; } if ( type.charAt( 0 ) == '[' ) { return; // array } Clazz sigs = (Clazz) classes.get( type ); if ( sigs == null ) { error( "Undefined reference: " + type ); } } public void visitFieldInsn( int opcode, String owner, String name, String desc ) { check( owner, name + '#' + desc ); } private void check( String owner, String sig ) { if ( shouldBeIgnored( owner ) ) { return; } if ( find( (Clazz) classes.get( owner ), sig ) ) { return; // found it } error( "Undefined reference: " + owner + '.' + sig ); } private boolean shouldBeIgnored( String type ) { if ( ignoreError ) { return true; // warning suppressed in this context } if ( type.charAt( 0 ) == '[' ) { return true; // array } if ( ignoredPackages.contains( type ) || ignoredPackageCache.contains( type ) ) { return true; } Iterator i = ignoredPackageRules.iterator(); while ( i.hasNext() ) { MatchRule rule = (MatchRule) i.next(); if ( rule.matches( type ) ) { ignoredPackageCache.add( type ); return true; } } return false; } }; } /** * If the given signature is found in the specified class, return true. */ private boolean find( Clazz c, String sig ) { if ( c == null ) { return false; } if ( c.getSignatures().contains( sig ) ) { return true; } if ( sig.startsWith( "<" ) ) // constructor and static initializer shouldn't go up the inheritance hierarchy { return false; } if ( find( (Clazz) classes.get( c.getSuperClass() ), sig ) ) { return true; } if ( c.getSuperInterfaces() != null ) { for ( int i = 0; i < c.getSuperInterfaces().length; i++ ) { if ( find( (Clazz) classes.get( c.getSuperInterfaces()[i] ), sig ) ) { return true; } } } return false; } private void error( String msg ) { hadError = true; if ( warned.add( msg ) ) { logger.error( msg + " in " + name ); } } } } SignatureMerger.java000066400000000000000000000070121163373477200340120ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/animal_snifferpackage org.codehaus.mojo.animal_sniffer; /* * The MIT License * * Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import org.codehaus.mojo.animal_sniffer.logging.Logger; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; /** * Merges signature files. * * @author Stephen Connolly */ public class SignatureMerger { private final Map/**/ classes = new HashMap(); private final Logger logger; public static void main( String[] args ) throws Exception { // TODO add command arg parsing // new SignatureMerger( new FileInputStream( "signature" ), ignoredPackages, // new PrintWriterLogger( System.out ) ).process( new File( "target/classes" ) ); } public SignatureMerger( InputStream[] in, OutputStream out, Logger logger ) throws IOException { this.logger = logger; for ( int i = 0; i < in.length; i++ ) { try { ObjectInputStream ois = new ObjectInputStream( new GZIPInputStream( in[i] ) ); while ( true ) { Clazz c = (Clazz) ois.readObject(); if ( c == null ) { return; // finished } Clazz cur = (Clazz) classes.get( c.getName() ); if ( cur == null ) { classes.put( c.getName(), c ); } else { classes.put( c.getName(), new Clazz( c, cur ) ); } } } catch ( ClassNotFoundException e ) { throw new NoClassDefFoundError( e.getMessage() ); } } ObjectOutputStream oos = new ObjectOutputStream( new GZIPOutputStream( out ) ); Iterator i = classes.entrySet().iterator(); while ( i.hasNext() ) { Map.Entry entry = (Map.Entry) i.next(); logger.info( (String) entry.getKey() ); oos.writeObject( entry.getValue() ); } oos.writeObject( null ); // EOF marker oos.close(); } }animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/animal_sniffer/logging/000077500000000000000000000000001163373477200315515ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/animal_sniffer/logging/Logger.java000066400000000000000000000032141163373477200336330ustar00rootroot00000000000000package org.codehaus.mojo.animal_sniffer.logging; /* * The MIT License * * Copyright (c) 2009, codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ /** * Abstracts out logging so that the different logging providers (eg ANT or Maven) can be plugged in. * * @author connollys * @since 1.3 */ public interface Logger { void info( String message ); void info( String message, Throwable t ); void debug( String message ); void debug( String message, Throwable t ); void warn( String message ); void warn( String message, Throwable t ); void error( String message ); void error( String message, Throwable t ); } PrintWriterLogger.java000066400000000000000000000052631163373477200357740ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/main/java/org/codehaus/mojo/animal_sniffer/loggingpackage org.codehaus.mojo.animal_sniffer.logging; /* * The MIT License * * Copyright (c) 2009, codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import java.io.StringWriter; import java.io.PrintWriter; import java.io.PrintStream; /** * Default implementation that sends output to a print writer * * @author connollys * @since 1.3 */ public final class PrintWriterLogger implements Logger { private final PrintStream destination; public PrintWriterLogger( PrintStream destination ) { this.destination = destination; } public void info( String message ) { output( "[INFO]", message, null ); } public void info( String message, Throwable t ) { output( "[INFO]", message, t ); } public void debug( String message ) { } public void debug( String message, Throwable t ) { } public void warn( String message ) { output( "[WARN]", message, null ); } public void warn( String message, Throwable t ) { output( "[WARN]", message, t ); } public void error( String message ) { output( "[ERROR]", message, null ); } public void error( String message, Throwable t ) { output( "[ERROR]", message, t ); } private void output( String prefix, String message, Throwable t ) { StringWriter w = new StringWriter( ); PrintWriter pw = new PrintWriter( w ); pw.print( prefix ); pw.print( ' ' ); pw.println( message ); if ( t != null ) { t.printStackTrace( pw ); } pw.close(); destination.print( w.toString() ); destination.flush(); } } animal-sniffer-1.7/animal-sniffer/src/site/000077500000000000000000000000001163373477200207175ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/site/apt/000077500000000000000000000000001163373477200215035ustar00rootroot00000000000000animal-sniffer-1.7/animal-sniffer/src/site/apt/index.apt.vm000066400000000000000000000116431163373477200237460ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Animal Sniffer ----- Stephen Connolly ----- 2009-10-01 ----- Animal Sniffer Animal Sniffer provides tools to assist verifying that classes compiled with a newer JDK/API are compatible with an older JDK/API. * CLI overview The CLI has the following functionality: * {{{usage.html}Display the target class version of classes}} to help you track down the offending jar file when you see <<>>. [] * API overview Animal-sniffer also provides an API for verifying and compiling API signatures. This API is used by {{{../animal-sniffer-ant-tasks/index.html} the ANT tasks}}, {{{../animal-sniffer-enforcer-rule} the maven enforcer rule}}, and {{{../../animal-sniffer-maven-plugin} the Maven plugin}}. If these tools are not sufficient to your needs, then the two entry points to the API are: * {{{apidocs/org/codehaus/mojo/animal_sniffer/SignatureChecker.html}SignatureChecker}} is used to check classes against a specific signature. * {{{apidocs/org/codehaus/mojo/animal_sniffer/SignatureBuilder.html}SignatureBuilder}} is used to build signatures from a collection of classes. [] * Usage General instructions on how to use the Animal Sniffer API can be found on the {{{usage.html}usage page}}. Some more specific use cases are described in the examples given below. Last but not least, users occasionally contribute additional examples, tips or errata to the {{{http://docs.codehaus.org/display/MAVENUSER/Animal_Sniffer}animal-sniffer's wiki page}}. In case you still have questions regarding the plugin's usage, please have a look at the {{{faq.html}FAQ}} and feel free to contact the {{{mail-lists.html}user mailing list}}. The posts to the mailing list are archived and could already contain the answer to your question as part of an older thread. Hence, it is also worth browsing/searching the {{{mail-lists.html}mail archive}}. If you feel like animal-sniffer is missing a feature or has a defect, you can fill a feature request or bug report in our {{{issue-tracking.html}issue tracker}}. When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from our {{{source-repository.html}source repository}} and will find supplementary information in the {{{http://maven.apache.org/guides/development/guide-helping.html}guide to helping with Maven}}. * Examples This CLI tool can accept any number of: * Class files * Jar files * Directories [] When directories are given, they are recursively scanned for class files and jar files. When jar files are given, class files in it is examined. The tool produces output like the following, so use the grep command to filter out the list: ----------------------------- % java -jar ${project.artifactId}-${project.version}.jar tmp 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/AbstractCreator.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/AbstractCreatorProcessor.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/AbstractProcessor.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/AttributesHolder.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/FragmentedArray.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/MutableXMLStreamBuffer.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/XMLStreamBuffer.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/XMLStreamBufferException.class ----------------------------- animal-sniffer-1.7/animal-sniffer/src/site/apt/signature-checker.apt000066400000000000000000000143111163373477200256140ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Signature Checker ----- Kohsuke Kawaguchi ----- 2008-11-15 ----- What is this? It's common for a Java project to compile with later versions of JDK than it minimally requires. For example, when Hudson runs on Java6 it takes advantages of those features, but it can also run on Java5 without those advanced features. The technique to do this is well understood. Here's one such code fragment taken from Hudson: ----------------- try { for (ThreadInfo ti : Functions.getThreadInfos()) r.put(ti.getThreadName(),Functions.dumpThreadInfo(ti)); } catch (LinkageError _) { // not in JDK6. fall back to JDK5 ... } ----------------- This is desirable, since you can take advantages of the latest JavaSE features without forcing users to upgrade. The problem is that you now need to compile with JDK6, so when other parts of code accidentally depends on new additions in Java6 and breaks the minimum Java5 requirement, your build process won't complain. If you are lucky, your tests will catch it, but no test attain 100% of code coverage, so there's still a good chance that such a problem slips into the production code. (For example, I've been bitten a few times by using <<>> constructor that was added in 1.6, since I typically use it only in handling errors that tend not to be tested well.) Animal sniffer to the rescue The idea of the tool is simple. I first run a "signature builder" with various versions of JREs, capturing all the method and field signatures from them. Those are then uploaded into a Maven repository to be downloaded later by your Maven. I then wrote a separate tool called "signature checker", which uses this signature file and inspect your classes. If your classes depend on things that don't exist in the signature list, you get an error message. This tool is packaged up as a Maven plugin, so to use this, you just add the following snippet inside your \ element in <<>>: ----------------- org.jvnet animal-sniffer 1.2 check org.jvnet.animal-sniffer java1.5 1.0 ----------------- The nested \ element specifies the signature list to use. In addition to java1.5, {{{http://maven.dyndns.org/2/org/jvnet/animal-sniffer/}java1.3, java1.4, and java1.6 available}}. Running this less often If you don't want to do this for every Maven build, you can instead have the following snippet: ----------------- org.jvnet animal-sniffer 1.2 org.jvnet.animal-sniffer java1.5 1.0 ----------------- And then you can run <<>> to check the dependency, or you can further add the following POM snippet so that the check is performed automatically during a release: ----------------- maven-release-plugin install animal-sniffer:check deploy ----------------- The tool uses ASM and statically analyze the code, so it doesn't miss any reference, unlike test based approach. Marking dependencies explicitly Now, in the places where you knowingly use features that go beyond the minimum requirement, you put the <<<@IgnoreJRERequirement>>> annotation on a method. This is a signal from you to the checker that you're aware of the dependency there and you know what you are doing. For this code to compile, you need to add <<>> to the dependency list. This annotation is configured as <<<@Retention(CLASS)>>>, so you don't need this jar to be at runtime. To tell Maven not to put it in the runtime, this fragment includes <<<\true\ >>>: ----------------- org.jvnet animal-sniffer 1.2 true ----------------- There are certain edge cases that this tool doesn't handle correctly (like the case when a visibility of a method changes from 'protected' to 'public' between Java5 to Java6 --- not that I know such a case exists), but I think it runs pretty well, at least on Hudson, and the added peace of mind is priceless. As usual, I'm always looking for more people to work on any of my projects, so if you are interested, please send me an e-mail, and you'll be a committer right away. animal-sniffer-1.7/animal-sniffer/src/site/apt/usage.apt.vm000066400000000000000000000051401163373477200237360ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2008 Kohsuke Kawaguchi and codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Animal Sniffer CLI ----- Kohsuke Kawaguchi ----- 2008-11-15 ----- What is this? This simple command line tool looks at Java class files and determine the format version number. The common use case of this tool is to figure out what is the offending jar file when you see <<>>. Usage This tool can accept any number of: * Class files * Jar files * Directories [] When directories are given, they are recursively scanned for class files and jar files. When jar files are given, class files in it is examined. The tool produces output like the following, so use the grep command to filter out the list: ----------------------------- % java -jar target/animal-sniffer-1.0-SNAPSHOT.jar tmp 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/AbstractCreator.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/AbstractCreatorProcessor.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/AbstractProcessor.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/AttributesHolder.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/FragmentedArray.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/MutableXMLStreamBuffer.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/XMLStreamBuffer.class 50.0 tmp/streambuffer-0.7.jar:com/sun/xml/stream/buffer/XMLStreamBufferException.class ----------------------------- animal-sniffer-1.7/animal-sniffer/src/site/site.xml000066400000000000000000000024141163373477200224060ustar00rootroot00000000000000 animal-sniffer-1.7/java-boot-classpath-detector/000077500000000000000000000000001163373477200217425ustar00rootroot00000000000000animal-sniffer-1.7/java-boot-classpath-detector/pom.xml000066400000000000000000000046071163373477200232660ustar00rootroot00000000000000 4.0.0 org.codehaus.mojo animal-sniffer-parent 1.7 org.codehaus.mojo java-boot-classpath-detector jar Java boot classpath detector Queries a java home in order to find its boot class path. maven-jar-plugin true org.codehaus.mojo.animal_sniffer.jbcpd.ShowClassPath maven-compiler-plugin 1.2 1.2 animal-sniffer-1.7/java-boot-classpath-detector/src/000077500000000000000000000000001163373477200225315ustar00rootroot00000000000000animal-sniffer-1.7/java-boot-classpath-detector/src/main/000077500000000000000000000000001163373477200234555ustar00rootroot00000000000000animal-sniffer-1.7/java-boot-classpath-detector/src/main/java/000077500000000000000000000000001163373477200243765ustar00rootroot00000000000000animal-sniffer-1.7/java-boot-classpath-detector/src/main/java/org/000077500000000000000000000000001163373477200251655ustar00rootroot00000000000000animal-sniffer-1.7/java-boot-classpath-detector/src/main/java/org/codehaus/000077500000000000000000000000001163373477200267605ustar00rootroot00000000000000animal-sniffer-1.7/java-boot-classpath-detector/src/main/java/org/codehaus/mojo/000077500000000000000000000000001163373477200277245ustar00rootroot00000000000000animal-sniffer-1.7/java-boot-classpath-detector/src/main/java/org/codehaus/mojo/animal_sniffer/000077500000000000000000000000001163373477200327015ustar00rootroot00000000000000000077500000000000000000000000001163373477200337045ustar00rootroot00000000000000animal-sniffer-1.7/java-boot-classpath-detector/src/main/java/org/codehaus/mojo/animal_sniffer/jbcpdShowClassPath.java000066400000000000000000000115761163373477200373040ustar00rootroot00000000000000animal-sniffer-1.7/java-boot-classpath-detector/src/main/java/org/codehaus/mojo/animal_sniffer/jbcpdpackage org.codehaus.mojo.animal_sniffer.jbcpd; /* * The MIT License * * Copyright (c) 2009 codehaus.org. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ import java.io.File; import java.io.IOException; import java.util.Enumeration; public final class ShowClassPath { public static void main(String[] args) { String cp = System.getProperty("sun.boot.class.path"); if (cp != null) { System.out.println(cp); return; } cp = System.getProperty("java.boot.class.path"); if (cp != null) { System.out.println(cp); return; } Enumeration i = System.getProperties().propertyNames(); String name = null; while (i.hasMoreElements()) { String temp = (String) i.nextElement(); if (temp.indexOf(".boot.class.path") != -1) { if (name == null) { name = temp; } else { System.err.println("Cannot auto-detect boot class path " + System.getProperty("java.version")); System.exit(1); } } } if (name == null) { String version = System.getProperty("java.version"); if (version.startsWith("1.1.")) { // by default, the current directory is added to the classpath // we therefore need to strip that out cp = System.getProperty("java.class.path"); cp = removeAll(cp, "."); cp = removeAll(cp, new File(".").getAbsolutePath()); try { cp = removeAll(cp, new File(".").getCanonicalPath()); } catch (IOException e) { // ignore } cp = removeAll(cp, new File(".").getAbsolutePath() + System.getProperty("file.separator")); try { cp = removeAll(cp, new File(".").getCanonicalPath() + System.getProperty("file.separator")); } catch (IOException e) { // ignore } System.out.println(cp); return; } System.err.println("Cannot auto-detect boot class path " + System.getProperty("java.version") + " " + System.getProperty("java.class.path")); System.exit(1); } System.out.println(System.getProperty(name)); } private static boolean isWindows() { return System.getProperty("os.name").toUpperCase().startsWith("WINDOWS"); } private static String removeAll(String cp, String prefix) { String pathSeparator = System.getProperty("path.separator"); if (cp.startsWith(prefix + pathSeparator)) { cp = cp.substring(prefix.length() + pathSeparator.length()); } int j; while (-1 != (j = cp.indexOf(pathSeparator + prefix + pathSeparator))) { cp = cp.substring(0, j) + cp.substring(j + prefix.length() + pathSeparator.length()); } if (cp.endsWith(pathSeparator + prefix)) { cp = cp.substring(0, cp.length() - prefix.length() + pathSeparator.length()); } if (isWindows()) { // we might have the prefix or the classpath case differing if (cp.toUpperCase().startsWith((prefix + pathSeparator).toUpperCase())) { cp = cp.substring(prefix.length() + pathSeparator.length()); } while (-1 != (j = cp.toUpperCase().indexOf((pathSeparator + prefix + pathSeparator).toUpperCase()))) { cp = cp.substring(0, j) + cp.substring(j + prefix.length() + pathSeparator.length()); } if (cp.toUpperCase().endsWith((pathSeparator + prefix).toUpperCase())) { cp = cp.substring(0, cp.length() - prefix.length() + pathSeparator.length()); } } return cp; } } animal-sniffer-1.7/java-boot-classpath-detector/src/site/000077500000000000000000000000001163373477200234755ustar00rootroot00000000000000animal-sniffer-1.7/java-boot-classpath-detector/src/site/apt/000077500000000000000000000000001163373477200242615ustar00rootroot00000000000000animal-sniffer-1.7/java-boot-classpath-detector/src/site/apt/index.apt.vm000066400000000000000000000045331163373477200265240ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ------ Introduction ------ Stephen Connolly ------ 2009-11-08 ------ Java Boot Classpath Detector The Java Boot Classpath Detector is an executable jar file which tries to determine the boot classpath of the Java Runtime and outputs that classpath to the standard output. It is used by the Animal Sniffer Maven Plugin to autodetect the boot classpath of Java Runtimes. It is known to work with most Java versions 1.2 or newer from most vendors. * Usage Just execute the jar file, e.g. --- java -jar ${project.artifactId}-${project.version}.jar --- If successful the process should return with exit code 0 and the output should be the boot classpath as a single line with each element separated by <<>>. For example, on linux you might get output like: --- /home/user/bin/jdk1.6.0_16/jre/lib/resources.jar:/home/user/bin/jdk1.6.0_16/jre/lib/rt.jar:/home/user/bin/jdk1.6.0_16/jre/lib/sunrsasign.jar:/home/user/bin/jdk1.6.0_16/jre/lib/jsse.jar:/home/user/bin/jdk1.6.0_16/jre/lib/jce.jar:/home/user/bin/jdk1.6.0_16/jre/lib/charsets.jar:/home/user/bin/jdk1.6.0_16/jre/classes --- A non-zero exit code indicates that the boot classpath could not be reliably determined. animal-sniffer-1.7/java-boot-classpath-detector/src/site/site.xml000066400000000000000000000024771163373477200251750ustar00rootroot00000000000000 animal-sniffer-1.7/pom.xml000066400000000000000000000102471163373477200156120ustar00rootroot00000000000000 4.0.0 org.codehaus.mojo mojo-parent 28 org.codehaus.mojo animal-sniffer-parent 1.7 pom Animal Sniffer Animal Sniffer Parent project. http://mojo.codehaus.org/animal-sniffer codehaus.org Mojo Website dav:https://dav.codehaus.org/mojo/animal-sniffer java-boot-classpath-detector animal-sniffer-annotations animal-sniffer animal-sniffer-maven-plugin animal-sniffer-enforcer-rule animal-sniffer-ant-tasks 2008 MIT license http://www.opensource.org/licenses/mit-license.php repo jira http://jira.codehaus.org/browse/MANIMALSNIFFER scm:svn:https://svn.codehaus.org/mojo/tags/animal-sniffer-parent-1.7 scm:svn:https://svn.codehaus.org/mojo/tags/animal-sniffer-parent-1.7 http://fisheye.codehaus.org/browse/mojo/tags/animal-sniffer-parent-1.7 Kohsuke Kaw kohsuke (dot) kawaguchi (at) sun (dot) com Lead Developer -8 Stephen Connolly stephen (dot) alan (dot) connolly (at) gmail (dot) com Developer 0 maven-invoker-plugin 1.4 src/it ${project.build.directory}/it ${project.build.directory}/local-repo src/it/settings.xml true true verify.bsh animal-sniffer-1.7/src/000077500000000000000000000000001163373477200150605ustar00rootroot00000000000000animal-sniffer-1.7/src/site/000077500000000000000000000000001163373477200160245ustar00rootroot00000000000000animal-sniffer-1.7/src/site/apt/000077500000000000000000000000001163373477200166105ustar00rootroot00000000000000animal-sniffer-1.7/src/site/apt/index.apt000066400000000000000000000102371163373477200204300ustar00rootroot00000000000000 ~~ The MIT License ~~ ~~ Copyright (c) 2009 codehaus.org. ~~ ~~ Permission is hereby granted, free of charge, to any person obtaining a copy ~~ of this software and associated documentation files (the "Software"), to deal ~~ in the Software without restriction, including without limitation the rights ~~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~~ copies of the Software, and to permit persons to whom the Software is ~~ furnished to do so, subject to the following conditions: ~~ ~~ The above copyright notice and this permission notice shall be included in ~~ all copies or substantial portions of the Software. ~~ ~~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~~ THE SOFTWARE. ~~ ----- Animal Sniffer ----- Stephen Connolly ----- 2009-10-01 ----- Animal Sniffer Animal Sniffer provides tools to assist verifying that classes compiled with a newer JDK/API are compatible with an older JDK/API. * Introduction What happens if you compile a program written with a version of an API that is different from the version you are targetting? Well the answer depends on a number of things. * Firstly we will assume that the API has an evolution contract, i.e., if a class or method or field is present in version v1, it will also be present in version v2 providing v1 is less than or equal to v2. A good example of this is the Java Runtime Library (a.k.a the JRE) * If you are compiling with a newer version of the API, you should not get any compiler errors. * If you are compiling with an older version of the API, and you have only used those features in the older version of the API, you should not get any compiler errors. * If you are compiling with an older version of the API, and you have used some features only available in the newer version, you will get a compiler error. [] If you are developing a project which must support running on JDK version 1.4, but your development system does not have a JDK version 1.4 available, it can be quite easy to accidentally use methods or classes that are only available in the newer version of the JDK. For example, if you are developing a plugin for Maven 2.0.x on a newer Macintosh. Animal sniffer can check the classes and method signatures that your compiled code uses and verify that you have use only those classes and signatures available in the API you are targetting. * Why the name? Sun gives each of the JDK versions codenames. Most of these codenames are animal names. Animal-sniffer was concieved as a utility to see what "animal" your code can run on. * What does animal-sniffer provide? The following tools are provided by animal sniffer: * {{{animal-sniffer/index.html}A command line tool to dump the class file version number}}. This helps you track down the offending jar file when you see <<>>. * {{{animal-sniffer-ant-tasks/index.html}A set of ANT tasks}} for verifying that your classes comply with an API signature as well as tasks for creating API signatures from a JDK, or a collection or jar and class files, or a collection of other API signature files, or combination of these elements. * {{{animal-sniffer-enforcer-rule/index.html}A rule for use in the maven-enforcer-plugin}} for verifying that your classes comply with an API signature . * {{{../animal-sniffer-maven-plugin/index.html}A maven plugin}} for verifying that your classes comply with an API signature as well as for creating API signatures from a JDK, or the current module's classes, or the current module's dependencies, or a collection of other API signature files, or combination of these elements. [] animal-sniffer-1.7/src/site/site.xml000066400000000000000000000036121163373477200175140ustar00rootroot00000000000000