From 383403f24ed8e6d7062a496fc71dd49c97d4df77 Mon Sep 17 00:00:00 2001 From: Simon Urli Date: Thu, 19 Oct 2017 14:45:25 +0200 Subject: [PATCH 1/2] One should not pass optional dependency --- src/main/java/spoon/MavenLauncher.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/spoon/MavenLauncher.java b/src/main/java/spoon/MavenLauncher.java index aba83047db3..c3cacfccfe0 100644 --- a/src/main/java/spoon/MavenLauncher.java +++ b/src/main/java/spoon/MavenLauncher.java @@ -268,9 +268,6 @@ public List getDependencies(boolean isLib) { if (version.startsWith("[")) { version = version.substring(1, version.indexOf(',')); } - if (dependency.isOptional()) { - continue; - } // ignore test dependencies for app source code if ("test".equals(dependency.getScope()) && SOURCE_TYPE.APP_SOURCE == sourceType) { continue; From 7ae2217d25dd5e4472c262dab77b39fd49ee4fcf Mon Sep 17 00:00:00 2001 From: Simon Urli Date: Thu, 19 Oct 2017 14:58:57 +0200 Subject: [PATCH 2/2] Change the behaviour for isOptional. Put some doc --- src/main/java/spoon/MavenLauncher.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/spoon/MavenLauncher.java b/src/main/java/spoon/MavenLauncher.java index c3cacfccfe0..b774039feed 100644 --- a/src/main/java/spoon/MavenLauncher.java +++ b/src/main/java/spoon/MavenLauncher.java @@ -237,6 +237,8 @@ private String extractVariable(String value) { /** * Get the list of dependencies available in the local maven repository + * + * @param isLib: If false take dependency of the main project; if true, take dependencies of a library of the project * @return the list of dependencies */ public List getDependencies(boolean isLib) { @@ -268,6 +270,11 @@ public List getDependencies(boolean isLib) { if (version.startsWith("[")) { version = version.substring(1, version.indexOf(',')); } + // pass only the optional dependency if it's in a library dependency + if (isLib && dependency.isOptional()) { + continue; + } + // ignore test dependencies for app source code if ("test".equals(dependency.getScope()) && SOURCE_TYPE.APP_SOURCE == sourceType) { continue;