From 1a553b0796d1410d0edc202640fa34e7b8d202c7 Mon Sep 17 00:00:00 2001
From: Colin Alworth <colin@colinalworth.com>
Date: Tue, 1 Mar 2022 14:55:49 -0600
Subject: [PATCH 1/4] Treat pom scope=runtime as compile to make gradle poms
 usable

Gradle's "implementation" configuration for dependencies results in
published maven poms that are technically accurate for building
bytecode, but useless for building J2CL. To fix this, we interpret any
scope=runtime as if it says scope=compile.

This patch also tests many publicly released gwt modules to ensure that
they build cleanly in the plugin, with the hope of avoiding this issue
in the future. There are several commented out dependencies, to avoid
trying to build gwt-dom until the next release is ready. Bug #127 is
filed for followup.

Fixes #126
---
 j2cl-maven-plugin/pom.xml                     |   3 +
 .../src/it/gwt-modules-project/pom.xml        | 155 ++++++++++++++++++
 2 files changed, 158 insertions(+)
 create mode 100644 j2cl-maven-plugin/src/it/gwt-modules-project/pom.xml

diff --git a/j2cl-maven-plugin/pom.xml b/j2cl-maven-plugin/pom.xml
index 582f0250..0e1b9613 100644
--- a/j2cl-maven-plugin/pom.xml
+++ b/j2cl-maven-plugin/pom.xml
@@ -171,6 +171,9 @@
           <environmentVariables>
             <MAVEN_OPTS>-ea</MAVEN_OPTS>
           </environmentVariables>
+          <extraArtifacts>
+            <artifact>com.google.jsinterop:jsinterop-annotations:1.0.2</artifact>
+          </extraArtifacts>
         </configuration>
       </plugin>
 
diff --git a/j2cl-maven-plugin/src/it/gwt-modules-project/pom.xml b/j2cl-maven-plugin/src/it/gwt-modules-project/pom.xml
new file mode 100644
index 00000000..14f8cbb6
--- /dev/null
+++ b/j2cl-maven-plugin/src/it/gwt-modules-project/pom.xml
@@ -0,0 +1,155 @@
+<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>
+
+    <groupId>gwt-modules-project</groupId>
+    <artifactId>gwt-modules-project</artifactId>
+    <version>1.0</version>
+
+    <properties>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.gwtproject.http</groupId>
+            <artifactId>gwt-http</artifactId>
+            <version>1.0.0-RC3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.json</groupId>
+            <artifactId>gwt-json</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+        <!-- Several dependencies are commented out until #127 is fixed -->
+<!--        <dependency>-->
+<!--            <groupId>org.gwtproject.layout</groupId>-->
+<!--            <artifactId>gwt-layout</artifactId>-->
+<!--            <version>1.0.0-RC1</version>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>org.gwtproject.event</groupId>-->
+<!--            <artifactId>gwt-event-dom</artifactId>-->
+<!--            <version>1.0.0-RC1</version>-->
+<!--        </dependency>-->
+        <dependency>
+            <groupId>org.gwtproject.event</groupId>
+            <artifactId>gwt-event-legacy</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.event</groupId>
+            <artifactId>gwt-logical-event</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.gwtproject.animation</groupId>-->
+<!--            <artifactId>gwt-animation</artifactId>-->
+<!--            <version>1.0.0-RC1</version>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>org.gwtproject.aria</groupId>-->
+<!--            <artifactId>gwt-aria</artifactId>-->
+<!--            <version>1.0.0-RC1</version>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>org.gwtproject.dom</groupId>-->
+<!--            <artifactId>gwt-dom</artifactId>-->
+<!--            <version>1.0.0-RC1</version>-->
+<!--        </dependency>-->
+        <dependency>
+            <groupId>org.gwtproject.xhr</groupId>
+            <artifactId>gwt-xhr</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.safehtml</groupId>
+            <artifactId>gwt-safehtml</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.safehtml</groupId>
+            <artifactId>gwt-safecss</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.regexp</groupId>
+            <artifactId>gwt-regexp</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.core</groupId>
+            <artifactId>gwt-core</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.xml</groupId>
+            <artifactId>gwt-xml</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.callback</groupId>
+            <artifactId>gwt-callback</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.timer</groupId>
+            <artifactId>gwt-timer</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.typedarrays</groupId>
+            <artifactId>gwt-typedarrays</artifactId>
+            <version>1.0.0-RC2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.user.window</groupId>
+            <artifactId>gwt-window</artifactId>
+            <version>1.0.0-RC2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.place</groupId>
+            <artifactId>gwt-places</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.user.history</groupId>
+            <artifactId>gwt-history</artifactId>
+            <version>1.0.0-RC1</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>@project.groupId@</groupId>
+                <artifactId>@project.artifactId@</artifactId>
+                <version>@project.version@</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>build</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <version>3.6.1</version>
+                    <configuration>
+                        <source>1.8</source>
+                        <target>1.8</target>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+    <repositories>
+        <repository>
+            <id>google-snapshots</id>
+            <url>https://oss.sonatype.org/content/repositories/google-snapshots/</url>
+        </repository>
+    </repositories>
+</project>

From 43396d109c9962fc4138382a5f0264990793e6c2 Mon Sep 17 00:00:00 2001
From: Colin Alworth <colin@colinalworth.com>
Date: Wed, 2 Mar 2022 13:38:57 -0600
Subject: [PATCH 2/4] Trying to add more dependencies?

This wasn't needed locally with a clean maven cache, but apparently GHA
wants to have it.
---
 j2cl-maven-plugin/pom.xml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/j2cl-maven-plugin/pom.xml b/j2cl-maven-plugin/pom.xml
index 0e1b9613..7400dd11 100644
--- a/j2cl-maven-plugin/pom.xml
+++ b/j2cl-maven-plugin/pom.xml
@@ -173,6 +173,7 @@
           </environmentVariables>
           <extraArtifacts>
             <artifact>com.google.jsinterop:jsinterop-annotations:1.0.2</artifact>
+            <artifact>com.google.jsinterop:jsinterop:1.0.2:pom</artifact>
           </extraArtifacts>
         </configuration>
       </plugin>

From bd071b7596cd0af4cd681b6fe27617b964a4c5a8 Mon Sep 17 00:00:00 2001
From: Colin Alworth <colin@colinalworth.com>
Date: Thu, 3 Mar 2022 10:48:31 -0600
Subject: [PATCH 3/4] Stop using test-only repo

I don't like this "fix", but it does force the invoker plugin to
correctly use the dependencies it has downloaded. This PR will be split
to avoid merging this with the actual fix
---
 j2cl-maven-plugin/pom.xml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/j2cl-maven-plugin/pom.xml b/j2cl-maven-plugin/pom.xml
index 7400dd11..13aabe57 100644
--- a/j2cl-maven-plugin/pom.xml
+++ b/j2cl-maven-plugin/pom.xml
@@ -151,7 +151,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-invoker-plugin</artifactId>
-        <version>3.0.1</version>
+        <version>3.2.2</version>
         <executions>
           <execution>
             <goals>
@@ -163,7 +163,6 @@
         </executions>
         <configuration>
           <cloneProjectsTo>${project.build.directory}/it-tests</cloneProjectsTo>
-          <localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
           <settingsFile>src/it/settings.xml</settingsFile>
           <goals>
             <goal>package -e</goal>

From 19c5d812e57aa11b3f94e2dbbc1ccee1d6c1b0f4 Mon Sep 17 00:00:00 2001
From: Colin Alworth <colin@colinalworth.com>
Date: Wed, 16 Nov 2022 11:06:22 -0600
Subject: [PATCH 4/4] Give the gha mac runner a longer timeout, include more
 deps

---
 .github/workflows/build.yml                   |  4 +-
 .../src/it/gwt-modules-project/pom.xml        | 46 ++++++++-----------
 2 files changed, 22 insertions(+), 28 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e6116c27..387e20ca 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -20,7 +20,7 @@ jobs:
       - name: Build and test
         run: |
           mvn --batch-mode org.apache.maven.plugins:maven-dependency-plugin:3.2.0:go-offline
-          mvn --batch-mode install '-Dinvoker.timeoutInSeconds=300'
+          mvn --batch-mode install '-Dinvoker.timeoutInSeconds=600'
       - name: Upload test results for review
         uses: actions/upload-artifact@v2
         if: always()
@@ -57,7 +57,7 @@ jobs:
       - name: Build and test
         run: |
           ./mvnw --batch-mode org.apache.maven.plugins:maven-dependency-plugin:3.2.0:go-offline
-          ./mvnw --batch-mode install '-Dinvoker.timeoutInSeconds=300'
+          ./mvnw --batch-mode install '-Dinvoker.timeoutInSeconds=600'
       - name: Upload test results for review
         uses: actions/upload-artifact@v2
         if: always()
diff --git a/j2cl-maven-plugin/src/it/gwt-modules-project/pom.xml b/j2cl-maven-plugin/src/it/gwt-modules-project/pom.xml
index 14f8cbb6..b9eb9600 100644
--- a/j2cl-maven-plugin/src/it/gwt-modules-project/pom.xml
+++ b/j2cl-maven-plugin/src/it/gwt-modules-project/pom.xml
@@ -26,11 +26,11 @@
 <!--            <artifactId>gwt-layout</artifactId>-->
 <!--            <version>1.0.0-RC1</version>-->
 <!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>org.gwtproject.event</groupId>-->
-<!--            <artifactId>gwt-event-dom</artifactId>-->
-<!--            <version>1.0.0-RC1</version>-->
-<!--        </dependency>-->
+        <dependency>
+            <groupId>org.gwtproject.event</groupId>
+            <artifactId>gwt-event-dom</artifactId>
+            <version>1.0.0-RC2</version>
+        </dependency>
         <dependency>
             <groupId>org.gwtproject.event</groupId>
             <artifactId>gwt-event-legacy</artifactId>
@@ -41,21 +41,21 @@
             <artifactId>gwt-logical-event</artifactId>
             <version>1.0.0-RC1</version>
         </dependency>
-<!--        <dependency>-->
-<!--            <groupId>org.gwtproject.animation</groupId>-->
-<!--            <artifactId>gwt-animation</artifactId>-->
-<!--            <version>1.0.0-RC1</version>-->
-<!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>org.gwtproject.aria</groupId>-->
-<!--            <artifactId>gwt-aria</artifactId>-->
-<!--            <version>1.0.0-RC1</version>-->
-<!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>org.gwtproject.dom</groupId>-->
-<!--            <artifactId>gwt-dom</artifactId>-->
-<!--            <version>1.0.0-RC1</version>-->
-<!--        </dependency>-->
+        <dependency>
+            <groupId>org.gwtproject.animation</groupId>
+            <artifactId>gwt-animation</artifactId>
+            <version>1.0.0-RC2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.aria</groupId>
+            <artifactId>gwt-aria</artifactId>
+            <version>1.0.0-RC2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.gwtproject.dom</groupId>
+            <artifactId>gwt-dom</artifactId>
+            <version>1.0.0-RC2</version>
+        </dependency>
         <dependency>
             <groupId>org.gwtproject.xhr</groupId>
             <artifactId>gwt-xhr</artifactId>
@@ -146,10 +146,4 @@
             </plugins>
         </pluginManagement>
     </build>
-    <repositories>
-        <repository>
-            <id>google-snapshots</id>
-            <url>https://oss.sonatype.org/content/repositories/google-snapshots/</url>
-        </repository>
-    </repositories>
 </project>