[Git][java-team/annotation-indexer][upstream] New upstream version 1.14

Emmanuel Bourg gitlab at salsa.debian.org
Thu Jan 7 09:18:40 GMT 2021



Emmanuel Bourg pushed to branch upstream at Debian Java Maintainers / annotation-indexer


Commits:
21f8246f by Emmanuel Bourg at 2021-01-07T10:16:19+01:00
New upstream version 1.14
- - - - -


4 changed files:

- pom.xml
- src/main/java/org/jvnet/hudson/annotation_indexer/AnnotationProcessorImpl.java
- src/main/java/org/jvnet/hudson/annotation_indexer/Index.java
- src/test/java/org/jvnet/hudson/annotation_indexer/AnnotationProcessorImplTest.java


Changes:

=====================================
pom.xml
=====================================
@@ -10,7 +10,7 @@
 
   <artifactId>annotation-indexer</artifactId>
   <name>Annotation Indexer</name>
-  <version>1.13</version>
+  <version>1.14</version>
   <description>
     Creates index of annotations.
   </description>
@@ -44,7 +44,8 @@
   <scm>
     <connection>scm:git:git://github.com/jenkinsci/lib-${project.artifactId}.git</connection>
     <developerConnection>scm:git:git at github.com:jenkinsci/lib-${project.artifactId}.git</developerConnection>
-    <tag>annotation-indexer-1.13</tag>
+    <url>https://github.com/jenkinsci/lib-annotation-indexer</url>
+    <tag>annotation-indexer-1.14</tag>
   </scm>
 
   <licenses>


=====================================
src/main/java/org/jvnet/hudson/annotation_indexer/AnnotationProcessorImpl.java
=====================================
@@ -93,7 +93,7 @@ public class AnnotationProcessorImpl extends AbstractProcessor {
         }
 
         String getIndexFileName() {
-            return "META-INF/annotations/" + annotationName;
+            return "META-INF/services/annotations/" + annotationName;
         }
 
         /**


=====================================
src/main/java/org/jvnet/hudson/annotation_indexer/Index.java
=====================================
@@ -7,6 +7,7 @@ import java.io.InputStreamReader;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
 import java.net.URL;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -20,6 +21,14 @@ import java.util.logging.Logger;
  * @author Kohsuke Kawaguchi
  */
 public class Index {
+    /**
+     * Resource path in which we look up the index.
+     *
+     * <p>
+     * Historically we put things under META-INF/annotations.
+     */
+    private static final List<String> PREFIXES = Arrays.asList("META-INF/annotations/", "META-INF/services/annotations/");
+
     /**
      * Lists up all the elements annotated by the given annotation and of the given {@link AnnotatedElement} subtype.
      */
@@ -42,15 +51,17 @@ public class Index {
 
         final Set<String> ids = new TreeSet<String>();
 
-        final Enumeration<URL> res = cl.getResources("META-INF/annotations/"+type.getName());
-        while (res.hasMoreElements()) {
-            URL url = res.nextElement();
+        for (String prefix : PREFIXES) {
+            final Enumeration<URL> res = cl.getResources(prefix + type.getName());
+            while (res.hasMoreElements()) {
+                URL url = res.nextElement();
 
-            try (InputStream is = url.openStream();
-                 BufferedReader r = new BufferedReader(new InputStreamReader(is, "UTF-8"))) {
-                String line;
-                while ((line = r.readLine()) != null) {
-                    ids.add(line);
+                try (InputStream is = url.openStream();
+                     BufferedReader r = new BufferedReader(new InputStreamReader(is, "UTF-8"))) {
+                    String line;
+                    while ((line = r.readLine()) != null) {
+                        ids.add(line);
+                    }
                 }
             }
         }


=====================================
src/test/java/org/jvnet/hudson/annotation_indexer/AnnotationProcessorImplTest.java
=====================================
@@ -29,7 +29,7 @@ public class AnnotationProcessorImplTest {
                 addLine("@some.api.A public class Stuff {}");
         compilation.doCompile(null, "-source", "8");
         assertEquals(Collections.emptyList(), Utils.filterObsoleteSourceVersionWarnings(compilation.getDiagnostics()));
-        assertEquals("some.pkg.Stuff" + System.getProperty("line.separator"), Utils.getGeneratedResource(compilation, "META-INF/annotations/some.api.A"));
+        assertEquals("some.pkg.Stuff" + System.getProperty("line.separator"), Utils.getGeneratedResource(compilation, "META-INF/services/annotations/some.api.A"));
     }
 
     @Indexed @Retention(RetentionPolicy.RUNTIME) public @interface A {}
@@ -40,7 +40,7 @@ public class AnnotationProcessorImplTest {
                 addLine("@" + A.class.getCanonicalName() + " public class Stuff {}");
         compilation.doCompile(null, "-source", "8");
         assertEquals(Collections.emptyList(), Utils.filterObsoleteSourceVersionWarnings(compilation.getDiagnostics()));
-        assertEquals("some.pkg.Stuff" + System.getProperty("line.separator"), Utils.getGeneratedResource(compilation, "META-INF/annotations/" + A.class.getName()));
+        assertEquals("some.pkg.Stuff" + System.getProperty("line.separator"), Utils.getGeneratedResource(compilation, "META-INF/services/annotations/" + A.class.getName()));
     }
 
     @Test public void incremental() {
@@ -50,14 +50,14 @@ public class AnnotationProcessorImplTest {
                 addLine("@" + A.class.getCanonicalName() + " public class Stuff {}");
         compilation.doCompile(null, "-source", "8");
         assertEquals(Collections.emptyList(), Utils.filterObsoleteSourceVersionWarnings(compilation.getDiagnostics()));
-        assertEquals("some.pkg.Stuff" + System.getProperty("line.separator"), Utils.getGeneratedResource(compilation, "META-INF/annotations/" + A.class.getName()));
+        assertEquals("some.pkg.Stuff" + System.getProperty("line.separator"), Utils.getGeneratedResource(compilation, "META-INF/services/annotations/" + A.class.getName()));
         compilation = new Compilation(compilation);
         compilation.addSource("some.pkg.MoreStuff").
                 addLine("package some.pkg;").
                 addLine("@" + A.class.getCanonicalName() + " public class MoreStuff {}");
         compilation.doCompile(null, "-source", "8");
         assertEquals(Collections.emptyList(), Utils.filterObsoleteSourceVersionWarnings(compilation.getDiagnostics()));
-        assertEquals("some.pkg.MoreStuff" + System.getProperty("line.separator") + "some.pkg.Stuff" + System.getProperty("line.separator"), Utils.getGeneratedResource(compilation, "META-INF/annotations/" + A.class.getName()));
+        assertEquals("some.pkg.MoreStuff" + System.getProperty("line.separator") + "some.pkg.Stuff" + System.getProperty("line.separator"), Utils.getGeneratedResource(compilation, "META-INF/services/annotations/" + A.class.getName()));
     }
 
     @Indexed @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface B {}
@@ -70,7 +70,7 @@ public class AnnotationProcessorImplTest {
         compilation.doCompile(null, "-source", "8");
         assertEquals(Collections.emptyList(), Utils.filterObsoleteSourceVersionWarnings(compilation.getDiagnostics()));
         /* XXX #7188605 currently broken on JDK 6; perhaps need to use a ElementScanner6 on roundEnv.rootElements whose visitType checks for annotations
-        assertEquals("some.pkg.Stuff\n", Utils.getGeneratedResource(compilation, "META-INF/annotations/" + B.class.getName()));
+        assertEquals("some.pkg.Stuff\n", Utils.getGeneratedResource(compilation, "META-INF/services/annotations/" + B.class.getName()));
         */
     }
 



View it on GitLab: https://salsa.debian.org/java-team/annotation-indexer/-/commit/21f8246f734b6ad5176cbd8765c51ade70259648

-- 
View it on GitLab: https://salsa.debian.org/java-team/annotation-indexer/-/commit/21f8246f734b6ad5176cbd8765c51ade70259648
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20210107/5105cff4/attachment.html>


More information about the pkg-java-commits mailing list