AVRO-2516: Add Automatic-Module-Name headers for Avro modules (#616)

(cherry picked from commit 1be286e774761ab67dd97f2ad96fc9d7b3d7b738)
diff --git a/lang/java/avro/pom.xml b/lang/java/avro/pom.xml
index ce32a12..931d612 100644
--- a/lang/java/avro/pom.xml
+++ b/lang/java/avro/pom.xml
@@ -59,6 +59,13 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>org.apache.avro</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
diff --git a/lang/java/compiler/pom.xml b/lang/java/compiler/pom.xml
index 7586c8d..218c39e 100644
--- a/lang/java/compiler/pom.xml
+++ b/lang/java/compiler/pom.xml
@@ -63,6 +63,17 @@
       </testResource>
     </testResources>
     <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>org.apache.avro.compiler</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
       <!-- Avro generates a parser class with javacc. By default, this looks in src/main/javacc
         and outputs to target/generated-sources/javacc See http://mojo.codehaus.org/javacc-maven-plugin/javacc-mojo.html
         for more info on using this plugin. -->
diff --git a/lang/java/grpc/pom.xml b/lang/java/grpc/pom.xml
index 2f85a60..fec1408 100644
--- a/lang/java/grpc/pom.xml
+++ b/lang/java/grpc/pom.xml
@@ -72,6 +72,17 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>org.apache.avro.grpc</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
       <!-- Allow guava because hadoop brings it as a transitive dependency. -->
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
diff --git a/lang/java/ipc-jetty/pom.xml b/lang/java/ipc-jetty/pom.xml
index 19812ef..92c92bd 100644
--- a/lang/java/ipc-jetty/pom.xml
+++ b/lang/java/ipc-jetty/pom.xml
@@ -59,6 +59,13 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>org.apache.avro.ipc.jetty</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
       </plugin>
     </plugins>
   </build>
diff --git a/lang/java/ipc-netty/pom.xml b/lang/java/ipc-netty/pom.xml
index 61c58c3..8e404e5 100644
--- a/lang/java/ipc-netty/pom.xml
+++ b/lang/java/ipc-netty/pom.xml
@@ -61,6 +61,13 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>org.apache.avro.ipc.netty</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
       </plugin>
     </plugins>
   </build>
diff --git a/lang/java/ipc/pom.xml b/lang/java/ipc/pom.xml
index f81b280..de2059c 100644
--- a/lang/java/ipc/pom.xml
+++ b/lang/java/ipc/pom.xml
@@ -96,6 +96,13 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>org.apache.avro.ipc</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
       </plugin>
     </plugins>
   </build>
diff --git a/lang/java/mapred/pom.xml b/lang/java/mapred/pom.xml
index 7a9e0dd..b66e36e 100644
--- a/lang/java/mapred/pom.xml
+++ b/lang/java/mapred/pom.xml
@@ -52,6 +52,13 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>org.apache.avro.mapred</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
       </plugin>
       <!-- Allow guava because hadoop brings it as a transitive dependency. -->
       <plugin>
diff --git a/lang/java/perf/README.md b/lang/java/perf/README.md
index 4cbe494..e8f7168 100644
--- a/lang/java/perf/README.md
+++ b/lang/java/perf/README.md
@@ -44,4 +44,4 @@
 > why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial
 > experiments, perform baseline and negative tests that provide experimental control, make
 > sure the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the
-> domain experts. Do not assume the numbers tell you what you want them to tell.
\ No newline at end of file
+> domain experts. Do not assume the numbers tell you what you want them to tell.
diff --git a/lang/java/perf/pom.xml b/lang/java/perf/pom.xml
index 0a82cdf..73d5833 100644
--- a/lang/java/perf/pom.xml
+++ b/lang/java/perf/pom.xml
@@ -37,7 +37,23 @@
     <jmh.version>1.21</jmh.version>
     <main.basedir>${project.parent.parent.basedir}</main.basedir>
   </properties>
-  
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>org.apache.avro.perf</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
   <dependencies>
     <dependency>
       <groupId>org.apache.avro</groupId>
diff --git a/lang/java/protobuf/pom.xml b/lang/java/protobuf/pom.xml
index 542764d..58091f9 100644
--- a/lang/java/protobuf/pom.xml
+++ b/lang/java/protobuf/pom.xml
@@ -79,6 +79,22 @@
     </profile>
   </profiles>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>org.apache.avro.protobuf</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
   <dependencies>
     <dependency>
       <groupId>${project.groupId}</groupId>
diff --git a/lang/java/thrift/pom.xml b/lang/java/thrift/pom.xml
index e987d73..63a589d 100644
--- a/lang/java/thrift/pom.xml
+++ b/lang/java/thrift/pom.xml
@@ -81,6 +81,22 @@
     </profile>
   </profiles>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>org.apache.avro.thrift</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
   <dependencies>
     <dependency>
       <groupId>${project.groupId}</groupId>
diff --git a/lang/java/trevni/avro/pom.xml b/lang/java/trevni/avro/pom.xml
index ce88cbe..9a0001e 100644
--- a/lang/java/trevni/avro/pom.xml
+++ b/lang/java/trevni/avro/pom.xml
@@ -59,6 +59,17 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>org.apache.avro.trevni.avro</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 
diff --git a/lang/java/trevni/core/pom.xml b/lang/java/trevni/core/pom.xml
index 5c6b1f1..e259b4f 100644
--- a/lang/java/trevni/core/pom.xml
+++ b/lang/java/trevni/core/pom.xml
@@ -35,6 +35,22 @@
     <main.basedir>${project.parent.parent.parent.basedir}</main.basedir>
   </properties>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Automatic-Module-Name>org.apache.avro.trevni</Automatic-Module-Name>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
   <dependencies>
     <dependency>
       <groupId>org.xerial.snappy</groupId>