[MJDEPS-16] Include project dependencies in scan
diff --git a/Jenkinsfile b/Jenkinsfile
index 5839442..144e405 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -17,4 +17,4 @@
* under the License.
*/
-asfMavenTlpPlgnBuild(jdk:['8','11','12','13'])
+asfMavenTlpPlgnBuild(jdk:['8','11','13','14'])
diff --git a/src/it/dependenciesToAnalyze/pom.xml b/src/it/dependenciesToAnalyze/pom.xml
index c6ef9c5..7a39404 100644
--- a/src/it/dependenciesToAnalyze/pom.xml
+++ b/src/it/dependenciesToAnalyze/pom.xml
@@ -43,6 +43,9 @@
<goals>
<goal>jdkinternals</goal>
</goals>
+ <configuration>
+ <includeClasspath>false</includeClasspath>
+ </configuration>
</execution>
</executions>
</plugin>
diff --git a/src/it/includeClasspath/invoker.properties b/src/it/includeClasspath/invoker.properties
new file mode 100644
index 0000000..f5d8d2d
--- /dev/null
+++ b/src/it/includeClasspath/invoker.properties
@@ -0,0 +1,20 @@
+# 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.
+
+invoker.java.version=1.8+
+invoker.goals=process-classes
+invoker.buildResult=failure
\ No newline at end of file
diff --git a/src/it/includeClasspath/pom.xml b/src/it/includeClasspath/pom.xml
new file mode 100644
index 0000000..05e945e
--- /dev/null
+++ b/src/it/includeClasspath/pom.xml
@@ -0,0 +1,60 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<!--
+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.
+-->
+
+<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>org.apache.maven.plugins.jdeps.its</groupId>
+ <artifactId>basic</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <properties>
+ <maven.compiler.source>1.6</maven.compiler.source>
+ <maven.compiler.target>1.6</maven.compiler.target>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jdkinternals</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>25.1-jre</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/src/it/includeClasspath/src/main/java/Main.java b/src/it/includeClasspath/src/main/java/Main.java
new file mode 100644
index 0000000..5a677ab
--- /dev/null
+++ b/src/it/includeClasspath/src/main/java/Main.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+public class Main
+{
+ public static void main( String[] args )
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/it/includeClasspath/verify.groovy b/src/it/includeClasspath/verify.groovy
new file mode 100644
index 0000000..086fbdd
--- /dev/null
+++ b/src/it/includeClasspath/verify.groovy
@@ -0,0 +1,33 @@
+
+/*
+ * 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.
+ */
+
+def buildLog = new File( basedir, 'build.log' )
+
+def found = false;
+
+buildLog.readLines().each { String line ->
+
+ if ( line.contains( 'Found offending packages' ) )
+ {
+ found = true;
+ }
+}
+
+assert found : "No offending packages"
diff --git a/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java b/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java
index 0140e82..b6c2074 100644
--- a/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java
@@ -79,15 +79,23 @@
*/
@Parameter( defaultValue = "true", property = "jdeps.failOnWarning" )
private boolean failOnWarning;
-
+
/**
* Specifies the version when processing multi-release JAR files version should be an integer >=9 or base.
- *
+ *
* @since 3.1.1
*/
@Parameter( property = "jdeps.multiRelease" )
private String multiRelease;
-
+
+ /**
+ * Whether only the sources need to be compatible or also every dependency on the classpath.
+ *
+ * @since 3.1.3
+ */
+ @Parameter( defaultValue = "true", property = "jdeps.includeClasspath" )
+ private boolean includeClasspath;
+
/**
* Additional dependencies which should be analyzed besides the classes.
* Specify as {@code groupId:artifactId}, allowing ant-pattern.
@@ -227,8 +235,16 @@
// jdeps [options] classes ...
Commandline cmd = new Commandline();
cmd.setExecutable( jExecutable );
-
- Set<Path> dependenciesToAnalyze = getDependenciesToAnalyze();
+
+ Set<Path> dependenciesToAnalyze = null;
+ try
+ {
+ dependenciesToAnalyze = getDependenciesToAnalyze( includeClasspath );
+ }
+ catch ( DependencyResolutionRequiredException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
addJDepsOptions( cmd, dependenciesToAnalyze );
addJDepsClasses( cmd, dependenciesToAnalyze );
@@ -370,12 +386,18 @@
// cmd.createArg().setValue( "-version" );
}
- protected Set<Path> getDependenciesToAnalyze()
+ protected Set<Path> getDependenciesToAnalyze( boolean includeClasspath )
+ throws DependencyResolutionRequiredException
{
Set<Path> jdepsClasses = new LinkedHashSet<>();
jdepsClasses.add( Paths.get( getClassesDirectory() ) );
-
+
+ if ( includeClasspath )
+ {
+ jdepsClasses.addAll( getClassPath() );
+ }
+
if ( dependenciesToAnalyzeIncludes != null )
{
MatchPatterns includes = MatchPatterns.from( dependenciesToAnalyzeIncludes );