Add immutables.value to annotationProcessorPaths 46/85546/5
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Nov 2019 10:52:22 +0000 (11:52 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Nov 2019 13:11:18 +0000 (14:11 +0100)
Immutables do not work in our setup with JPMS modules, as they
are not picked up from general dependency path. Also we do not need
the full dependency in each module, just the annotations package.

This is based on:
https://github.com/immutables/immutables/issues/713#issuecomment-419750206
https://github.com/immutables/immutables/issues/750
https://github.com/immutables/immutables/issues/745#issuecomment-375952158

JIRA: ODLPARENT-216
Change-Id: Ib1b6f89b537fe27dbf68bec166b7ebdab042c483
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
odlparent/pom.xml
pom.xml
tests/immutables-jpms/pom.xml [new file with mode: 0644]
tests/immutables-jpms/src/main/java/module-info.java [new file with mode: 0644]
tests/immutables-jpms/src/main/java/org/opendaylight/odlparent/test/immutables/jpms/JpmsInterface.java [new file with mode: 0644]
tests/immutables-jpms/src/test/java/org/opendaylight/odlparent/test/immutables/jpms/JmpsInterfaceTest.java [new file with mode: 0644]
tests/immutables-plain/pom.xml [new file with mode: 0644]
tests/immutables-plain/src/main/java/org/opendaylight/odlparent/test/immutables/plain/PlainInterface.java [new file with mode: 0644]
tests/immutables-plain/src/test/java/org/opendaylight/odlparent/test/immutables/plain/PlainInterfaceTest.java [new file with mode: 0644]
tests/pom.xml [new file with mode: 0644]

index e9c8317e0a8ee3f61d4118bb81f54ee16ec91111..e7f3cfa47015c45319a19649155c9af332741b80 100644 (file)
         <!-- Generates immutable implementations, builders, the works -->
         <groupId>org.immutables</groupId>
         <artifactId>value</artifactId>
+        <classifier>annotations</classifier>
+        <!-- Keep this version in sync with annotationProcessorPaths declaration below -->
         <version>2.7.5</version>
         <!-- Must be provided; scope=test here breaks APT in Eclipse :( -->
         <scope>provided</scope>
       </dependency>
+      <dependency>
+        <!-- Same as above, except using legacy unified artifact -->
+        <!-- FIXME: ODLPARENT-217: remove this declaration -->
+        <groupId>org.immutables</groupId>
+        <artifactId>value</artifactId>
+        <!-- Keep this version in sync with annotationProcessorPaths declaration below -->
+        <version>2.7.5</version>
+        <!-- Must be provided; scope=test here breaks APT in Eclipse :( -->
+        <scope>provided</scope>
+      </dependency>
+
       <dependency>
         <!-- Generates META-INF/services entries for ServiceLoader -->
         <groupId>org.kohsuke.metainf-services</groupId>
               <arg>-Xlint:deprecation</arg>
               <arg>-Xlint:unchecked</arg>
             </compilerArgs>
+            <annotationProcessorPaths>
+              <dependency>
+                <groupId>org.immutables</groupId>
+                <artifactId>value</artifactId>
+                <!-- Keep this version in sync with dependency declaration above -->
+                <version>2.7.5</version>
+              </dependency>
+            </annotationProcessorPaths>
           </configuration>
         </plugin>
         <plugin>
diff --git a/pom.xml b/pom.xml
index 7dadb283e91c08ef54670cc59b4214754238c583..59b98510586929098e4e567892835ea73720f8e0 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -70,6 +70,7 @@
         <!-- Self-tests -->
         <module>odlparent-bundle-check</module>
         <module>odlparent-dependency-check</module>
+        <module>tests</module>
 
         <!-- Third-party stuff -->
         <module>third-party</module>
diff --git a/tests/immutables-jpms/pom.xml b/tests/immutables-jpms/pom.xml
new file mode 100644 (file)
index 0000000..9a51879
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<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.opendaylight.odlparent</groupId>
+        <artifactId>odlparent</artifactId>
+        <version>6.0.2-SNAPSHOT</version>
+        <relativePath>../../odlparent</relativePath>
+    </parent>
+
+    <artifactId>immutables-jpms</artifactId>
+    <packaging>jar</packaging>
+
+    <properties>
+        <maven.deploy.skip>true</maven.deploy.skip>
+        <maven.install.skip>true</maven.install.skip>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.immutables</groupId>
+            <artifactId>value</artifactId>
+            <classifier>annotations</classifier>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/tests/immutables-jpms/src/main/java/module-info.java b/tests/immutables-jpms/src/main/java/module-info.java
new file mode 100644 (file)
index 0000000..36659b8
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+module org.opendaylight.odlparent.test.immutables.jpms {
+    exports org.opendaylight.odlparent.test.immutables.jpms;
+
+    requires static com.github.spotbugs.annotations;
+    requires static org.immutables.value.annotations;
+}
diff --git a/tests/immutables-jpms/src/main/java/org/opendaylight/odlparent/test/immutables/jpms/JpmsInterface.java b/tests/immutables-jpms/src/main/java/org/opendaylight/odlparent/test/immutables/jpms/JpmsInterface.java
new file mode 100644 (file)
index 0000000..3538aef
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.odlparent.test.immutables.jpms;
+
+import org.immutables.value.Value.Immutable;
+
+@Immutable
+public interface JpmsInterface {
+
+    int getFoo();
+}
diff --git a/tests/immutables-jpms/src/test/java/org/opendaylight/odlparent/test/immutables/jpms/JmpsInterfaceTest.java b/tests/immutables-jpms/src/test/java/org/opendaylight/odlparent/test/immutables/jpms/JmpsInterfaceTest.java
new file mode 100644 (file)
index 0000000..951cfdb
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.odlparent.test.immutables.jpms;
+
+import static org.hamcrest.Matchers.isA;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+public class JmpsInterfaceTest {
+    @Test
+    public void testBuilder() {
+        assertThat(ImmutableJpmsInterface.builder().foo(1).build(), isA(JpmsInterface.class));
+    }
+}
diff --git a/tests/immutables-plain/pom.xml b/tests/immutables-plain/pom.xml
new file mode 100644 (file)
index 0000000..362192c
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<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.opendaylight.odlparent</groupId>
+        <artifactId>odlparent</artifactId>
+        <version>6.0.2-SNAPSHOT</version>
+        <relativePath>../../odlparent</relativePath>
+    </parent>
+
+    <artifactId>immutables-plain</artifactId>
+    <packaging>jar</packaging>
+
+    <properties>
+        <maven.deploy.skip>true</maven.deploy.skip>
+        <maven.install.skip>true</maven.install.skip>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.immutables</groupId>
+            <artifactId>value</artifactId>
+            <classifier>annotations</classifier>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/tests/immutables-plain/src/main/java/org/opendaylight/odlparent/test/immutables/plain/PlainInterface.java b/tests/immutables-plain/src/main/java/org/opendaylight/odlparent/test/immutables/plain/PlainInterface.java
new file mode 100644 (file)
index 0000000..c7c9771
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.odlparent.test.immutables.plain;
+
+import org.immutables.value.Value.Immutable;
+
+@Immutable
+public interface PlainInterface {
+
+    int getBar();
+}
diff --git a/tests/immutables-plain/src/test/java/org/opendaylight/odlparent/test/immutables/plain/PlainInterfaceTest.java b/tests/immutables-plain/src/test/java/org/opendaylight/odlparent/test/immutables/plain/PlainInterfaceTest.java
new file mode 100644 (file)
index 0000000..b45a65a
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.odlparent.test.immutables.plain;
+
+import static org.hamcrest.Matchers.isA;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+
+public class PlainInterfaceTest {
+    @Test
+    public void testBuilder() {
+        assertThat(ImmutablePlainInterface.builder().bar(1).build(), isA(PlainInterface.class));
+    }
+}
diff --git a/tests/pom.xml b/tests/pom.xml
new file mode 100644 (file)
index 0000000..533a15c
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright © 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+<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.opendaylight.odlparent</groupId>
+        <artifactId>odlparent-lite</artifactId>
+        <version>6.0.2-SNAPSHOT</version>
+        <relativePath>../odlparent-lite</relativePath>
+    </parent>
+
+    <artifactId>tests-aggregator</artifactId>
+    <packaging>pom</packaging>
+    <name>ODL :: odlparent :: ${project.artifactId}</name>
+
+    <properties>
+        <maven.deploy.skip>true</maven.deploy.skip>
+        <maven.install.skip>true</maven.install.skip>
+    </properties>
+
+    <modules>
+        <module>immutables-jpms</module>
+        <module>immutables-plain</module>
+    </modules>
+</project>