From 53700b1b0f5b163ada4ccbd2bb2a3fd44040c42d Mon Sep 17 00:00:00 2001
From: Ashley Scopes <73482956+ascopes@users.noreply.github.com>
Date: Fri, 28 Jun 2024 19:01:04 +0100
Subject: [PATCH 1/5] GH-267: Create reproduction for issues resolving
'test-jar' artifacts
---
.../invoker.properties | 17 +++++
.../gh-267-resolve-test-jar/module-1/pom.xml | 47 ++++++++++++
.../gh-267-resolve-test-jar/module-2/pom.xml | 50 +++++++++++++
.../module-2/src/test/protobuf/channel.proto | 27 +++++++
.../src/it/gh-267-resolve-test-jar/pom.xml | 75 +++++++++++++++++++
.../it/gh-267-resolve-test-jar/test.groovy | 22 ++++++
.../src/it/invoker-debug.properties | 1 +
.../src/it/invoker.properties | 2 +
8 files changed, 241 insertions(+)
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/invoker.properties
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-1/pom.xml
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/pom.xml
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/src/test/protobuf/channel.proto
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/pom.xml
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/test.groovy
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/invoker.properties b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/invoker.properties
new file mode 100644
index 00000000..c8b32cfa
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/invoker.properties
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2023 - 2024, Ashley Scopes.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+invoker.goals = install
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-1/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-1/pom.xml
new file mode 100644
index 00000000..b4b89994
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-1/pom.xml
@@ -0,0 +1,47 @@
+
+
+
+ 4.0.0
+
+
+ gh-267-resolver
+ parent
+ @project.version@
+
+
+ module-1
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
+
+
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/pom.xml
new file mode 100644
index 00000000..9a22a482
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/pom.xml
@@ -0,0 +1,50 @@
+
+
+
+ 4.0.0
+
+
+ gh-267-resolver
+ parent
+ @project.version@
+
+
+ module-2
+
+
+
+ ${project.parent.groupId}
+ module-1
+ @project.version@
+ test-jar
+ test
+
+
+
+
+
+
+ io.github.ascopes
+ protobuf-maven-plugin
+
+
+
+
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/src/test/protobuf/channel.proto b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/src/test/protobuf/channel.proto
new file mode 100644
index 00000000..d3e9528a
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/src/test/protobuf/channel.proto
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2023 - 2024, Ashley Scopes.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package users;
+
+option java_multiple_files = true;
+option java_package = "org.example";
+
+message Channel {
+ string id = 1;
+ string name = 2;
+}
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/pom.xml
new file mode 100644
index 00000000..40aa986c
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/pom.xml
@@ -0,0 +1,75 @@
+
+
+
+ 4.0.0
+
+
+ @project.groupId@
+ protobuf-maven-plugin-parent
+ @project.version@
+ ../../../../pom.xml
+
+
+ gh-267-resolver
+ parent
+ pom
+
+
+ module-1
+ module-2
+
+
+
+ 4.27.1
+
+
+
+
+ com.google.protobuf
+ protobuf-java
+ ${protobuf.version}
+
+
+
+
+
+
+
+ @project.groupId@
+ @project.artifactId@
+ @project.version@
+
+
+ ${protobuf.version}
+
+
+
+
+
+ generate-test
+
+
+
+
+
+
+
+
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/test.groovy b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/test.groovy
new file mode 100644
index 00000000..9211b956
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/test.groovy
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2023 - 2024, Ashley Scopes.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.nio.file.Path
+
+import static org.assertj.core.api.Assertions.assertThat
+
+// TODO
+
+return true
diff --git a/protobuf-maven-plugin/src/it/invoker-debug.properties b/protobuf-maven-plugin/src/it/invoker-debug.properties
index 42fc8814..cbd6d936 100644
--- a/protobuf-maven-plugin/src/it/invoker-debug.properties
+++ b/protobuf-maven-plugin/src/it/invoker-debug.properties
@@ -14,6 +14,7 @@
# limitations under the License.
#
+# Verbose (runs Maven with --debug)
invoker.debug = false
invoker.mavenOpts = -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:5005
invoker.quiet = false
diff --git a/protobuf-maven-plugin/src/it/invoker.properties b/protobuf-maven-plugin/src/it/invoker.properties
index cacab5a8..047df706 100644
--- a/protobuf-maven-plugin/src/it/invoker.properties
+++ b/protobuf-maven-plugin/src/it/invoker.properties
@@ -14,5 +14,7 @@
# limitations under the License.
#
+# Verbose (runs Maven with --debug)
+invoker.debug = false
invoker.quiet = false
invoker.timeoutInSeconds = 300
From 33ea548dd8cf5b1b0f5c4b30a3eb3ea5d947e193 Mon Sep 17 00:00:00 2001
From: Ashley Scopes <73482956+ascopes@users.noreply.github.com>
Date: Fri, 28 Jun 2024 19:02:19 +0100
Subject: [PATCH 2/5] GH-267: Resolve artifact types correctly
Use the artifact type registry provided by Aether to correctly
map the types of dependencies to their expected artifact type
directly. This enables mapping between 'test-jar' and the expected
*.jar file extension correctly, and should fix GH-267.
---
.../AetherMavenArtifactPathResolver.java | 52 ++++++++++++++-----
1 file changed, 39 insertions(+), 13 deletions(-)
diff --git a/protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/dependencies/aether/AetherMavenArtifactPathResolver.java b/protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/dependencies/aether/AetherMavenArtifactPathResolver.java
index 7c9aa438..067e300b 100644
--- a/protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/dependencies/aether/AetherMavenArtifactPathResolver.java
+++ b/protobuf-maven-plugin/src/main/java/io/github/ascopes/protobufmavenplugin/dependencies/aether/AetherMavenArtifactPathResolver.java
@@ -37,6 +37,8 @@
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.ArtifactType;
+import org.eclipse.aether.artifact.ArtifactTypeRegistry;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.collection.CollectRequest;
import org.eclipse.aether.graph.Dependency;
@@ -65,6 +67,7 @@ public class AetherMavenArtifactPathResolver {
private final MavenSession mavenSession;
private final ArtifactHandler artifactHandler;
+ private final ArtifactTypeRegistry artifactTypeRegistry;
private final RepositorySystem repositorySystem;
private final RepositorySystemSession repositorySession;
private final List remoteRepositories;
@@ -75,12 +78,14 @@ public AetherMavenArtifactPathResolver(
RepositorySystem repositorySystem,
ArtifactHandler artifactHandler
) {
+ repositorySession = new ProtobufMavenPluginRepositorySession(
+ mavenSession.getRepositorySession());
+
this.mavenSession = mavenSession;
this.repositorySystem = repositorySystem;
+ artifactTypeRegistry = repositorySession.getArtifactTypeRegistry();
this.artifactHandler = artifactHandler;
- var defaultRepositorySession = mavenSession.getRepositorySession();
- repositorySession = new ProtobufMavenPluginRepositorySession(defaultRepositorySession);
remoteRepositories = RepositoryUtils
.toRepos(mavenSession.getProjectBuildingRequest().getRemoteRepositories());
@@ -124,7 +129,7 @@ public Path resolveArtifact(MavenArtifact artifact) throws ResolutionException {
* Resolve all given dependencies based on their resolution depth semantics.
*
* @param artifacts the artifacts to resolve.
- * @param defaultDependencyResolutionDepth the project default dependency resolution depth.
+ * @param defaultDependencyResolutionDepth the project default dependency resolution depth.\
* @param includeProjectDependencies whether to also resolve project dependencies and return
* them in the result.
* @return the paths to each resolved artifact.
@@ -174,8 +179,8 @@ private Artifact createArtifact(MavenArtifact artifact) {
return new DefaultArtifact(
artifact.getGroupId(),
artifact.getArtifactId(),
- effectiveClassifier(artifact.getClassifier()),
- effectiveExtension(artifact.getType()),
+ classifierOrDefault(artifact.getClassifier()),
+ extensionOrDefault(artifact.getType()), // MavenArtifact types <-> Aether extensions
artifact.getVersion()
);
}
@@ -205,9 +210,10 @@ private Dependency createDependency(
var artifact = new DefaultArtifact(
mavenDependency.getGroupId(),
mavenDependency.getArtifactId(),
- effectiveClassifier(mavenDependency.getClassifier()),
- effectiveExtension(mavenDependency.getType()),
- mavenDependency.getVersion()
+ classifierOrDefault(mavenDependency.getClassifier()),
+ null, // Inferred
+ mavenDependency.getVersion(),
+ extensionToType(mavenDependency.getType())
);
var exclusions = mavenDependency.getExclusions()
@@ -228,14 +234,34 @@ private Dependency createDependency(
);
}
- private @Nullable String effectiveClassifier(@Nullable String classifier) {
- return Optional.ofNullable(classifier).orElseGet(artifactHandler::getClassifier);
+ private @Nullable String classifierOrDefault(@Nullable String classifier) {
+ // .getClassifier can return null in this case to imply a default classifier to Aether.
+ return Optional.ofNullable(classifier)
+ .orElseGet(artifactHandler::getClassifier);
+ }
+
+ private @Nullable ArtifactType extensionToType(@Nullable String extension) {
+ if (extension == null) {
+ extension = requireNonNullElse(artifactHandler.getExtension(), "jar");
+ }
+
+ var type = artifactTypeRegistry.get(extension);
+ log.debug(
+ "Resolved extension {} to Aether type (classifier: {}, type: {}, id: {}, properties: {})",
+ extension,
+ type.getClassifier(),
+ type.getExtension(),
+ type.getId(),
+ type.getProperties()
+ );
+ return type;
}
- private String effectiveExtension(@Nullable String extension) {
+ private String extensionOrDefault(@Nullable String extension) {
// We have to provide a sensible default here if it isn't provided by the artifact
- // handler, otherwise we fall over in a heap. Not entirely sure why this doesn't matter
- // for classifiers...
+ // handler, otherwise we fall over in a heap because Maven implicitly infers this information
+ // whereas Aether does not. For some reason, this is mandatory whereas classifiers can be
+ // totally inferred if null.
return Optional.ofNullable(extension)
.or(() -> Optional.ofNullable(artifactHandler.getExtension()))
.orElse("jar");
From aac9f408334c3c8017a8263983aa5925aa95840c Mon Sep 17 00:00:00 2001
From: Ashley Scopes <73482956+ascopes@users.noreply.github.com>
Date: Fri, 28 Jun 2024 19:04:08 +0100
Subject: [PATCH 3/5] GH-267: Remove unneeded test.groovy
---
.../it/gh-267-resolve-test-jar/test.groovy | 22 -------------------
1 file changed, 22 deletions(-)
delete mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/test.groovy
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/test.groovy b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/test.groovy
deleted file mode 100644
index 9211b956..00000000
--- a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/test.groovy
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2023 - 2024, Ashley Scopes.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.nio.file.Path
-
-import static org.assertj.core.api.Assertions.assertThat
-
-// TODO
-
-return true
From 701a83846bc40d330188abb4659e50c18b8c4118 Mon Sep 17 00:00:00 2001
From: Ashley Scopes <73482956+ascopes@users.noreply.github.com>
Date: Fri, 28 Jun 2024 19:11:32 +0100
Subject: [PATCH 4/5] GH-267: Add regression test for classifier resolution
which previously worked
---
.../invoker.properties | 0
.../module-1/pom.xml | 2 +-
.../module-2/pom.xml | 2 +-
.../module-2/src/test/protobuf/channel.proto | 0
.../pom.xml | 2 +-
.../invoker.properties | 17 +++++
.../module-1/pom.xml | 47 ++++++++++++
.../module-2/pom.xml | 50 +++++++++++++
.../module-2/src/test/protobuf/channel.proto | 27 +++++++
.../gh-267-resolve-tests-classifier/pom.xml | 75 +++++++++++++++++++
10 files changed, 219 insertions(+), 3 deletions(-)
rename protobuf-maven-plugin/src/it/{gh-267-resolve-test-jar => gh-267-resolve-test-jar-type}/invoker.properties (100%)
rename protobuf-maven-plugin/src/it/{gh-267-resolve-test-jar => gh-267-resolve-test-jar-type}/module-1/pom.xml (96%)
rename protobuf-maven-plugin/src/it/{gh-267-resolve-test-jar => gh-267-resolve-test-jar-type}/module-2/pom.xml (96%)
rename protobuf-maven-plugin/src/it/{gh-267-resolve-test-jar => gh-267-resolve-test-jar-type}/module-2/src/test/protobuf/channel.proto (100%)
rename protobuf-maven-plugin/src/it/{gh-267-resolve-test-jar => gh-267-resolve-test-jar-type}/pom.xml (97%)
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/invoker.properties
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-1/pom.xml
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-2/pom.xml
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-2/src/test/protobuf/channel.proto
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/pom.xml
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/invoker.properties b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/invoker.properties
similarity index 100%
rename from protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/invoker.properties
rename to protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/invoker.properties
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-1/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-1/pom.xml
similarity index 96%
rename from protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-1/pom.xml
rename to protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-1/pom.xml
index b4b89994..f21343b3 100644
--- a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-1/pom.xml
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-1/pom.xml
@@ -22,7 +22,7 @@
4.0.0
- gh-267-resolver
+ gh-267-resolve-test-jar-type
parent
@project.version@
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-2/pom.xml
similarity index 96%
rename from protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/pom.xml
rename to protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-2/pom.xml
index 9a22a482..5213b66f 100644
--- a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/pom.xml
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-2/pom.xml
@@ -22,7 +22,7 @@
4.0.0
- gh-267-resolver
+ gh-267-resolve-test-jar-type
parent
@project.version@
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/src/test/protobuf/channel.proto b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-2/src/test/protobuf/channel.proto
similarity index 100%
rename from protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/module-2/src/test/protobuf/channel.proto
rename to protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-2/src/test/protobuf/channel.proto
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/pom.xml
similarity index 97%
rename from protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/pom.xml
rename to protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/pom.xml
index 40aa986c..837b8ae5 100644
--- a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar/pom.xml
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/pom.xml
@@ -28,7 +28,7 @@
../../../../pom.xml
- gh-267-resolver
+ gh-267-resolve-test-jar-type
parent
pom
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/invoker.properties b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/invoker.properties
new file mode 100644
index 00000000..c8b32cfa
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/invoker.properties
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2023 - 2024, Ashley Scopes.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+invoker.goals = install
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-1/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-1/pom.xml
new file mode 100644
index 00000000..1fe7f57d
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-1/pom.xml
@@ -0,0 +1,47 @@
+
+
+
+ 4.0.0
+
+
+ gh-267-resolve-tests-classifier
+ parent
+ @project.version@
+
+
+ module-1
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
+
+
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-2/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-2/pom.xml
new file mode 100644
index 00000000..2c1c436c
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-2/pom.xml
@@ -0,0 +1,50 @@
+
+
+
+ 4.0.0
+
+
+ gh-267-resolve-tests-classifier
+ parent
+ @project.version@
+
+
+ module-2
+
+
+
+ ${project.parent.groupId}
+ module-1
+ @project.version@
+ tests
+ test
+
+
+
+
+
+
+ io.github.ascopes
+ protobuf-maven-plugin
+
+
+
+
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-2/src/test/protobuf/channel.proto b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-2/src/test/protobuf/channel.proto
new file mode 100644
index 00000000..d3e9528a
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-2/src/test/protobuf/channel.proto
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2023 - 2024, Ashley Scopes.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package users;
+
+option java_multiple_files = true;
+option java_package = "org.example";
+
+message Channel {
+ string id = 1;
+ string name = 2;
+}
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/pom.xml
new file mode 100644
index 00000000..735b9037
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/pom.xml
@@ -0,0 +1,75 @@
+
+
+
+ 4.0.0
+
+
+ @project.groupId@
+ protobuf-maven-plugin-parent
+ @project.version@
+ ../../../../pom.xml
+
+
+ gh-267-resolve-tests-classifier
+ parent
+ pom
+
+
+ module-1
+ module-2
+
+
+
+ 4.27.1
+
+
+
+
+ com.google.protobuf
+ protobuf-java
+ ${protobuf.version}
+
+
+
+
+
+
+
+ @project.groupId@
+ @project.artifactId@
+ @project.version@
+
+
+ ${protobuf.version}
+
+
+
+
+
+ generate-test
+
+
+
+
+
+
+
+
From f0ac8098b9021f5572fdc55f4f4e2b1ca018bc71 Mon Sep 17 00:00:00 2001
From: Ashley Scopes <73482956+ascopes@users.noreply.github.com>
Date: Fri, 28 Jun 2024 19:19:18 +0100
Subject: [PATCH 5/5] GH-267: Add extra test data to verify imports work
correctly
---
.../module-1/pom.xml | 5 ++++
.../module-1/src/test/protobuf/message.proto | 27 +++++++++++++++++++
.../module-2/src/test/protobuf/channel.proto | 5 +++-
.../it/gh-267-resolve-test-jar-type/pom.xml | 1 +
.../module-1/pom.xml | 11 ++++++++
.../module-1/src/test/protobuf/message.proto | 27 +++++++++++++++++++
.../module-2/src/test/protobuf/channel.proto | 5 +++-
.../gh-267-resolve-tests-classifier/pom.xml | 1 +
8 files changed, 80 insertions(+), 2 deletions(-)
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-1/src/test/protobuf/message.proto
create mode 100644 protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-1/src/test/protobuf/message.proto
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-1/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-1/pom.xml
index f21343b3..44468f33 100644
--- a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-1/pom.xml
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-1/pom.xml
@@ -31,6 +31,11 @@
+
+ io.github.ascopes
+ protobuf-maven-plugin
+
+
org.apache.maven.plugins
maven-jar-plugin
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-1/src/test/protobuf/message.proto b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-1/src/test/protobuf/message.proto
new file mode 100644
index 00000000..241bf8b0
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-1/src/test/protobuf/message.proto
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2023 - 2024, Ashley Scopes.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package messages;
+
+option java_multiple_files = true;
+option java_package = "org.example";
+
+message Message {
+ string id = 1;
+ string content = 2;
+}
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-2/src/test/protobuf/channel.proto b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-2/src/test/protobuf/channel.proto
index d3e9528a..cbf17ad4 100644
--- a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-2/src/test/protobuf/channel.proto
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/module-2/src/test/protobuf/channel.proto
@@ -16,7 +16,9 @@
syntax = "proto3";
-package users;
+package channels;
+
+import "message.proto";
option java_multiple_files = true;
option java_package = "org.example";
@@ -24,4 +26,5 @@ option java_package = "org.example";
message Channel {
string id = 1;
string name = 2;
+ repeated messages.Message messages = 3;
}
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/pom.xml
index 837b8ae5..61149bb5 100644
--- a/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/pom.xml
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-test-jar-type/pom.xml
@@ -58,6 +58,7 @@
@project.version@
+ true
${protobuf.version}
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-1/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-1/pom.xml
index 1fe7f57d..6f0e0ab1 100644
--- a/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-1/pom.xml
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-1/pom.xml
@@ -30,7 +30,18 @@
module-1
+
+
+ ${project.basedir}/src/test/protobuf
+
+
+
+
+ io.github.ascopes
+ protobuf-maven-plugin
+
+
org.apache.maven.plugins
maven-jar-plugin
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-1/src/test/protobuf/message.proto b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-1/src/test/protobuf/message.proto
new file mode 100644
index 00000000..241bf8b0
--- /dev/null
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-1/src/test/protobuf/message.proto
@@ -0,0 +1,27 @@
+//
+// Copyright (C) 2023 - 2024, Ashley Scopes.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+syntax = "proto3";
+
+package messages;
+
+option java_multiple_files = true;
+option java_package = "org.example";
+
+message Message {
+ string id = 1;
+ string content = 2;
+}
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-2/src/test/protobuf/channel.proto b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-2/src/test/protobuf/channel.proto
index d3e9528a..cbf17ad4 100644
--- a/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-2/src/test/protobuf/channel.proto
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/module-2/src/test/protobuf/channel.proto
@@ -16,7 +16,9 @@
syntax = "proto3";
-package users;
+package channels;
+
+import "message.proto";
option java_multiple_files = true;
option java_package = "org.example";
@@ -24,4 +26,5 @@ option java_package = "org.example";
message Channel {
string id = 1;
string name = 2;
+ repeated messages.Message messages = 3;
}
diff --git a/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/pom.xml b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/pom.xml
index 735b9037..1a572254 100644
--- a/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/pom.xml
+++ b/protobuf-maven-plugin/src/it/gh-267-resolve-tests-classifier/pom.xml
@@ -58,6 +58,7 @@
@project.version@
+ true
${protobuf.version}