-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://svn.codehaus.org/mojo/trunk@13757 52ab4f32-60fc-0310-b215-8acea882cd1b
- Loading branch information
olamy
committed
Mar 15, 2011
0 parents
commit a7c56a1
Showing
10,061 changed files
with
1,014,407 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>animal-sniffer-parent</artifactId> | ||
<version>1.7-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>animal-sniffer-annotations</artifactId> | ||
|
||
<name>Animal Sniffer Annotations</name> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-enforcer-plugin</artifactId> | ||
<version>1.0-beta-1</version> | ||
<executions> | ||
<execution> | ||
<id>enforce-java</id> | ||
<goals> | ||
<goal>enforce</goal> | ||
</goals> | ||
<configuration> | ||
<rules> | ||
<requireJavaVersion> | ||
<message>Annotations require Java 1.5+ to compile</message> | ||
<version>[1.5,)</version> | ||
</requireJavaVersion> | ||
</rules> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.5</source> | ||
<target>1.5</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
42 changes: 42 additions & 0 deletions
42
...ffer-annotations/src/main/java/org/codehaus/mojo/animal_sniffer/IgnoreJRERequirement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package 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 | ||
{ | ||
} |
147 changes: 147 additions & 0 deletions
147
mojo/animal-sniffer/animal-sniffer-annotations/src/site/apt/index.apt.vm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
~~ 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 <<<java.awt.SplashScreen>>>. | ||
In these cases you would wrap the use of the newer classes inside a <<<try ... catch (LinkageError e)>>> 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 <<<org.jvnet:animal-sniffer-annotation:1.0>>> 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 | ||
<<<animal-sniffer-annotations>>>, (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> | ||
... | ||
<dependencies> | ||
... | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>${project.artifactId}</artifactId> | ||
<version>${project.version}</version> | ||
<optional>true</optional> | ||
<!-- if you are using badly written maven plugins then blame them and add | ||
<scope>provided</scope> | ||
--> | ||
</dependency> | ||
... | ||
</dependencies> | ||
... | ||
<build> | ||
... | ||
<plugins> | ||
... | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
... | ||
<configuration> | ||
... | ||
<source>1.5</source> | ||
<target>1.5</target> | ||
... | ||
</configuration> | ||
... | ||
</plugin> | ||
... | ||
</plugins> | ||
... | ||
</project> | ||
--- | ||
|
||
|
33 changes: 33 additions & 0 deletions
33
mojo/animal-sniffer/animal-sniffer-annotations/src/site/site.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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. | ||
--> | ||
<project> | ||
<body> | ||
<menu ref="parent"/> | ||
<menu name="Overview"> | ||
<item name="Introduction" href="index.html"/> | ||
</menu> | ||
<menu ref="reports"/> | ||
</body> | ||
</project> |
Oops, something went wrong.