diff --git a/src/it/projects/bugs/massembly-1022/pom.xml b/src/it/projects/bugs/massembly-1022/pom.xml
new file mode 100644
index 00000000..abfa05e3
--- /dev/null
+++ b/src/it/projects/bugs/massembly-1022/pom.xml
@@ -0,0 +1,82 @@
+
+
+ 4.0.0
+
+
+ org.apache.maven.plugin.assembly.test
+ it-project-parent
+ 1
+
+
+ test
+ massembly-1022
+ 0.0.1-SNAPSHOT
+ pom
+
+
+ We have scope compile in assembly descriptor, so dependencies in runtime scope can be unresolved
+
+
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.36
+ runtime
+
+
+
+
+
+
+ org.slf4j
+ slf4j-simple
+ 1.7.36
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+
+ package
+
+ single
+
+
+
+
+
+ zip
+
+
+ src/assembly/assembly.xml
+
+
+
+
+
+
+
diff --git a/src/it/projects/bugs/massembly-1022/src/assembly/assembly.xml b/src/it/projects/bugs/massembly-1022/src/assembly/assembly.xml
new file mode 100644
index 00000000..e9fe4a92
--- /dev/null
+++ b/src/it/projects/bugs/massembly-1022/src/assembly/assembly.xml
@@ -0,0 +1,31 @@
+
+
+
+ assembly
+ false
+
+
+
+ compile
+
+
+
diff --git a/src/it/projects/bugs/massembly-1022/verify.groovy b/src/it/projects/bugs/massembly-1022/verify.groovy
new file mode 100644
index 00000000..50e5eaa7
--- /dev/null
+++ b/src/it/projects/bugs/massembly-1022/verify.groovy
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.util.zip.ZipFile
+
+def zipFile = new ZipFile(new File(basedir, "target/massembly-1022-0.0.1-SNAPSHOT-assembly.zip"));
+assert zipFile.getEntry("slf4j-simple-1.7.36.jar") != null
+assert zipFile.entries().size() == 1
diff --git a/src/main/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolver.java b/src/main/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolver.java
index 6bbd7b00..e9eef03b 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolver.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolver.java
@@ -260,14 +260,19 @@ public boolean visitEnter(DependencyNode node) {
@Override
public boolean visitLeave(DependencyNode node) {
- if (node.getDependency() != null) {
+ Dependency dependency = node.getDependency();
+ if (dependency != null) {
Artifact artifact = aetherToMavenArtifacts.computeIfAbsent(
- node.getDependency().getArtifact(), RepositoryUtils::toArtifact);
- List depTrail = new ArrayList<>();
- stack.descendingIterator().forEachRemaining(depTrail::add);
+ dependency.getArtifact(), RepositoryUtils::toArtifact);
+ if (artifact.isResolved() && artifact.getFile() != null) {
+ List depTrail = new ArrayList<>();
+ stack.descendingIterator().forEachRemaining(depTrail::add);
+ artifact.setDependencyTrail(depTrail);
+ artifact.setOptional(dependency.isOptional());
+ artifact.setScope(dependency.getScope());
+ artifacts.add(artifact);
+ }
stack.pop();
- artifact.setDependencyTrail(depTrail);
- artifacts.add(artifact);
}
return true;
}
diff --git a/src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java b/src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java
index fb311754..362becf8 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/artifact/DefaultDependencyResolverTest.java
@@ -83,10 +83,10 @@ public void test_getDependencySetResolutionRequirements_transitive() throws Exce
artifacts.add(newArtifact("g.id", "a-id", "1"));
artifacts.add(newArtifact("g.id", "a-id-2", "2"));
- DefaultDependencyNode node1 = new DefaultDependencyNode(
- new Dependency(new org.eclipse.aether.artifact.DefaultArtifact("g.id:a-id:1"), "runtime"));
- DefaultDependencyNode node2 = new DefaultDependencyNode(
- new Dependency(new org.eclipse.aether.artifact.DefaultArtifact("g.id:a-id-2:2"), "runtime"));
+ DefaultDependencyNode node1 = new DefaultDependencyNode(new Dependency(
+ new org.eclipse.aether.artifact.DefaultArtifact("g.id:a-id:1").setFile(new File(".")), "runtime"));
+ DefaultDependencyNode node2 = new DefaultDependencyNode(new Dependency(
+ new org.eclipse.aether.artifact.DefaultArtifact("g.id:a-id-2:2").setFile(new File(".")), "runtime"));
DependencyResult dependencyResult = new DependencyResult(new DependencyRequest());
DefaultDependencyNode rootDependencyNode = new DefaultDependencyNode((Dependency) null);
@@ -177,8 +177,9 @@ public void test_getModuleSetResolutionRequirements_includeDeps() throws Excepti
// FIXME - this is not checked - because ms.UseAllReactorProjects is false
ms.addInclude("*:module-1");
- DefaultDependencyNode node1 = new DefaultDependencyNode(
- new Dependency(new org.eclipse.aether.artifact.DefaultArtifact("group.id:module-1-dep:1"), "runtime"));
+ DefaultDependencyNode node1 = new DefaultDependencyNode(new Dependency(
+ new org.eclipse.aether.artifact.DefaultArtifact("group.id:module-1-dep:1").setFile(new File(".")),
+ "runtime"));
DependencyResult dependencyResult = new DependencyResult(new DependencyRequest());
DefaultDependencyNode rootDependencyNode = new DefaultDependencyNode((Dependency) null);