Skip to content

Commit cb594d2

Browse files
committed
Merge branch 'master' of 'scijava/annindex' into HEAD
SciJava-common makes use of annotations to be able to index classes to provide a powerful plugin framework that allows for a flexible extension mechanism by using annotation indexes generated at compile time, and stored inside the artifacts. SciJava-common used to rely on SezPoz for that, but we are switching to our own, custom annotation indexer for the following reasons: - we need better support for Eclipse (which does not run annotation processors in incremental compilation mode) - we need a more robust data format (annotation indexes written out with SezPoz using an Oracle JDK cannot be read back using Android) - since our main user -- the @plugin annotation -- needs a RetentionPolicy of "runtime", there must not be a warning about that usage model - SciJava-common's usage of the annotation index requires the latter to be handled carefully when it comes to class loader issues. While there has been a fix for SezPoz to that extent, donated by the SciJava project, the fix did not make it into a release for more than fourteen SciJava versions; SciJava has maintained its own SezPoz version for that reason. To support the SciJava-related projects (including the ones uploaded to ImageJ update sites where it cannot be guaranteed at all times that all the uploaded artifacts were built with the newest SciJava common version), the branch sports a backwards-compatible index reader that falls back to SezPoz-generated indexes for artifacts that do not contain SciJava-generated ones. While at it, fill a few gaps in the pom.xml and bump the version to 2.6.0-SNAPSHOT (to reflect the new API)... Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Conflicts: .gitignore LICENSE.txt license/scijava/license.txt pom.xml
2 parents b3e63cf + fbafebf commit cb594d2

30 files changed

Lines changed: 3402 additions & 1 deletion

‎pom.xml‎

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</parent>
1010

1111
<artifactId>scijava-common</artifactId>
12-
<version>2.5.1-SNAPSHOT</version>
12+
<version>2.6.0-SNAPSHOT</version>
1313

1414
<name>SciJava Common</name>
1515
<description>SciJava Common is a shared library for SciJava software. It provides a plugin framework, with an extensible mechanism for service discovery, driven by the SezPoz library, so that plugins can be loaded dynamically. It is used by both ImageJ and SCIFIO.</description>
@@ -75,6 +75,13 @@ Institute of Molecular Cell Biology and Genetics.</organizationName>
7575
<canUpdateCopyright>true</canUpdateCopyright>
7676
</configuration>
7777
</plugin>
78+
<plugin>
79+
<groupId>org.apache.maven.plugins</groupId>
80+
<artifactId>maven-compiler-plugin</artifactId>
81+
<configuration>
82+
<compilerArgument>-proc:none</compilerArgument>
83+
</configuration>
84+
</plugin>
7885
</plugins>
7986
</build>
8087

@@ -88,6 +95,57 @@ Institute of Molecular Cell Biology and Genetics.</organizationName>
8895
</mailingList>
8996
</mailingLists>
9097

98+
<developers>
99+
<developer>
100+
<id>ctrueden</id>
101+
<name>Curtis Rueden</name>
102+
<email>ctrueden@wisc.edu</email>
103+
<url>http://loci.wisc.edu/people/curtis-rueden</url>
104+
<organization>UW-Madison LOCI</organization>
105+
<organizationUrl>http://loci.wisc.edu/</organizationUrl>
106+
<roles>
107+
<role>architect</role>
108+
<role>developer</role>
109+
</roles>
110+
<timezone>-6</timezone>
111+
</developer>
112+
<developer>
113+
<id>dscho</id>
114+
<name>Johannes Schindelin</name>
115+
<email>schindelin@wisc.edu</email>
116+
<url>http://loci.wisc.edu/people/johannes-schindelin</url>
117+
<organization>UW-Madison LOCI</organization>
118+
<organizationUrl>http://loci.wisc.edu/</organizationUrl>
119+
<roles>
120+
<role>architect</role>
121+
<role>developer</role>
122+
</roles>
123+
<timezone>-6</timezone>
124+
</developer>
125+
</developers>
126+
127+
<organization>
128+
<name>SciJava</name>
129+
<url>http://scijava.org/</url>
130+
</organization>
131+
132+
<issueManagement>
133+
<system>GitHub issues</system>
134+
<url>https://github.com/scijava/scijava-common/issues</url>
135+
</issueManagement>
136+
137+
<ciManagement>
138+
<system>Jenkins</system>
139+
<url>https://jenkins.imagej.net/job/SciJava-common/</url>
140+
</ciManagement>
141+
142+
<licenses>
143+
<license>
144+
<name>Simplified BSD License</name>
145+
<distribution>repo</distribution>
146+
</license>
147+
</licenses>
148+
91149
<scm>
92150
<connection>scm:git:git://github.com/scijava/scijava-common</connection>
93151
<developerConnection>scm:git:git@github.com:scijava/scijava-common</developerConnection>
@@ -116,6 +174,41 @@ Institute of Molecular Cell Biology and Genetics.</organizationName>
116174
</dependency>
117175
</dependencies>
118176
</profile>
177+
<profile>
178+
<id>run-its</id>
179+
<build>
180+
<defaultGoal>integration-test</defaultGoal>
181+
<plugins>
182+
<plugin>
183+
<artifactId>maven-invoker-plugin</artifactId>
184+
<version>1.8</version>
185+
<configuration>
186+
<debug>${invoker.debug}</debug>
187+
<showErrors>true</showErrors>
188+
<streamLogs>true</streamLogs>
189+
<projectsDirectory>src/it</projectsDirectory>
190+
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
191+
<pomIncludes>
192+
<pomInclude>*/pom.xml</pomInclude>
193+
</pomIncludes>
194+
<settingsFile>src/it/settings.xml</settingsFile>
195+
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
196+
<preBuildHookScript>setup.bsh</preBuildHookScript>
197+
<postBuildHookScript>verify.bsh</postBuildHookScript>
198+
</configuration>
199+
<executions>
200+
<execution>
201+
<id>integration-test</id>
202+
<goals>
203+
<goal>install</goal>
204+
<goal>run</goal>
205+
</goals>
206+
</execution>
207+
</executions>
208+
</plugin>
209+
</plugins>
210+
</build>
211+
</profile>
119212
</profiles>
120213

121214
<!-- NB: for project parent -->

‎src/it/apt-test/pom.xml‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
#%L
4+
Annotation index (processor and index access library).
5+
%%
6+
Copyright (C) 2009 - 2013 Board of Regents of the University of Wisconsin-Madison.
7+
%%
8+
Redistribution and use in source and binary forms, with or without
9+
modification, are permitted provided that the following conditions are met:
10+
11+
1. Redistributions of source code must retain the above copyright notice,
12+
this list of conditions and the following disclaimer.
13+
2. Redistributions in binary form must reproduce the above copyright notice,
14+
this list of conditions and the following disclaimer in the documentation
15+
and/or other materials provided with the distribution.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
21+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27+
POSSIBILITY OF SUCH DAMAGE.
28+
29+
The views and conclusions contained in the software and documentation are
30+
those of the authors and should not be interpreted as representing official
31+
policies, either expressed or implied, of any organization.
32+
#L%
33+
-->
34+
35+
<project xmlns="http://maven.apache.org/POM/4.0.0"
36+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
37+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
38+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
39+
<modelVersion>4.0.0</modelVersion>
40+
41+
<groupId>@project.groupId@</groupId>
42+
<artifactId>apt-test</artifactId>
43+
<version>@project.version@</version>
44+
45+
<name>An integration test for the annotation processor</name>
46+
<description>This integration makes sure that the annotations are properly processed and indexed at compilation time.</description>
47+
48+
<properties>
49+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
50+
</properties>
51+
52+
<dependencies>
53+
<dependency>
54+
<groupId>@project.groupId@</groupId>
55+
<artifactId>@project.artifactId@</artifactId>
56+
<version>@project.version@</version>
57+
</dependency>
58+
</dependencies>
59+
60+
</project>
61+

‎src/it/apt-test/setup.bsh‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import java.io.File;
2+
3+
assertTrue(message, condition) {
4+
if (!condition) {
5+
throw new Exception(message);
6+
}
7+
}
8+
9+
rmRF(directory) {
10+
list = directory.listFiles();
11+
for (i = 0; list != null && i < list.length; i++) {
12+
if ((list[i].isFile() && !list[i].delete()) ||
13+
(list[i].isDirectory() && !rmRF(list[i]))) {
14+
print("Could not delete " + list[i]);
15+
return false;
16+
}
17+
}
18+
return directory.delete();
19+
}
20+
21+
metaInf = new File(basedir, "target/classes/META-INF");
22+
23+
assertTrue("Could not delete META-INF/", !metaInf.isDirectory() || rmRF(metaInf));
24+
print("Setup completed");
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* #%L
3+
* Annotation index (processor and index access library).
4+
* %%
5+
* Copyright (C) 2009 - 2013 Board of Regents of the University of Wisconsin-Madison.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*
28+
* The views and conclusions contained in the software and documentation are
29+
* those of the authors and should not be interpreted as representing official
30+
* policies, either expressed or implied, of any organization.
31+
* #L%
32+
*/
33+
package org.scijava.annotations.its;
34+
35+
/**
36+
* An annotated class, to be indexed in the integration test
37+
*
38+
* @author Johannes Schindelin
39+
*/
40+
@CustomAnnotation(greeting = "Hey, what's up, doc?")
41+
public class Annotated {
42+
@CustomAnnotation(greeting = "Howdy, stranger!")
43+
public class Inner {}
44+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* #%L
3+
* Annotation index (processor and index access library).
4+
* %%
5+
* Copyright (C) 2009 - 2013 Board of Regents of the University of Wisconsin-Madison.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*
28+
* The views and conclusions contained in the software and documentation are
29+
* those of the authors and should not be interpreted as representing official
30+
* policies, either expressed or implied, of any organization.
31+
* #L%
32+
*/
33+
package org.scijava.annotations.its;
34+
35+
import java.lang.annotation.ElementType;
36+
import java.lang.annotation.Retention;
37+
import java.lang.annotation.RetentionPolicy;
38+
import java.lang.annotation.Target;
39+
40+
import org.scijava.annotations.Indexable;
41+
42+
/**
43+
* A simple annotation for use in the integration test.
44+
*
45+
* @author Johannes Schindelin
46+
*/
47+
@Retention(RetentionPolicy.RUNTIME)
48+
@Target({ElementType.TYPE})
49+
@Indexable
50+
public @interface CustomAnnotation {
51+
52+
String greeting() default "Hello, World!";
53+
54+
}
55+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"class":"org.scijava.annotations.its.Annotated","values":{"greeting":"Hey, what's up, doc?"}}{"class":"org.scijava.annotations.its.Annotated$Inner","values":{"greeting":"Howdy, stranger!"}}

‎src/it/apt-test/verify.bsh‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import java.io.BufferedReader;
2+
import java.io.File;
3+
import java.io.FileReader;
4+
5+
assertTrue(message, condition) {
6+
if (!condition) {
7+
throw new Exception(message);
8+
}
9+
}
10+
11+
assertEquals(a, b) {
12+
if (a !=b && (a == null || !a.equals(b))) {
13+
throw new Exception("Not equal: " + a + " != " + b);
14+
}
15+
}
16+
17+
readAsString(file) {
18+
builder = new StringBuilder();
19+
reader = new BufferedReader(new FileReader(file));
20+
for (;;) {
21+
line = reader.readLine();
22+
if (line == null) {
23+
break;
24+
}
25+
if (builder.length() > 0) {
26+
builder.append('\n');
27+
}
28+
builder.append(line);
29+
}
30+
reader.close();
31+
return builder.toString();
32+
}
33+
34+
annotationIndex = new File(basedir,
35+
"target/classes/META-INF/json/org.scijava.annotations.its.CustomAnnotation");
36+
37+
assertTrue("File does not exist: " + annotationIndex, annotationIndex.exists());
38+
39+
expect = readAsString(new File(basedir, "src/test/resources/expect"));
40+
actual = readAsString(annotationIndex);
41+
assertEquals(expect, actual);

0 commit comments

Comments
 (0)