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

Emmanuel Bourg gitlab at salsa.debian.org
Mon Jan 27 09:12:28 GMT 2020



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


Commits:
eb6b9ae5 by Emmanuel Bourg at 2020-01-27T09:58:43+01:00
New upstream version 1.13
- - - - -


8 changed files:

- + .github/release-drafter.yml
- + README.md
- 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
- src/test/java/org/jvnet/hudson/annotation_indexer/Utils.java
- + src/test/java/org/jvnet/hudson/annotation_indexer/package-info.java


Changes:

=====================================
.github/release-drafter.yml
=====================================
@@ -0,0 +1,2 @@
+_extends: .github
+tag-template: annotation-indexer-$NEXT_MINOR_VERSION


=====================================
README.md
=====================================
@@ -0,0 +1,12 @@
+# Annotation Indexer library
+
+The library creates an index of annotations which can be then accessed by other components.
+It is used inside the [Jenkins project](http://jenkins.io), but it can be also used in other projects.
+
+## Javadoc
+
+To be published soon, see https://github.com/jenkins-infra/javadoc/pull/22
+
+## Changelog
+
+For version 1.13 and above, see [GitHub Releases](https://github.com/jenkinsci/lib-annotation-indexer/releases)


=====================================
pom.xml
=====================================
@@ -4,22 +4,27 @@
   <parent>
     <groupId>org.jenkins-ci</groupId>
     <artifactId>jenkins</artifactId>
-    <version>1.37</version>
+    <version>1.46</version>
     <relativePath />
   </parent>
 
   <artifactId>annotation-indexer</artifactId>
   <name>Annotation Indexer</name>
-  <version>1.12</version>
+  <version>1.13</version>
   <description>
     Creates index of annotations.
   </description>
 
+  <properties>
+    <java.level>8</java.level>
+    <java.level.test>8</java.level.test>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>org.kohsuke.metainf-services</groupId>
       <artifactId>metainf-services</artifactId>
-      <version>1.7</version>
+      <version>1.8</version>
       <optional>true</optional>
     </dependency>
     <dependency>
@@ -39,7 +44,7 @@
   <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.12</tag>
+    <tag>annotation-indexer-1.13</tag>
   </scm>
 
   <licenses>


=====================================
src/main/java/org/jvnet/hudson/annotation_indexer/AnnotationProcessorImpl.java
=====================================
@@ -9,6 +9,7 @@ import javax.annotation.processing.SupportedAnnotationTypes;
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.element.Element;
+import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.util.Elements;
 import javax.tools.Diagnostic.Kind;
@@ -80,6 +81,10 @@ public class AnnotationProcessorImpl extends AbstractProcessor {
             case CONSTRUCTOR:
                 t = (TypeElement) elt.getEnclosingElement();
                 break;
+            case PACKAGE:
+                classes.add(((PackageElement)elt).getQualifiedName().toString()+".*");
+                return;
+
             default:
 //                throw new AssertionError(elt.getKind());
                 return;


=====================================
src/main/java/org/jvnet/hudson/annotation_indexer/Index.java
=====================================
@@ -45,15 +45,13 @@ public class Index {
         final Enumeration<URL> res = cl.getResources("META-INF/annotations/"+type.getName());
         while (res.hasMoreElements()) {
             URL url = res.nextElement();
-            InputStream is = url.openStream();
-            try {
-                BufferedReader r = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+
+            try (InputStream is = url.openStream();
+                 BufferedReader r = new BufferedReader(new InputStreamReader(is, "UTF-8"))) {
                 String line;
                 while ((line = r.readLine()) != null) {
                     ids.add(line);
                 }
-            } finally {
-                is.close();
             }
         }
 
@@ -96,6 +94,11 @@ public class Index {
                             String name = iditr.next();
 
                             try {
+                                if (name.endsWith(".*")) {
+                                    final Package p = Package.getPackage(name.substring(0, name.length() - 2));
+                                    lookaheads.add(p);
+                                }
+
                                 Class<?> c = cl.loadClass(name);
 
                                 if (c.isAnnotationPresent(type))


=====================================
src/test/java/org/jvnet/hudson/annotation_indexer/AnnotationProcessorImplTest.java
=====================================
@@ -1,5 +1,6 @@
 package org.jvnet.hudson.annotation_indexer;
 
+import java.io.IOException;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Inherited;
 import java.lang.annotation.Retention;
@@ -26,7 +27,7 @@ public class AnnotationProcessorImplTest {
         compilation.addSource("some.pkg.Stuff").
                 addLine("package some.pkg;").
                 addLine("@some.api.A public class Stuff {}");
-        compilation.doCompile(null, "-source", "6");
+        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"));
     }
@@ -37,7 +38,7 @@ public class AnnotationProcessorImplTest {
         compilation.addSource("some.pkg.Stuff").
                 addLine("package some.pkg;").
                 addLine("@" + A.class.getCanonicalName() + " public class Stuff {}");
-        compilation.doCompile(null, "-source", "6");
+        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()));
     }
@@ -47,14 +48,14 @@ public class AnnotationProcessorImplTest {
         compilation.addSource("some.pkg.Stuff").
                 addLine("package some.pkg;").
                 addLine("@" + A.class.getCanonicalName() + " public class Stuff {}");
-        compilation.doCompile(null, "-source", "6");
+        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()));
         compilation = new Compilation(compilation);
         compilation.addSource("some.pkg.MoreStuff").
                 addLine("package some.pkg;").
                 addLine("@" + A.class.getCanonicalName() + " public class MoreStuff {}");
-        compilation.doCompile(null, "-source", "6");
+        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()));
     }
@@ -66,7 +67,7 @@ public class AnnotationProcessorImplTest {
         compilation.addSource("some.pkg.Stuff").
                 addLine("package some.pkg;").
                 addLine("public class Stuff extends " + Super.class.getCanonicalName() + " {}");
-        compilation.doCompile(null, "-source", "6");
+        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()));
@@ -109,4 +110,13 @@ public class AnnotationProcessorImplTest {
         assertFalse(it.hasNext());
     }
 
+
+    @Indexed @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PACKAGE) public @interface OnPackage {}
+    @Test public void packageinfo() throws IOException {
+        Iterator<AnnotatedElement> it = Index.list(OnPackage.class, Stuff.class.getClassLoader()).iterator();
+        assertTrue(it.hasNext());
+        final Package p = (Package) it.next();
+        assertEquals("org.jvnet.hudson.annotation_indexer", p.getName());
+    }
+
 }


=====================================
src/test/java/org/jvnet/hudson/annotation_indexer/Utils.java
=====================================
@@ -24,8 +24,7 @@ class Utils {
     // Filter out warnings about source 1.6 is obsolete in java 9
     // This usually appears with other warnings
     public static final List<String> IGNORE = Arrays.asList(
-            "source value 1.6 is obsolete and will be removed in a future release", // Filter out warnings about source 1.6 is obsolete in java 9
-            "To suppress warnings about obsolete options" // This usually appears with other warnings
+            "RELEASE_6" // Filter out warnings about source 1.6 is obsolete in java 9+
     );
 
     public static List<Diagnostic<? extends JavaFileObject>> filterObsoleteSourceVersionWarnings(List<Diagnostic<? extends JavaFileObject>> diagnostics) {


=====================================
src/test/java/org/jvnet/hudson/annotation_indexer/package-info.java
=====================================
@@ -0,0 +1,2 @@
+ at AnnotationProcessorImplTest.OnPackage
+package org.jvnet.hudson.annotation_indexer;



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

-- 
View it on GitLab: https://salsa.debian.org/java-team/annotation-indexer/commit/eb6b9ae5b01f2f46ad56842b91c68c51b5e18dac
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/20200127/7e597312/attachment.html>


More information about the pkg-java-commits mailing list