Author: krosenvold Date: Fri Dec 4 14:48:05 2015 New Revision: 1717974 URL: http://svn.apache.org/viewvc?rev=1717974&view=rev Log: Added support for constant pool parsing to find more deps
Now detectes jdk8 lambdas and static refs on jdk8 Added: maven/shared/trunk/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ConstantPoolParser.java maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/pom.xml maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/src/ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/src/main/ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/src/main/java/ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/src/main/java/inlinedStaticReference/ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/src/main/java/inlinedStaticReference/Project.java - copied, changed from r1717675, maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/pom.xml maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/src/ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/src/main/ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/src/main/java/ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/src/main/java/inlinedStaticReference/ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/src/main/java/inlinedStaticReference/Project.java - copied, changed from r1717675, maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java Modified: maven/shared/trunk/maven-dependency-analyzer/pom.xml maven/shared/trunk/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyClassFileVisitor.java maven/shared/trunk/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultProjectDependencyAnalyzerTest.java maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java Modified: maven/shared/trunk/maven-dependency-analyzer/pom.xml URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-analyzer/pom.xml?rev=1717974&r1=1717973&r2=1717974&view=diff ============================================================================== --- maven/shared/trunk/maven-dependency-analyzer/pom.xml (original) +++ maven/shared/trunk/maven-dependency-analyzer/pom.xml Fri Dec 4 14:48:05 2015 @@ -64,6 +64,12 @@ <version>5.0.2</version> </dependency> <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> <version>1.5.1</version> @@ -103,7 +109,7 @@ <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>3.8.2</version> + <version>4.12</version> <scope>test</scope> </dependency> </dependencies> @@ -113,6 +119,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> + <version>2.18.1</version> <configuration> <systemProperties> <property> Added: maven/shared/trunk/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ConstantPoolParser.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ConstantPoolParser.java?rev=1717974&view=auto ============================================================================== --- maven/shared/trunk/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ConstantPoolParser.java (added) +++ maven/shared/trunk/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ConstantPoolParser.java Fri Dec 4 14:48:05 2015 @@ -0,0 +1,171 @@ +package org.apache.maven.shared.dependency.analyzer.asm; + +/* + * 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.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * A small parser to read the constant pool directly, in case it contains references + * ASM does not support. + * + * Adapted from http://stackoverflow.com/a/32278587/23691 + */ +public class ConstantPoolParser +{ + public static final int HEAD = 0xcafebabe; + + // Constant pool types + public static final byte CONSTANT_UTF8 = 1; + + public static final byte CONSTANT_INTEGER = 3; + + public static final byte CONSTANT_FLOAT = 4; + + public static final byte CONSTANT_LONG = 5; + + public static final byte CONSTANT_DOUBLE = 6; + + public static final byte CONSTANT_CLASS = 7; + + public static final byte CONSTANT_STRING = 8; + + public static final byte CONSTANT_FIELDREF = 9; + + public static final byte CONSTANT_METHODREF = 10; + + public static final byte CONSTANT_INTERFACEMETHODREF = 11; + + public static final byte CONSTANT_NAME_AND_TYPE = 12; + + public static final byte CONSTANT_METHODHANDLE = 15; + + public static final byte CONSTANT_METHOD_TYPE = 16; + + public static final byte CONSTANT_INVOKE_DYNAMIC = 18; + + private static final int OXF0 = 0xf0; + + private static final int OXE0 = 0xe0; + + private static final int OX3F = 0x3F; + + static Set<String> getConstantPoolClassReferences( byte[] b ) + { + return parseConstantPoolClassRefereces( ByteBuffer.wrap( b ) ); + } + + static Set<String> parseConstantPoolClassRefereces( ByteBuffer buf ) + { + if ( buf.order( ByteOrder.BIG_ENDIAN ) + .getInt() != HEAD ) + { + return Collections.emptySet(); + } + buf.getChar() ; buf.getChar(); // minor + ver + Set<Integer> classes = new HashSet<Integer>(); + Map<Integer, String> stringConstants = new HashMap<Integer, String>(); + for ( int ix = 1, num = buf.getChar(); ix < num; ix++ ) + { + byte tag = buf.get(); + switch ( tag ) + { + default: + throw new RuntimeException( "Unknown constant pool type" ); + case CONSTANT_UTF8: + stringConstants.put( ix, decodeString( buf ) ); + continue; + case CONSTANT_CLASS: + case CONSTANT_STRING: + case CONSTANT_METHOD_TYPE: + classes.add( (int) buf.getChar() ); + break; + case CONSTANT_FIELDREF: + case CONSTANT_METHODREF: + case CONSTANT_INTERFACEMETHODREF: + case CONSTANT_NAME_AND_TYPE: + buf.getChar(); + buf.getChar(); + break; + case CONSTANT_INTEGER: + buf.getInt(); + break; + case CONSTANT_FLOAT: + buf.getFloat(); + break; + case CONSTANT_DOUBLE: + buf.getDouble(); + break; + case CONSTANT_LONG: + buf.getLong(); + break; + case CONSTANT_METHODHANDLE: + buf.get(); + buf.getChar(); + break; + case CONSTANT_INVOKE_DYNAMIC: + buf.getChar(); + buf.getChar(); + break; + } + } + Set<String> result = new HashSet<String>(); + for ( Integer aClass : classes ) + { + result.add( stringConstants.get( aClass ) ); + } + return result; + } + + private static String decodeString( ByteBuffer buf ) + { + int size = buf.getChar(), oldLimit = buf.limit(); + buf.limit( buf.position() + size ); + StringBuilder sb = new StringBuilder( size + ( size >> 1 ) + 16 ); + while ( buf.hasRemaining() ) + { + byte b = buf.get(); + if ( b > 0 ) + { + sb.append( (char) b ); + } + else + { + int b2 = buf.get(); + if ( ( b & OXF0 ) != OXE0 ) + { + sb.append( (char) ( ( b & 0x1F ) << 6 | b2 & OX3F ) ); + } + else + { + int b3 = buf.get(); + sb.append( (char) ( ( b & 0x0F ) << 12 | ( b2 & OX3F ) << 6 | b3 & OX3F ) ); + } + } + } + buf.limit( oldLimit ); + return sb.toString(); + } +} Modified: maven/shared/trunk/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyClassFileVisitor.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyClassFileVisitor.java?rev=1717974&r1=1717973&r2=1717974&view=diff ============================================================================== --- maven/shared/trunk/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyClassFileVisitor.java (original) +++ maven/shared/trunk/maven-dependency-analyzer/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyClassFileVisitor.java Fri Dec 4 14:48:05 2015 @@ -64,6 +64,12 @@ public class DependencyClassFileVisitor { ClassReader reader = new ClassReader( in ); + final Set<String> constantPoolClassRefs = ConstantPoolParser.getConstantPoolClassReferences( reader.b ); + for ( String string : constantPoolClassRefs ) + { + resultCollector.addName( string ); + } + AnnotationVisitor annotationVisitor = new DefaultAnnotationVisitor( resultCollector ); SignatureVisitor signatureVisitor = new DefaultSignatureVisitor( resultCollector ); FieldVisitor fieldVisitor = new DefaultFieldVisitor( annotationVisitor, resultCollector ); Modified: maven/shared/trunk/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultProjectDependencyAnalyzerTest.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultProjectDependencyAnalyzerTest.java?rev=1717974&r1=1717973&r2=1717974&view=diff ============================================================================== --- maven/shared/trunk/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultProjectDependencyAnalyzerTest.java (original) +++ maven/shared/trunk/maven-dependency-analyzer/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultProjectDependencyAnalyzerTest.java Fri Dec 4 14:48:05 2015 @@ -19,14 +19,7 @@ package org.apache.maven.shared.dependen * under the License. */ -import java.io.File; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Properties; -import java.util.Set; - +import org.apache.commons.lang.SystemUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.ArtifactHandler; @@ -40,10 +33,19 @@ import org.apache.maven.shared.test.plug import org.apache.maven.shared.test.plugin.RepositoryTool; import org.apache.maven.shared.test.plugin.TestToolsException; import org.codehaus.plexus.PlexusTestCase; +import org.junit.Assume; + +import java.io.File; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; +import java.util.Set; /** * Tests <code>DefaultProjectDependencyAnalyzer</code>. - * + * * @author <a href="mailto:markhob...@gmail.com">Mark Hobson</a> * @version $Id$ * @see DefaultProjectDependencyAnalyzer @@ -78,7 +80,8 @@ public class DefaultProjectDependencyAna if ( localRepo == null ) { RepositoryTool repositoryTool = (RepositoryTool) lookup( RepositoryTool.ROLE ); - localRepo = repositoryTool.findLocalRepositoryDirectory().getAbsoluteFile(); + localRepo = repositoryTool.findLocalRepositoryDirectory() + .getAbsoluteFile(); System.out.println( "Local repository: " + localRepo ); } @@ -115,6 +118,55 @@ public class DefaultProjectDependencyAna assertEquals( expectedAnalysis, actualAnalysis ); } + public void testJava8methodRefs() + throws TestToolsException, ProjectDependencyAnalyzerException + { + if ( !SystemUtils.isJavaVersionAtLeast( 180 ) ) + { + return; + } + // Only visible through constant pool analysis + compileProject( "java8methodRefs/pom.xml" ); + + MavenProject project = getProject( "java8methodRefs/pom.xml" ); + + ProjectDependencyAnalysis actualAnalysis = analyzer.analyze( project ); + + Artifact project1 = createArtifact( "commons-io", "commons-io", "jar", "2.4", "compile" ); + Artifact project2 = createArtifact( "commons-lang", "commons-lang", "jar", "2.6", "compile" ); + Set<Artifact> usedDeclaredArtifacts = new HashSet<Artifact>( Arrays.asList( project1, project2 ) ); + + ProjectDependencyAnalysis expectedAnalysis = + new ProjectDependencyAnalysis( usedDeclaredArtifacts, new HashSet<Artifact>(), new HashSet<Artifact>() ); + + assertEquals( expectedAnalysis, actualAnalysis ); + } + + + public void testInlinedStaticReferece() + throws TestToolsException, ProjectDependencyAnalyzerException + { + if ( !SystemUtils.isJavaVersionAtLeast( 180 ) ) + { + return; + } + + // Only visible through constant pool analysis + compileProject( "inlinedStaticReference/pom.xml" ); + + MavenProject project = getProject( "inlinedStaticReference/pom.xml" ); + + ProjectDependencyAnalysis actualAnalysis = analyzer.analyze( project ); + + Artifact project1 = createArtifact( "dom4j", "dom4j", "jar", "1.6.1", "compile" ); + Set<Artifact> usedDeclaredArtifacts = Collections.singleton( project1 ); + + ProjectDependencyAnalysis expectedAnalysis = + new ProjectDependencyAnalysis( usedDeclaredArtifacts, new HashSet<Artifact>(), new HashSet<Artifact>() ); + + assertEquals( expectedAnalysis, actualAnalysis ); + } + public void testJarWithCompileDependency() throws TestToolsException, ProjectDependencyAnalyzerException { @@ -122,11 +174,13 @@ public class DefaultProjectDependencyAna MavenProject project2 = getProject( "jarWithCompileDependency/project2/pom.xml" ); - if ( project2.getBuild().getOutputDirectory().contains( "${" ) ) + if ( project2.getBuild() + .getOutputDirectory() + .contains( "${" ) ) { // if Maven version used as dependency is upgraded to >= 2.2.0 - throw new TestToolsException( "output directory was not interpolated: " - + project2.getBuild().getOutputDirectory() ); + throw new TestToolsException( "output directory was not interpolated: " + project2.getBuild() + .getOutputDirectory() ); } ProjectDependencyAnalysis actualAnalysis = analyzer.analyze( project2 ); @@ -143,6 +197,13 @@ public class DefaultProjectDependencyAna public void testJarWithTestDependency() throws TestToolsException, ProjectDependencyAnalyzerException { + if ( SystemUtils.isJavaVersionAtLeast( 180 ) ) + { + return; + } + + Assume.assumeTrue( !SystemUtils.isJavaVersionAtLeast( 180 ) ); + compileProject( "jarWithTestDependency/pom.xml" ); MavenProject project2 = getProject( "jarWithTestDependency/project2/pom.xml" ); @@ -150,8 +211,8 @@ public class DefaultProjectDependencyAna ProjectDependencyAnalysis actualAnalysis = analyzer.analyze( project2 ); Artifact project1 = - createArtifact( "org.apache.maven.shared.dependency-analyzer.tests", "jarWithTestDependency1", "jar", - "1.0", "test" ); + createArtifact( "org.apache.maven.shared.dependency-analyzer.tests", "jarWithTestDependency1", "jar", "1.0", + "test" ); Set<Artifact> usedDeclaredArtifacts = Collections.singleton( project1 ); Artifact junit = createArtifact( "junit", "junit", "jar", "3.8.1", "test" ); @@ -164,7 +225,7 @@ public class DefaultProjectDependencyAna // MSHARED-253: force used dependency (which is actually used but not detected) ProjectDependencyAnalysis forcedAnalysis = - actualAnalysis.forceDeclaredDependenciesUsage( new String[] { "junit:junit" } ); + actualAnalysis.forceDeclaredDependenciesUsage( new String[]{ "junit:junit" } ); usedDeclaredArtifacts = new HashSet<Artifact>( Arrays.asList( project1, junit ) ); expectedAnalysis = new ProjectDependencyAnalysis( usedDeclaredArtifacts, null, null ); @@ -176,10 +237,11 @@ public class DefaultProjectDependencyAna forcedAnalysis.forceDeclaredDependenciesUsage( new String[]{ "junit:junit" } ); fail( "failure expected since junit dependency is declared-used" ); } - catch( ProjectDependencyAnalyzerException pdae ) + catch ( ProjectDependencyAnalyzerException pdae ) { - assertTrue( pdae.getMessage().contains( "Trying to force use of dependencies which are " - + "declared but already detected as used: [junit:junit]" ) ); + assertTrue( pdae.getMessage() + .contains( "Trying to force use of dependencies which are " + + "declared but already detected as used: [junit:junit]" ) ); } try @@ -187,13 +249,40 @@ public class DefaultProjectDependencyAna forcedAnalysis.forceDeclaredDependenciesUsage( new String[]{ "undefined:undefined" } ); fail( "failure expected since undefined dependency is not declared" ); } - catch( ProjectDependencyAnalyzerException pdae ) + catch ( ProjectDependencyAnalyzerException pdae ) { - assertTrue( pdae.getMessage().contains( "Trying to force use of dependencies which are " - + "not declared: [undefined:undefined]" ) ); + assertTrue( pdae.getMessage() + .contains( "Trying to force use of dependencies which are " + + "not declared: [undefined:undefined]" ) ); } } + public void testJarWithTestDependencyJDK8() + throws TestToolsException, ProjectDependencyAnalyzerException + { + if ( !SystemUtils.isJavaVersionAtLeast( 180 ) ) + { + return; + } + + compileProject( "jarWithTestDependency/pom.xml" ); + + MavenProject project2 = getProject( "jarWithTestDependency/project2/pom.xml" ); + + ProjectDependencyAnalysis actualAnalysis = analyzer.analyze( project2 ); + + Artifact project1 = + createArtifact( "org.apache.maven.shared.dependency-analyzer.tests", "jarWithTestDependency1", "jar", "1.0", + "test" ); + Artifact junit = createArtifact( "junit", "junit", "jar", "3.8.1", "test" ); + Set<Artifact> usedDeclaredArtifacts = new HashSet<Artifact>( Arrays.asList( project1, junit ) ); + + ProjectDependencyAnalysis expectedAnalysis = + new ProjectDependencyAnalysis( usedDeclaredArtifacts, null, new HashSet<Artifact>() ); + + assertEquals( expectedAnalysis, actualAnalysis ); + } + public void testJarWithXmlTransitiveDependency() throws TestToolsException, ProjectDependencyAnalyzerException { @@ -206,8 +295,7 @@ public class DefaultProjectDependencyAna Artifact jdom = createArtifact( "dom4j", "dom4j", "jar", "1.6.1", "compile" ); Set<Artifact> usedDeclaredArtifacts = Collections.singleton( jdom ); - ProjectDependencyAnalysis expectedAnalysis = - new ProjectDependencyAnalysis( usedDeclaredArtifacts, null, null ); + ProjectDependencyAnalysis expectedAnalysis = new ProjectDependencyAnalysis( usedDeclaredArtifacts, null, null ); // MSHARED-47: usedUndeclaredArtifacts=[xml-apis:xml-apis:jar:1.0.b2:compile] //assertEquals( expectedAnalysis, actualAnalysis ); @@ -221,11 +309,11 @@ public class DefaultProjectDependencyAna // difficult to create multi-module project with Maven 2.x, so here's hacky solution // to get a inter-module dependency MavenProject project = getProject( "multimoduleProject/module2/pom.xml" ); - @SuppressWarnings( "unchecked" ) - Set<Artifact> dependencyArtifacts = project.getArtifacts(); + @SuppressWarnings( "unchecked" ) Set<Artifact> dependencyArtifacts = project.getArtifacts(); for ( Artifact artifact : dependencyArtifacts ) { - if ( artifact.getArtifactId().equals( "test-module1" ) ) + if ( artifact.getArtifactId() + .equals( "test-module1" ) ) { File dir = getTestFile( "target/test-classes/", "multimoduleProject/module1/target/classes/" ); artifact.setFile( dir ); @@ -237,8 +325,7 @@ public class DefaultProjectDependencyAna Artifact junit = createArtifact( "org.apache.maven.its.dependency", "test-module1", "jar", "1.0", "compile" ); Set<Artifact> usedDeclaredArtifacts = Collections.singleton( junit ); - ProjectDependencyAnalysis expectedAnalysis = - new ProjectDependencyAnalysis( usedDeclaredArtifacts, null, null ); + ProjectDependencyAnalysis expectedAnalysis = new ProjectDependencyAnalysis( usedDeclaredArtifacts, null, null ); assertEquals( expectedAnalysis, actualAnalysis ); } Added: maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/pom.xml URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/pom.xml?rev=1717974&view=auto ============================================================================== --- maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/pom.xml (added) +++ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/pom.xml Fri Dec 4 14:48:05 2015 @@ -0,0 +1,41 @@ +<?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.shared.dependency-analyzer.tests</groupId> + <artifactId>inlinedStaticReference</artifactId> + <version>1.0</version> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>dom4j</groupId> + <artifactId>dom4j</artifactId> + <version>1.6.1</version> + </dependency> + </dependencies> +</project> Copied: maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/src/main/java/inlinedStaticReference/Project.java (from r1717675, maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java) URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/src/main/java/inlinedStaticReference/Project.java?p2=maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/src/main/java/inlinedStaticReference/Project.java&p1=maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java&r1=1717675&r2=1717974&rev=1717974&view=diff ============================================================================== --- maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java (original) +++ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/inlinedStaticReference/src/main/java/inlinedStaticReference/Project.java Fri Dec 4 14:48:05 2015 @@ -1,4 +1,4 @@ -package jarWithTestDependency.project2; +package inlinedStaticReference; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,24 +19,15 @@ package jarWithTestDependency.project2; * under the License. */ -import jarWithTestDependency.project1.Project1; +import org.dom4j.Node; +import org.dom4j.Text; -/** - * - * - * @author <a href="mailto:markhob...@gmail.com">Mark Hobson</a> - * @version $Id$ - */ -public class Project2 +public class Project { - // using a constant from JUnit requires junit dependency but is not detected since the constant - // value is copied, then nothing can be detected in bytecode - public final static int STATUS_ERROR = junit.runner.TestRunListener.STATUS_ERROR; - - // constructors ----------------------------------------------------------- + public static final short myvalue = Node.ELEMENT_NODE; - public Project2() + public Project() { - Project1 project = new Project1(); + // no op } } Modified: maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java?rev=1717974&r1=1717973&r2=1717974&view=diff ============================================================================== --- maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java (original) +++ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java Fri Dec 4 14:48:05 2015 @@ -31,6 +31,7 @@ public class Project2 { // using a constant from JUnit requires junit dependency but is not detected since the constant // value is copied, then nothing can be detected in bytecode + // Not the case any more, since we sniff it from the constant pool public final static int STATUS_ERROR = junit.runner.TestRunListener.STATUS_ERROR; // constructors ----------------------------------------------------------- Added: maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/pom.xml URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/pom.xml?rev=1717974&view=auto ============================================================================== --- maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/pom.xml (added) +++ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/pom.xml Fri Dec 4 14:48:05 2015 @@ -0,0 +1,59 @@ +<?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.shared.dependency-analyzer.tests</groupId> + <artifactId>java8methodreferences</artifactId> + <version>1.0</version> + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.4</version> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.6</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </build> +</project> Copied: maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/src/main/java/inlinedStaticReference/Project.java (from r1717675, maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java) URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/src/main/java/inlinedStaticReference/Project.java?p2=maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/src/main/java/inlinedStaticReference/Project.java&p1=maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java&r1=1717675&r2=1717974&rev=1717974&view=diff ============================================================================== --- maven/shared/trunk/maven-dependency-analyzer/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java (original) +++ maven/shared/trunk/maven-dependency-analyzer/src/test/resources/java8methodRefs/src/main/java/inlinedStaticReference/Project.java Fri Dec 4 14:48:05 2015 @@ -1,4 +1,4 @@ -package jarWithTestDependency.project2; +package inlinedStaticReference; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -19,24 +19,17 @@ package jarWithTestDependency.project2; * under the License. */ -import jarWithTestDependency.project1.Project1; +import java.io.File; +import java.util.function.Function; -/** - * - * - * @author <a href="mailto:markhob...@gmail.com">Mark Hobson</a> - * @version $Id$ - */ -public class Project2 +import org.apache.commons.io.FileUtils; + +public class Project { - // using a constant from JUnit requires junit dependency but is not detected since the constant - // value is copied, then nothing can be detected in bytecode - public final static int STATUS_ERROR = junit.runner.TestRunListener.STATUS_ERROR; - - // constructors ----------------------------------------------------------- - - public Project2() - { - Project1 project = new Project1(); + public static final Function<String, File> souv = FileUtils::getFile; + + public Project() { + Function<Character, String> fn = org.apache.commons.lang.CharUtils::unicodeEscaped; } + }