maven-dependency-analyzer-1.2/ 0000755 0001750 0001750 00000000000 11624300054 016352 5 ustar twerner twerner maven-dependency-analyzer-1.2/pom.xml 0000644 0001750 0001750 00000011514 11525103620 017671 0 ustar twerner twerner
4.0.0
org.apache.maven.shared
maven-shared-components
16
../maven-shared-components/pom.xml
org.apache.maven.shared
maven-dependency-analyzer
jar
1.2
Maven Dependency Analyzer
Analyzes the dependencies of a project for undeclared or unused artifacts.
scm:svn:http://svn.apache.org/repos/asf/maven/shared/tags/maven-dependency-analyzer-1.2
scm:svn:https://svn.apache.org/repos/asf/maven/shared/tags/maven-dependency-analyzer-1.2
http://svn.apache.org/viewvc/maven/shared/tags/maven-dependency-analyzer-1.2
jira
http://jira.codehaus.org/browse/MSHARED/component/13265
asm
asm
3.0
org.codehaus.plexus
plexus-utils
1.5.1
org.apache.maven
maven-project
2.0.5
org.apache.maven
maven-model
2.0.5
org.apache.maven
maven-artifact
2.0.5
org.apache.maven.shared
maven-plugin-testing-tools
1.0-alpha-3
test
jmock
jmock
1.1.0
test
junit
junit
3.8.2
test
org.apache.maven.plugins
maven-surefire-plugin
maven.home
${maven.home}
org.codehaus.plexus
plexus-maven-plugin
descriptor
maven-repo-local
maven.repo.local
maven-surefire-plugin
maven.repo.local
${maven.repo.local}
maven-dependency-analyzer-1.2/src/ 0000755 0001750 0001750 00000000000 11624300054 017141 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/ 0000755 0001750 0001750 00000000000 11624300054 020120 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/ 0000755 0001750 0001750 00000000000 11624300054 022132 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/ 0000755 0001750 0001750 00000000000 11624300054 026401 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project1/ 0000755 0001750 0001750 00000000000 11624300054 030130 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project1/pom.xml 0000644 0001750 0001750 00000002421 11152230410 031436 0 ustar twerner twerner
4.0.0
org.apache.maven.shared.dependency-analyzer.tests
jarWithTestDependency1
jar
1.0
maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project1/src/ 0000755 0001750 0001750 00000000000 11624300054 030717 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project1/src/main/ 0000755 0001750 0001750 00000000000 11624300054 031643 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project1/src/main/java/ 0000755 0001750 0001750 00000000000 11624300054 032564 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000165 00000000000 011567 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project1/src/main/java/jarWithTestDependency/ maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project1/src/main/java/jarWit0000755 0001750 0001750 00000000000 11624300054 033745 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000176 00000000000 011571 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project1/src/main/java/jarWithTestDependency/project1/ maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project1/src/main/java/jarWit0000755 0001750 0001750 00000000000 11624300054 033745 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000213 00000000000 011561 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project1/src/main/java/jarWithTestDependency/project1/Project1.java maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project1/src/main/java/jarWit0000644 0001750 0001750 00000002206 11020006575 033750 0 ustar twerner twerner package jarWithTestDependency.project1;
/*
* 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.
*/
/**
*
*
* @author Mark Hobson
* @version $Id: Project1.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public class Project1
{
// constructors -----------------------------------------------------------
public Project1()
{
// no-op
}
}
maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project2/ 0000755 0001750 0001750 00000000000 11624300054 030131 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project2/pom.xml 0000644 0001750 0001750 00000004046 11152230410 031444 0 ustar twerner twerner
4.0.0
org.apache.maven.shared.dependency-analyzer.tests
jarWithTestDependency2
jar
1.0
org.apache.maven.shared.dependency-analyzer.tests
jarWithTestDependency1
1.0
test
junit
junit
3.8.1
test
maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project2/src/ 0000755 0001750 0001750 00000000000 11624300054 030720 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project2/src/test/ 0000755 0001750 0001750 00000000000 11624300054 031677 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project2/src/test/java/ 0000755 0001750 0001750 00000000000 11624300054 032620 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000165 00000000000 011567 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/ maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWit0000755 0001750 0001750 00000000000 11624300054 034001 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000176 00000000000 011571 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/ maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWit0000755 0001750 0001750 00000000000 11624300054 034001 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000213 00000000000 011561 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/project2/src/test/java/jarWit0000644 0001750 0001750 00000002321 11020006575 034002 0 ustar twerner twerner package jarWithTestDependency.project2;
/*
* 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 jarWithTestDependency.project1.Project1;
/**
*
*
* @author Mark Hobson
* @version $Id: Project2.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public class Project2
{
// constructors -----------------------------------------------------------
public Project2()
{
Project1 project = new Project1();
}
}
maven-dependency-analyzer-1.2/src/test/resources/jarWithTestDependency/pom.xml 0000644 0001750 0001750 00000002542 11152230410 027713 0 ustar twerner twerner
4.0.0
org.apache.maven.shared.dependency-analyzer.tests
jarWithTestDependency
pom
1.0
project1
project2
maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/ 0000755 0001750 0001750 00000000000 11624300054 027052 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project1/ 0000755 0001750 0001750 00000000000 11624300054 030601 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project1/pom.xml 0000644 0001750 0001750 00000002425 11152230410 032113 0 ustar twerner twerner
4.0.0
org.apache.maven.shared.dependency-analyzer.tests
jarWithCompileDependency1
jar
1.0
maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project1/src/ 0000755 0001750 0001750 00000000000 11624300054 031370 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project1/src/main/ 0000755 0001750 0001750 00000000000 11624300054 032314 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project1/src/main/java/ 0000755 0001750 0001750 00000000000 11624300054 033235 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000173 00000000000 011566 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project1/src/main/java/jarWithCompileDependency/ maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project1/src/main/java/jar0000755 0001750 0001750 00000000000 11624300054 033732 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000204 00000000000 011561 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project1/src/main/java/jarWithCompileDependency/project1/ maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project1/src/main/java/jar0000755 0001750 0001750 00000000000 11624300054 033732 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000221 00000000000 011560 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project1/src/main/java/jarWithCompileDependency/project1/Project1.java maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project1/src/main/java/jar0000644 0001750 0001750 00000002211 11020006575 033731 0 ustar twerner twerner package jarWithCompileDependency.project1;
/*
* 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.
*/
/**
*
*
* @author Mark Hobson
* @version $Id: Project1.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public class Project1
{
// constructors -----------------------------------------------------------
public Project1()
{
// no-op
}
}
maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project2/ 0000755 0001750 0001750 00000000000 11624300054 030602 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project2/pom.xml 0000644 0001750 0001750 00000002757 11152230410 032124 0 ustar twerner twerner
4.0.0
org.apache.maven.shared.dependency-analyzer.tests
jarWithCompileDependency2
jar
1.0
org.apache.maven.shared.dependency-analyzer.tests
jarWithCompileDependency1
1.0
maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project2/src/ 0000755 0001750 0001750 00000000000 11624300054 031371 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project2/src/main/ 0000755 0001750 0001750 00000000000 11624300054 032315 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project2/src/main/java/ 0000755 0001750 0001750 00000000000 11624300054 033236 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000173 00000000000 011566 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project2/src/main/java/jarWithCompileDependency/ maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project2/src/main/java/jar0000755 0001750 0001750 00000000000 11624300054 033733 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000204 00000000000 011561 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project2/src/main/java/jarWithCompileDependency/project2/ maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project2/src/main/java/jar0000755 0001750 0001750 00000000000 11624300054 033733 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000221 00000000000 011560 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project2/src/main/java/jarWithCompileDependency/project2/Project2.java maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/project2/src/main/java/jar0000644 0001750 0001750 00000002327 11020006575 033742 0 ustar twerner twerner package jarWithCompileDependency.project2;
/*
* 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 jarWithCompileDependency.project1.Project1;
/**
*
*
* @author Mark Hobson
* @version $Id: Project2.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public class Project2
{
// constructors -----------------------------------------------------------
public Project2()
{
Project1 project = new Project1();
}
}
maven-dependency-analyzer-1.2/src/test/resources/jarWithCompileDependency/pom.xml 0000644 0001750 0001750 00000002545 11152230410 030367 0 ustar twerner twerner
4.0.0
org.apache.maven.shared.dependency-analyzer.tests
jarWithCompileDependency
pom
1.0
project1
project2
maven-dependency-analyzer-1.2/src/test/resources/jarWithNoDependencies/ 0000755 0001750 0001750 00000000000 11624300054 026346 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithNoDependencies/pom.xml 0000644 0001750 0001750 00000002421 11152230410 027654 0 ustar twerner twerner
4.0.0
org.apache.maven.shared.dependency-analyzer.tests
jarWithNoDependencies
jar
1.0
maven-dependency-analyzer-1.2/src/test/resources/jarWithNoDependencies/src/ 0000755 0001750 0001750 00000000000 11624300054 027135 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithNoDependencies/src/main/ 0000755 0001750 0001750 00000000000 11624300054 030061 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/jarWithNoDependencies/src/main/java/ 0000755 0001750 0001750 00000000000 11624300054 031002 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000154 00000000000 011565 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithNoDependencies/src/main/java/jarWithNoDependencies/ maven-dependency-analyzer-1.2/src/test/resources/jarWithNoDependencies/src/main/java/jarWithNoDepend0000755 0001750 0001750 00000000000 11624300054 033750 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000170 00000000000 011563 L ustar root root maven-dependency-analyzer-1.2/src/test/resources/jarWithNoDependencies/src/main/java/jarWithNoDependencies/Project.java maven-dependency-analyzer-1.2/src/test/resources/jarWithNoDependencies/src/main/java/jarWithNoDepend0000644 0001750 0001750 00000002172 11020006575 033755 0 ustar twerner twerner package jarWithNoDependencies;
/*
* 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.
*/
/**
*
*
* @author Mark Hobson
* @version $Id: Project.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public class Project
{
// constructors -----------------------------------------------------------
public Project()
{
// no-op
}
}
maven-dependency-analyzer-1.2/src/test/resources/pom/ 0000755 0001750 0001750 00000000000 11624300054 022725 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/resources/pom/pom.xml 0000644 0001750 0001750 00000002377 11152230410 024245 0 ustar twerner twerner
4.0.0
org.apache.maven.shared.dependency-analyzer.tests
pom
pom
1.0
maven-dependency-analyzer-1.2/src/test/java/ 0000755 0001750 0001750 00000000000 11624300053 021040 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/java/org/ 0000755 0001750 0001750 00000000000 11624300053 021627 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/java/org/apache/ 0000755 0001750 0001750 00000000000 11624300053 023050 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/ 0000755 0001750 0001750 00000000000 11624300053 024156 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/ 0000755 0001750 0001750 00000000000 11624300053 025424 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/ 0000755 0001750 0001750 00000000000 11624300053 027542 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/ 0000755 0001750 0001750 00000000000 11624300054 031370 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000163 00000000000 011565 L ustar root root maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/InputStreamConstraint.java maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/InputStreamC0000644 0001750 0001750 00000005535 11020006575 033702 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.io.IOException;
import java.io.InputStream;
import org.codehaus.plexus.util.IOUtil;
import org.jmock.core.Constraint;
/**
*
*
* @author Mark Hobson
* @version $Id: InputStreamConstraint.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public class InputStreamConstraint
implements Constraint
{
// constants --------------------------------------------------------------
private static final String DEFAULT_CHARSET_NAME = "UTF-8";
// fields -----------------------------------------------------------------
private final String expected;
private final String charsetName;
// constructors -----------------------------------------------------------
public InputStreamConstraint( String expected )
{
this( expected, DEFAULT_CHARSET_NAME );
}
public InputStreamConstraint( String expected, String charsetName )
{
this.expected = expected;
this.charsetName = charsetName;
}
// Constraint methods -----------------------------------------------------
/*
* @see org.jmock.core.Constraint#eval(java.lang.Object)
*/
public boolean eval( Object object )
{
if ( !( object instanceof InputStream ) )
{
return false;
}
InputStream in = (InputStream) object;
try
{
String actual = IOUtil.toString( in, charsetName );
return expected.equals( actual );
}
catch ( IOException exception )
{
return false;
}
}
// SelfDescribing methods -------------------------------------------------
/*
* @see org.jmock.core.SelfDescribing#describeTo(java.lang.StringBuffer)
*/
public StringBuffer describeTo( StringBuffer buffer )
{
buffer.append( "in(" );
buffer.append( "\"" ).append( expected ).append( "\"" );
buffer.append( "," ).append( charsetName );
buffer.append( ")" );
return buffer;
}
}
././@LongLink 0000000 0000000 0000000 00000000166 00000000000 011570 L ustar root root maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultClassAnalyzerTest.java maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultClass0000644 0001750 0001750 00000006367 11346730223 033707 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import java.util.jar.JarOutputStream;
import java.util.zip.ZipException;
import org.codehaus.plexus.util.IOUtil;
/**
* Tests DefaultClassAnalyzer
.
*
* @author Mark Hobson
* @version $Id: DefaultClassAnalyzerTest.java 922584 2010-03-13 15:34:43Z hboutemy $
* @see DefaultClassAnalyzer
*/
public class DefaultClassAnalyzerTest extends AbstractFileTest
{
// tests ------------------------------------------------------------------
public void testAnalyzeWithJar() throws IOException
{
File file = createJar();
JarOutputStream out = new JarOutputStream( new FileOutputStream( file ) );
writeEntry( out, "a/b/c.class", "class a.b.c" );
writeEntry( out, "x/y/z.class", "class x.y.z" );
out.close();
Set expectedClasses = new HashSet();
expectedClasses.add( "a.b.c" );
expectedClasses.add( "x.y.z" );
DefaultClassAnalyzer analyzer = new DefaultClassAnalyzer();
Set actualClasses = analyzer.analyze( file.toURI().toURL() );
assertEquals( expectedClasses, actualClasses );
}
public void testAnalyzeBadJar() throws IOException
{
//to reproduce MDEP-143
File file = createJar();
JarOutputStream out = new JarOutputStream( new FileOutputStream( file ) );
writeEntry( out, "a/b/c.class", "class a.b.c" );
writeEntry( out, "x/y/z.class", "class x.y.z" );
out.close();
//corrupt the jar file by alter its contents
FileInputStream fis = new FileInputStream( file );
ByteArrayOutputStream baos = new ByteArrayOutputStream( 100 );
IOUtil.copy( fis, baos, 100 );
fis.close();
byte [] ba = baos.toByteArray();
ba[50] = 1;
FileOutputStream fos = new FileOutputStream( file );
IOUtil.copy( ba, fos, 100 );
fos.close();
DefaultClassAnalyzer analyzer = new DefaultClassAnalyzer();
try
{
analyzer.analyze( file.toURI().toURL() );
fail( "Exception expected" );
}
catch ( ZipException e )
{
assertTrue( e.getMessage().startsWith( "Cannot process Jar entry on URL:" ) );
}
}
}
././@LongLink 0000000 0000000 0000000 00000000204 00000000000 011561 L ustar root root maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzerExceptionTest.java maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDepen0000644 0001750 0001750 00000003505 11020006575 033701 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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 junit.framework.TestCase;
/**
* Tests ProjectDependencyAnalyzerException
.
*
* @author Mark Hobson
* @version $Id: ProjectDependencyAnalyzerExceptionTest.java 661727 2008-05-30 14:21:49Z bentmann $
* @see ProjectDependencyAnalyzerException
*/
public class ProjectDependencyAnalyzerExceptionTest extends TestCase
{
// tests ------------------------------------------------------------------
public void testConstructor()
{
ProjectDependencyAnalyzerException exception = new ProjectDependencyAnalyzerException( "a" );
assertEquals( "a", exception.getMessage() );
}
public void testConstructorWithThrowable()
{
Throwable throwable = new Exception();
ProjectDependencyAnalyzerException exception = new ProjectDependencyAnalyzerException( "a", throwable );
assertEquals( "a", exception.getMessage() );
assertEquals( throwable, exception.getCause() );
}
}
././@LongLink 0000000 0000000 0000000 00000000173 00000000000 011566 L ustar root root maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalysisTest.java maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDepen0000644 0001750 0001750 00000003661 11020006575 033704 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.HashSet;
import java.util.Set;
import junit.framework.TestCase;
/**
* Tests ProjectDependencyAnalysis
.
*
* @author Mark Hobson
* @version $Id: ProjectDependencyAnalysisTest.java 661727 2008-05-30 14:21:49Z bentmann $
* @see ProjectDependencyAnalysis
*/
public class ProjectDependencyAnalysisTest extends TestCase
{
// tests ------------------------------------------------------------------
public void testConstructor()
{
Set usedDeclaredArtifacts = new HashSet();
Set usedUndeclaredArtifacts = new HashSet();
Set unusedDeclaredArtifacts = new HashSet();
ProjectDependencyAnalysis analysis =
new ProjectDependencyAnalysis( usedDeclaredArtifacts, usedUndeclaredArtifacts, unusedDeclaredArtifacts );
assertEquals( usedDeclaredArtifacts, analysis.getUsedDeclaredArtifacts() );
assertEquals( usedUndeclaredArtifacts, analysis.getUsedUndeclaredArtifacts() );
assertEquals( unusedDeclaredArtifacts, analysis.getUnusedDeclaredArtifacts() );
}
}
maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/ 0000755 0001750 0001750 00000000000 11624300053 032147 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitorTest.java maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/Dependen0000644 0001750 0001750 00000045547 11464577763 033665 0 ustar twerner twerner 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.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import junit.framework.TestCase;
import org.objectweb.asm.Label;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
/**
* Tests DependencyVisitor
.
*
* @author Mark Hobson
* @version $Id: DependencyVisitorTest.java 1031144 2010-11-04 18:48:19Z brianf $
* @see DependencyVisitor
*/
public class DependencyVisitorTest extends TestCase
{
// TODO: finish tests
// fields -----------------------------------------------------------------
private DependencyVisitor visitor;
// TestCase methods -------------------------------------------------------
/*
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception
{
visitor = new DependencyVisitor();
}
// visit tests ------------------------------------------------------------
public void testVisitWithDefaultSuperclass()
{
// class a.b.c
visitor.visit( 50, 0, "a/b/c", null, "java/lang/Object", null );
assertClasses( "java.lang.Object" );
}
public void testVisitWithSuperclass()
{
// class a.b.c
visitor.visit( 50, 0, "a/b/c", null, "x/y/z", null );
assertClasses( "x.y.z" );
}
public void testVisitWithInterface()
{
// class a.b.c implements x.y.z
visitor.visit( 50, 0, "a/b/c", null, "java/lang/Object", new String[] { "x/y/z" } );
assertClasses( "java.lang.Object", "x.y.z" );
}
public void testVisitWithInterfaces()
{
// class a.b.c implements p.q.r, x.y.z
visitor.visit( 50, 0, "a/b/c", null, "java/lang/Object", new String[] { "p/q/r", "x/y/z" } );
assertClasses( "java.lang.Object", "p.q.r", "x.y.z" );
}
public void testVisitWithUnboundedClassTypeParameter()
{
// class a.b.c
String signature = "Ljava/lang/Object;";
visitor.visit( 50, 0, "a/b/c", signature, "java/lang/Object", null );
assertClasses( "java.lang.Object" );
}
public void testVisitWithBoundedClassTypeParameter()
{
// class a.b.c
String signature = "Ljava/lang/Object;";
visitor.visit( 50, 0, "a/b/c", signature, "java/lang/Object", null );
assertClasses( "java.lang.Object", "x.y.z" );
}
public void testVisitWithBoundedClassTypeParameters()
{
// class a.b.c
String signature = "Ljava/lang/Object;";
visitor.visit( 50, 0, "a/b/c", signature, "java/lang/Object", null );
assertClasses( "java.lang.Object", "p.q.r", "x.y.z" );
}
public void testVisitWithGenericInterface()
{
// class a.b.c implements p.q.r
String signature = "Ljava/lang/Object;Lp/q/r;";
visitor.visit( 50, 0, "a/b/c", signature, "java/lang/Object", new String[] { "p.q.r" } );
assertClasses( "java.lang.Object", "p.q.r", "x.y.z" );
}
public void testVisitWithInterfaceBound()
{
// class a.b.c implements x.y.z
String signature = "Ljava/lang/Object;Lx/y/z;";
visitor.visit( 50, 0, "a/b/c", signature, "java/lang/Object", new String[] { "x.y.z" } );
assertClasses( "java.lang.Object", "x.y.z" );
}
// visitSource tests ------------------------------------------------------
public void testVisitSource()
{
visitor.visitSource( null, null );
assertNoClasses();
}
// visitOuterClass tests --------------------------------------------------
public void testVisitOuterClass()
{
// class a.b.c
// {
// class ...
// {
// }
// }
visitor.visitOuterClass( "a/b/c", null, null );
assertNoClasses();
}
public void testVisitOuterClassInMethod()
{
// class a.b.c
// {
// x.y.z x(p.q.r p)
// {
// class ...
// {
// }
// }
// }
visitor.visitOuterClass( "a/b/c", "x", "(Lp/q/r;)Lx/y/z;" );
assertNoClasses();
}
// visitAnnotation tests --------------------------------------------------
public void testVisitAnnotation()
{
assertVisitor( visitor.visitAnnotation( "La/b/c;", false ) );
assertClasses( "a.b.c" );
}
public void testVisitAnnotationWithRuntimeVisibility()
{
assertVisitor( visitor.visitAnnotation( "La/b/c;", true ) );
assertClasses( "a.b.c" );
}
// visitAttribute tests ---------------------------------------------------
public void testVisitAttribute()
{
visitor.visitAttribute( new MockAttribute( "a" ) );
assertNoClasses();
}
// visitInnerClass tests --------------------------------------------------
public void testVisitInnerClass()
{
// TODO: ensure innerName is correct
// class a.b.c { class x.y.z { } }
visitor.visitInnerClass( "x/y/z", "a/b/c", "z", 0 );
assertNoClasses();
}
public void testVisitInnerClassAnonymous()
{
// class a.b.c { new class x.y.z { } }
visitor.visitInnerClass( "x/y/z$1", "a/b/c", null, 0 );
assertNoClasses();
}
// visitField tests -------------------------------------------------------
public void testVisitField()
{
// a.b.c a
assertVisitor( visitor.visitField( 0, "a", "La/b/c;", null, null ) );
assertClasses( "a.b.c" );
}
// TODO: determine actual use of default values
// public void testVisitFieldWithValue()
// {
// }
public void testVisitFieldArray()
{
// a.b.c[] a
assertVisitor( visitor.visitField( 0, "a", "[La/b/c;", null, null ) );
assertClasses( "a.b.c" );
}
public void testVisitFieldGeneric()
{
// a.b.c a
assertVisitor( visitor.visitField( 0, "a", "La/b/c;", "La/b/c;", null ) );
assertClasses( "a.b.c", "x.y.z" );
}
// visitMethod tests ------------------------------------------------------
public void testVisitMethod()
{
// void a()
assertVisitor( visitor.visitMethod( 0, "a", "()V", null, null ) );
assertNoClasses();
}
public void testVisitMethodWithPrimitiveArgument()
{
// void a(int)
assertVisitor( visitor.visitMethod( 0, "a", "(I)V", null, null ) );
assertNoClasses();
}
public void testVisitMethodWithPrimitiveArrayArgument()
{
// void a(int[])
assertVisitor( visitor.visitMethod( 0, "a", "([I)V", null, null ) );
assertNoClasses();
}
public void testVisitMethodWithObjectArgument()
{
// void a(a.b.c)
assertVisitor( visitor.visitMethod( 0, "a", "(La/b/c;)V", null, null ) );
assertClasses( "a.b.c" );
}
public void testVisitMethodWithObjectArguments()
{
// void a(a.b.c, x.y.z)
assertVisitor( visitor.visitMethod( 0, "a", "(La/b/c;Lx/y/z;)V", null, null ) );
assertClasses( "a.b.c", "x.y.z" );
}
public void testVisitMethodWithObjectArrayArgument()
{
// void a(a.b.c[])
assertVisitor( visitor.visitMethod( 0, "a", "([La/b/c;)V", null, null ) );
assertClasses( "a.b.c" );
}
public void testVisitMethodWithGenericArgument()
{
// void a(a.b.c)
assertVisitor( visitor.visitMethod( 0, "a", "(La/b/c;)V", "(La/b/c;)V", null ) );
assertClasses( "a.b.c", "x.y.z" );
}
public void testVisitMethodWithPrimitiveReturnType()
{
// int a()
assertVisitor( visitor.visitMethod( 0, "a", "()I", null, null ) );
assertNoClasses();
}
public void testVisitMethodWithPrimitiveArrayReturnType()
{
// int[] a()
assertVisitor( visitor.visitMethod( 0, "a", "()[I", null, null ) );
assertNoClasses();
}
public void testVisitMethodWithObjectReturnType()
{
// a.b.c a()
assertVisitor( visitor.visitMethod( 0, "a", "()La/b/c;", null, null ) );
assertClasses( "a.b.c" );
}
public void testVisitMethodWithObjectArrayReturnType()
{
// a.b.c[] a()
assertVisitor( visitor.visitMethod( 0, "a", "()[La/b/c;", null, null ) );
assertClasses( "a.b.c" );
}
public void testVisitMethodWithException()
{
// void a() throws a.b.c
assertVisitor( visitor.visitMethod( 0, "a", "()V", null, new String[] { "a/b/c" } ) );
assertClasses( "a.b.c" );
}
public void testVisitMethodWithExceptions()
{
// void a() throws a.b.c, x.y.z
assertVisitor( visitor.visitMethod( 0, "a", "()V", null, new String[] { "a/b/c", "x/y/z" } ) );
assertClasses( "a.b.c", "x.y.z" );
}
// visitAnnotationDefault tests -------------------------------------------
public void testVisitAnnotationDefault()
{
assertVisitor( visitor.visitAnnotationDefault() );
assertNoClasses();
}
// visitParameterAnnotation tests -------------------------------------------
public void testVisitParameterAnnotation()
{
// @a.b.c
assertVisitor( visitor.visitParameterAnnotation( 0, "La/b/c;", false ) );
assertClasses( "a.b.c" );
}
// visitCode tests --------------------------------------------------------
public void testVisitCode()
{
visitor.visitCode();
assertNoClasses();
}
// visitFrame tests -------------------------------------------------------
public void testVisitFrame()
{
visitor.visitFrame( Opcodes.F_NEW, 0, new Object[0], 0, new Object[0] );
assertNoClasses();
}
// visitInsn tests --------------------------------------------------------
public void testVisitInsn()
{
visitor.visitInsn( Opcodes.NOP );
assertNoClasses();
}
// visitIntInsn tests -----------------------------------------------------
public void testVisitIntInsn()
{
visitor.visitIntInsn( Opcodes.BIPUSH, 0 );
assertNoClasses();
}
// visitVarInsn tests -----------------------------------------------------
public void testVisitVarInsn()
{
visitor.visitVarInsn( Opcodes.ILOAD, 0 );
assertNoClasses();
}
// visitTypeInsn tests ----------------------------------------------------
public void testVisitTypeInsn()
{
visitor.visitTypeInsn( Opcodes.NEW, "a/b/c" );
assertClasses( "a.b.c" );
}
// visitFieldInsn tests ---------------------------------------------------
public void testVisitFieldInsnWithPrimitive()
{
visitor.visitFieldInsn( Opcodes.GETFIELD, "a/b/c", "x", "I" );
assertClasses( "a.b.c" );
}
public void testVisitFieldInsnWithObject()
{
visitor.visitFieldInsn( Opcodes.GETFIELD, "a/b/c", "x", "Lx/y/z;" );
assertClasses( "a.b.c" );
}
// visitMethodInsn tests --------------------------------------------------
public void testVisitMethodInsn()
{
visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "()V" );
assertClasses( "a.b.c" );
}
public void testVisitMethodInsnWithPrimitiveArgument()
{
visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "(I)V" );
assertClasses( "a.b.c" );
}
public void testVisitMethodInsnWithPrimitiveArrayArgument()
{
visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "([I)V" );
assertClasses( "a.b.c" );
}
public void testVisitMethodInsnWithObjectArgument()
{
visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "(Lx/y/z;)V" );
assertClasses( "a.b.c" );
}
public void testVisitMethodInsnWithObjectArguments()
{
visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "(Lp/q/r;Lx/y/z;)V" );
assertClasses( "a.b.c" );
}
public void testVisitMethodInsnWithObjectArrayArgument()
{
visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "([Lx/y/z;)V" );
assertClasses( "a.b.c" );
}
public void testVisitMethodInsnWithPrimitiveReturnType()
{
visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "()I" );
assertClasses( "a.b.c" );
}
public void testVisitMethodInsnWithPrimitiveArrayReturnType()
{
visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "()[I" );
assertClasses( "a.b.c" );
}
public void testVisitMethodInsnWithObjectReturnType()
{
visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "()Lx/y/z;" );
assertClasses( "a.b.c" );
}
public void testVisitMethodInsnWithObjectArrayReturnType()
{
visitor.visitMethodInsn( Opcodes.INVOKEVIRTUAL, "a/b/c", "x", "()[Lx/y/z;" );
assertClasses( "a.b.c" );
}
// visitJumpInsn tests ----------------------------------------------------
public void testVisitJumpInsn()
{
visitor.visitJumpInsn( Opcodes.IFEQ, new Label() );
assertNoClasses();
}
// visitLabel tests -------------------------------------------------------
public void testVisitLabel()
{
visitor.visitLabel( new Label() );
assertNoClasses();
}
// visitLdcInsn tests -----------------------------------------------------
public void testVisitLdcInsnWithNonType()
{
visitor.visitLdcInsn( "a" );
assertNoClasses();
}
public void testVisitLdcInsnWithPrimitiveType()
{
visitor.visitLdcInsn( Type.INT_TYPE );
assertNoClasses();
}
public void testVisitLdcInsnWithObjectType()
{
visitor.visitLdcInsn( Type.getType( "La/b/c;" ) );
assertClasses( "a.b.c" );
}
// visitIincInsn tests ----------------------------------------------------
public void testVisitIincInsn()
{
visitor.visitIincInsn( 0, 1 );
assertNoClasses();
}
// visitTableSwitchInsn tests ---------------------------------------------
public void testVisitTableSwitchInsn()
{
visitor.visitTableSwitchInsn( 0, 1, new Label(), new Label[] { new Label() } );
assertNoClasses();
}
// visitLookupSwitchInsn tests --------------------------------------------
public void testVisitLookupSwitchInsn()
{
visitor.visitLookupSwitchInsn( new Label(), new int[] { 0 }, new Label[] { new Label() } );
assertNoClasses();
}
// visitMultiANewArrayInsn tests ------------------------------------------
public void testVisitMultiANewArrayInsnWithPrimitive()
{
visitor.visitMultiANewArrayInsn( "I", 2 );
assertNoClasses();
}
public void testVisitMultiANewArrayInsnWithObject()
{
visitor.visitMultiANewArrayInsn( "La/b/c;", 2 );
assertClasses( "a.b.c" );
}
// visitTryCatchBlock tests -----------------------------------------------
public void testVisitTryCatchBlock()
{
visitor.visitTryCatchBlock( new Label(), new Label(), new Label(), "a/b/c" );
assertClasses( "a.b.c" );
}
public void testVisitTryCatchBlockForFinally()
{
visitor.visitTryCatchBlock( new Label(), new Label(), new Label(), null );
assertNoClasses();
}
// visitLocalVariable tests -----------------------------------------------
public void testVisitLocalVariableWithPrimitive()
{
visitor.visitLocalVariable( "a", "I", null, new Label(), new Label(), 0 );
assertNoClasses();
}
public void testVisitLocalVariableWithPrimitiveArray()
{
visitor.visitLocalVariable( "a", "[I", null, new Label(), new Label(), 0 );
assertNoClasses();
}
public void testVisitLocalVariableWithObject()
{
visitor.visitLocalVariable( "a", "La/b/c;", null, new Label(), new Label(), 0 );
assertClasses( "a.b.c" );
}
public void testVisitLocalVariableWithObjectArray()
{
visitor.visitLocalVariable( "a", "[La/b/c;", null, new Label(), new Label(), 0 );
assertClasses( "a.b.c" );
}
public void testVisitLocalVariableWithGenericObject()
{
visitor.visitLocalVariable( "a", "La/b/c;", "La/b/c;", new Label(), new Label(), 0 );
assertClasses( "a.b.c", "x.y.z" );
}
public void testVisitLocalVariableWithGenericObjectArray()
{
visitor.visitLocalVariable( "a", "La/b/c;", "[La/b/c;", new Label(), new Label(), 0 );
assertClasses( "a.b.c", "x.y.z" );
}
// visitLineNumber tests --------------------------------------------------
public void testVisitLineNumber()
{
visitor.visitLineNumber( 0, new Label() );
assertNoClasses();
}
// visitMaxs tests --------------------------------------------------------
public void testVisitMaxs()
{
visitor.visitMaxs( 0, 0 );
assertNoClasses();
}
// private methods --------------------------------------------------------
private void assertVisitor( Object actualVisitor )
{
assertEquals( visitor, actualVisitor );
}
private void assertNoClasses()
{
assertClasses( Collections.EMPTY_SET );
}
private void assertClasses( String element )
{
assertClasses( Collections.singleton( element ) );
}
private void assertClasses( String expectedClass1, String expectedClass2 )
{
assertClasses( new String[] { expectedClass1, expectedClass2 } );
}
private void assertClasses( String expectedClass1, String expectedClass2, String expectedClass3 )
{
assertClasses( new String[] { expectedClass1, expectedClass2, expectedClass3 } );
}
private void assertClasses( String[] expectedClasses )
{
assertClasses( new HashSet( Arrays.asList( expectedClasses ) ) );
}
private void assertClasses( Set expectedClasses )
{
assertEquals( expectedClasses, visitor.getClasses() );
}
}
././@LongLink 0000000 0000000 0000000 00000000157 00000000000 011570 L ustar root root maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/MockAttribute.java maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/asm/MockAttr0000644 0001750 0001750 00000002445 11020006575 033625 0 ustar twerner twerner 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 org.objectweb.asm.Attribute;
/**
* A simple ASM Attribute
for use in tests.
*
* @author Mark Hobson
* @version $Id: MockAttribute.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public class MockAttribute extends Attribute
{
// constructors -----------------------------------------------------------
public MockAttribute( String type )
{
super( type );
}
}
././@LongLink 0000000 0000000 0000000 00000000156 00000000000 011567 L ustar root root maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/AbstractFileTest.java maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/AbstractFile0000644 0001750 0001750 00000005143 11020006575 033662 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.jar.JarOutputStream;
import java.util.zip.ZipEntry;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.jmock.MockObjectTestCase;
/**
*
*
* @author Mark Hobson
* @version $Id: AbstractFileTest.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public abstract class AbstractFileTest extends MockObjectTestCase
{
// protected methods ------------------------------------------------------
protected File createJar() throws IOException
{
File file = File.createTempFile( "test", ".jar" );
file.deleteOnExit();
return file;
}
protected File createDir() throws IOException
{
File file = File.createTempFile( "test", null );
file.delete();
if ( !file.mkdir() )
throw new IOException( "Cannot create temporary directory: " + file );
return file;
}
protected File createFile( File parent, String child, String data ) throws IOException
{
File file = new File( parent, child );
OutputStream out = new FileOutputStream( file );
IOUtil.copy( data, out );
out.close();
return file;
}
protected File mkdirs( File parent, String child ) throws IOException
{
File dir = new File( parent, child );
FileUtils.forceMkdir( dir );
return dir;
}
protected void writeEntry( JarOutputStream out, String path, String data ) throws IOException
{
out.putNextEntry( new ZipEntry( path ) );
byte[] bytes = data.getBytes( "UTF-8" );
out.write( bytes, 0, bytes.length );
}
}
././@LongLink 0000000 0000000 0000000 00000000202 00000000000 011557 L ustar root root maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultProjectDependencyAnalyzerTest.java maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultProje0000644 0001750 0001750 00000016442 11146006252 033710 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.invoker.InvocationRequest;
import org.apache.maven.shared.invoker.InvocationResult;
import org.apache.maven.shared.test.plugin.BuildTool;
import org.apache.maven.shared.test.plugin.ProjectTool;
import org.apache.maven.shared.test.plugin.RepositoryTool;
import org.apache.maven.shared.test.plugin.TestToolsException;
import org.codehaus.plexus.PlexusTestCase;
/**
* Tests DefaultProjectDependencyAnalyzer
.
*
* @author Mark Hobson
* @version $Id: DefaultProjectDependencyAnalyzerTest.java 744664 2009-02-15 12:38:02Z bentmann $
* @see DefaultProjectDependencyAnalyzer
*/
public class DefaultProjectDependencyAnalyzerTest
extends PlexusTestCase
{
// fields -----------------------------------------------------------------
private BuildTool buildTool;
private ProjectTool projectTool;
private ProjectDependencyAnalyzer analyzer;
private static File localRepo;
// TestCase methods -------------------------------------------------------
/*
* @see org.codehaus.plexus.PlexusTestCase#setUp()
*/
protected void setUp()
throws Exception
{
super.setUp();
buildTool = (BuildTool) lookup( BuildTool.ROLE );
projectTool = (ProjectTool) lookup( ProjectTool.ROLE );
if ( localRepo == null )
{
RepositoryTool repositoryTool = (RepositoryTool) lookup( RepositoryTool.ROLE );
localRepo = repositoryTool.findLocalRepositoryDirectory().getAbsoluteFile();
System.out.println( "Local repository: " + localRepo );
}
analyzer = (ProjectDependencyAnalyzer) lookup( ProjectDependencyAnalyzer.ROLE );
}
// tests ------------------------------------------------------------------
public void testPom()
throws TestToolsException, ProjectDependencyAnalyzerException
{
compileProject( "pom/pom.xml" );
MavenProject project = getProject( "pom/pom.xml" );
ProjectDependencyAnalysis actualAnalysis = analyzer.analyze( project );
ProjectDependencyAnalysis expectedAnalysis = new ProjectDependencyAnalysis();
assertEquals( expectedAnalysis, actualAnalysis );
}
public void testJarWithNoDependencies()
throws TestToolsException, ProjectDependencyAnalyzerException
{
compileProject( "jarWithNoDependencies/pom.xml" );
MavenProject project = getProject( "jarWithNoDependencies/pom.xml" );
ProjectDependencyAnalysis actualAnalysis = analyzer.analyze( project );
ProjectDependencyAnalysis expectedAnalysis = new ProjectDependencyAnalysis();
assertEquals( expectedAnalysis, actualAnalysis );
}
public void testJarWithCompileDependency()
throws TestToolsException, ProjectDependencyAnalyzerException
{
compileProject( "jarWithCompileDependency/pom.xml" );
MavenProject project2 = getProject( "jarWithCompileDependency/project2/pom.xml" );
ProjectDependencyAnalysis actualAnalysis = analyzer.analyze( project2 );
Artifact project1 =
createArtifact( "org.apache.maven.shared.dependency-analyzer.tests", "jarWithCompileDependency1", "jar",
"1.0", "compile" );
Set usedDeclaredArtifacts = Collections.singleton( project1 );
ProjectDependencyAnalysis expectedAnalysis = new ProjectDependencyAnalysis( usedDeclaredArtifacts, null, null );
assertEquals( expectedAnalysis, actualAnalysis );
}
public void testJarWithTestDependency()
throws TestToolsException, ProjectDependencyAnalyzerException
{
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" );
Set usedDeclaredArtifacts = Collections.singleton( project1 );
// TODO: remove workaround for SUREFIRE-300 when 2.3.1 released
Artifact junit = createArtifact( "junit", "junit", "jar", "3.8.1", "test" );
Set unusedDeclaredArtifacts = Collections.singleton( junit );
ProjectDependencyAnalysis expectedAnalysis =
new ProjectDependencyAnalysis( usedDeclaredArtifacts, null, unusedDeclaredArtifacts );
assertEquals( expectedAnalysis, actualAnalysis );
}
// private methods --------------------------------------------------------
private void compileProject( String pomPath )
throws TestToolsException
{
File pom = getTestFile( "target/test-classes/", pomPath );
Properties properties = new Properties();
List goals = Arrays.asList( new String[] { "clean", "install" } );
File log = new File( pom.getParentFile(), "build.log" );
// TODO: don't install test artifacts to local repository
InvocationRequest request = buildTool.createBasicInvocationRequest( pom, properties, goals, log );
request.setLocalRepositoryDirectory( localRepo );
InvocationResult result = buildTool.executeMaven( request );
assertNull( "Error compiling test project", result.getExecutionException() );
assertEquals( "Error compiling test project", 0, result.getExitCode() );
}
private MavenProject getProject( String pomPath )
throws TestToolsException
{
File pom = getTestFile( "target/test-classes/", pomPath );
return projectTool.readProjectWithDependencies( pom );
}
private Artifact createArtifact( String groupId, String artifactId, String type, String version, String scope )
{
VersionRange versionRange = VersionRange.createFromVersion( version );
ArtifactHandler handler = new DefaultArtifactHandler();
return new DefaultArtifact( groupId, artifactId, versionRange, scope, type, null, handler );
}
}
././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/ClassFileVisitorUtilsTest.java maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/ClassFileVis0000644 0001750 0001750 00000011606 11020006575 033647 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.jar.JarOutputStream;
import org.codehaus.plexus.util.FileUtils;
import org.jmock.Mock;
/**
* Tests ClassFileVisitorUtils
.
*
* @author Mark Hobson
* @version $Id: ClassFileVisitorUtilsTest.java 661727 2008-05-30 14:21:49Z bentmann $
* @see ClassFileVisitorUtils
*/
public class ClassFileVisitorUtilsTest
extends AbstractFileTest
{
// tests ------------------------------------------------------------------
public void testAcceptJar()
throws IOException
{
File file = createJar();
JarOutputStream out = new JarOutputStream( new FileOutputStream( file ) );
writeEntry( out, "a/b/c.class", "class a.b.c" );
writeEntry( out, "x/y/z.class", "class x.y.z" );
out.close();
Mock mock = mock( ClassFileVisitor.class );
expectVisitClass( mock, "a.b.c", "class a.b.c" );
expectVisitClass( mock, "x.y.z", "class x.y.z" );
ClassFileVisitorUtils.accept( file.toURI().toURL(), (ClassFileVisitor) mock.proxy() );
mock.verify();
}
public void testAcceptJarWithNonClassEntry()
throws IOException
{
File file = createJar();
JarOutputStream out = new JarOutputStream( new FileOutputStream( file ) );
writeEntry( out, "a/b/c.jpg", "jpeg a.b.c" );
out.close();
Mock mock = mock( ClassFileVisitor.class );
ClassFileVisitorUtils.accept( file.toURI().toURL(), (ClassFileVisitor) mock.proxy() );
mock.verify();
}
public void testAcceptDir()
throws IOException
{
File dir = createDir();
File abDir = mkdirs( dir, "a/b" );
createFile( abDir, "c.class", "class a.b.c" );
File xyDir = mkdirs( dir, "x/y" );
createFile( xyDir, "z.class", "class x.y.z" );
Mock mock = mock( ClassFileVisitor.class );
expectVisitClass( mock, "a.b.c", "class a.b.c" );
expectVisitClass( mock, "x.y.z", "class x.y.z" );
ClassFileVisitorUtils.accept( dir.toURI().toURL(), (ClassFileVisitor) mock.proxy() );
FileUtils.deleteDirectory( dir );
mock.verify();
}
public void testAcceptDirWithNonClassFile()
throws IOException
{
File dir = createDir();
File abDir = mkdirs( dir, "a/b" );
createFile( abDir, "c.jpg", "jpeg a.b.c" );
Mock mock = mock( ClassFileVisitor.class );
ClassFileVisitorUtils.accept( dir.toURI().toURL(), (ClassFileVisitor) mock.proxy() );
FileUtils.deleteDirectory( dir );
mock.verify();
}
public void testAcceptWithFile()
throws IOException
{
File file = File.createTempFile( "test", ".class" );
file.deleteOnExit();
Mock mock = mock( ClassFileVisitor.class );
URL url = file.toURI().toURL();
try
{
ClassFileVisitorUtils.accept( url, (ClassFileVisitor) mock.proxy() );
}
catch ( IllegalArgumentException exception )
{
assertEquals( "Cannot accept visitor on URL: " + url, exception.getMessage() );
}
}
public void testAcceptWithUnsupportedScheme()
throws IOException
{
Mock mock = mock( ClassFileVisitor.class );
URL url = new URL( "http://localhost/" );
try
{
ClassFileVisitorUtils.accept( url, (ClassFileVisitor) mock.proxy() );
}
catch ( IllegalArgumentException exception )
{
assertEquals( "Cannot accept visitor on URL: " + url, exception.getMessage() );
}
}
// private methods --------------------------------------------------------
private void expectVisitClass( Mock mock, String className, String data )
{
mock.expects( atLeastOnce() ).method( "visitClass" ).with( eq( className ), in( data ) );
}
private InputStreamConstraint in( String expected )
{
return new InputStreamConstraint( expected );
}
}
././@LongLink 0000000 0000000 0000000 00000000173 00000000000 011566 L ustar root root maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/CollectorClassFileVisitorTest.java maven-dependency-analyzer-1.2/src/test/java/org/apache/maven/shared/dependency/analyzer/CollectorCla0000644 0001750 0001750 00000004073 11020006575 033666 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.HashSet;
import java.util.Set;
import org.apache.maven.shared.dependency.analyzer.CollectorClassFileVisitor;
import junit.framework.TestCase;
/**
* Tests CollectorClassFileVisitor
.
*
* @author Mark Hobson
* @version $Id: CollectorClassFileVisitorTest.java 661727 2008-05-30 14:21:49Z bentmann $
* @see CollectorClassFileVisitor
*/
public class CollectorClassFileVisitorTest
extends TestCase
{
// fields -----------------------------------------------------------------
private CollectorClassFileVisitor visitor;
// TestCase thods ---------------------------------------------------------
/*
* @see junit.framework.TestCase#setUp()
*/
protected void setUp()
throws Exception
{
visitor = new CollectorClassFileVisitor();
}
// tests ------------------------------------------------------------------
public void testVisitClass()
{
visitor.visitClass( "a.b.c", null );
visitor.visitClass( "x.y.z", null );
Set expected = new HashSet();
expected.add( "a.b.c" );
expected.add( "x.y.z" );
assertEquals( expected, visitor.getClasses() );
}
}
maven-dependency-analyzer-1.2/src/main/ 0000755 0001750 0001750 00000000000 11624300054 020065 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/main/resources/ 0000755 0001750 0001750 00000000000 11624300054 022077 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/main/java/ 0000755 0001750 0001750 00000000000 11624300054 021006 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/main/java/org/ 0000755 0001750 0001750 00000000000 11624300054 021575 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/main/java/org/apache/ 0000755 0001750 0001750 00000000000 11624300054 023016 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/ 0000755 0001750 0001750 00000000000 11624300054 024124 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/ 0000755 0001750 0001750 00000000000 11624300054 025372 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/ 0000755 0001750 0001750 00000000000 11624300054 027510 5 ustar twerner twerner maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ 0000755 0001750 0001750 00000000000 11624300054 031335 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000163 00000000000 011565 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ClassFileVisitorUtils.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ClassFileVis0000644 0001750 0001750 00000010777 11020006575 033624 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import org.codehaus.plexus.util.DirectoryScanner;
/**
*
*
* @author Mark Hobson
* @version $Id: ClassFileVisitorUtils.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public final class ClassFileVisitorUtils
{
// constants --------------------------------------------------------------
private static final String[] CLASS_INCLUDES = { "**/*.class" };
// constructors -----------------------------------------------------------
private ClassFileVisitorUtils()
{
// private constructor for utility class
}
// public methods ---------------------------------------------------------
public static void accept( URL url, ClassFileVisitor visitor )
throws IOException
{
if ( url.getPath().endsWith( ".jar" ) )
{
acceptJar( url, visitor );
}
else if ( url.getProtocol().equalsIgnoreCase( "file" ) )
{
try
{
File file = new File( new URI( url.toString() ) );
if ( file.isDirectory() )
{
acceptDirectory( file, visitor );
}
else if ( file.exists() )
{
throw new IllegalArgumentException( "Cannot accept visitor on URL: " + url );
}
}
catch ( URISyntaxException exception )
{
IllegalArgumentException e = new IllegalArgumentException( "Cannot accept visitor on URL: " + url );
e.initCause( exception );
throw e;
}
}
else
{
throw new IllegalArgumentException( "Cannot accept visitor on URL: " + url );
}
}
// private methods --------------------------------------------------------
private static void acceptJar( URL url, ClassFileVisitor visitor )
throws IOException
{
JarInputStream in = new JarInputStream( url.openStream() );
JarEntry entry = null;
while ( ( entry = in.getNextJarEntry() ) != null )
{
String name = entry.getName();
if ( name.endsWith( ".class" ) )
visitClass( name, in, visitor );
}
in.close();
}
private static void acceptDirectory( File directory, ClassFileVisitor visitor )
throws IOException
{
if ( !directory.isDirectory() )
throw new IllegalArgumentException( "File is not a directory" );
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( directory );
scanner.setIncludes( CLASS_INCLUDES );
scanner.scan();
String[] paths = scanner.getIncludedFiles();
for ( int i = 0; i < paths.length; i++ )
{
String path = paths[i].replace( File.separatorChar, '/' );
File file = new File( directory, path );
FileInputStream in = new FileInputStream( file );
visitClass( path, in, visitor );
in.close();
}
}
private static void visitClass( String path, InputStream in, ClassFileVisitor visitor )
{
if ( !path.endsWith( ".class" ) )
throw new IllegalArgumentException( "Path is not a class" );
String className = path.substring( 0, path.length() - 6 );
className = className.replace( '/', '.' );
visitor.visitClass( className, in );
}
}
././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzer.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ProjectDepen0000644 0001750 0001750 00000002664 11020006575 033653 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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 org.apache.maven.project.MavenProject;
/**
*
*
* @author Mark Hobson
* @version $Id: ProjectDependencyAnalyzer.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public interface ProjectDependencyAnalyzer
{
// fields -----------------------------------------------------------------
String ROLE = ProjectDependencyAnalyzer.class.getName();
// public methods ---------------------------------------------------------
ProjectDependencyAnalysis analyze( MavenProject project)
throws ProjectDependencyAnalyzerException;
}
././@LongLink 0000000 0000000 0000000 00000000176 00000000000 011571 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/DefaultProjectDependencyAnalyzer.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/DefaultProje0000644 0001750 0001750 00000016643 11465016212 033661 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.MavenProject;
/**
*
*
* @author Mark Hobson
* @version $Id: DefaultProjectDependencyAnalyzer.java 1031612 2010-11-05 15:02:34Z brianf $
* @plexus.component role="org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzer" role-hint="default"
*/
public class DefaultProjectDependencyAnalyzer
implements ProjectDependencyAnalyzer
{
// fields -----------------------------------------------------------------
/**
* ClassAnalyzer
*
* @plexus.requirement
*/
private ClassAnalyzer classAnalyzer;
/**
* DependencyAnalyzer
*
* @plexus.requirement
*/
private DependencyAnalyzer dependencyAnalyzer;
// ProjectDependencyAnalyzer methods --------------------------------------
/*
* @see org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzer#analyze(org.apache.maven.project.MavenProject)
*/
public ProjectDependencyAnalysis analyze( MavenProject project )
throws ProjectDependencyAnalyzerException
{
try
{
Map artifactClassMap = buildArtifactClassMap( project );
Set dependencyClasses = buildDependencyClasses( project , artifactClassMap );
Set declaredArtifacts = buildDeclaredArtifacts( project );
Set usedArtifacts = buildUsedArtifacts( artifactClassMap, dependencyClasses );
Set usedDeclaredArtifacts = new LinkedHashSet( declaredArtifacts );
usedDeclaredArtifacts.retainAll( usedArtifacts );
Set usedUndeclaredArtifacts = new LinkedHashSet( usedArtifacts );
usedUndeclaredArtifacts = removeAll( usedUndeclaredArtifacts, declaredArtifacts );
Set unusedDeclaredArtifacts = new LinkedHashSet( declaredArtifacts );
unusedDeclaredArtifacts = removeAll( unusedDeclaredArtifacts, usedArtifacts );
return new ProjectDependencyAnalysis( usedDeclaredArtifacts, usedUndeclaredArtifacts,
unusedDeclaredArtifacts );
}
catch ( IOException exception )
{
throw new ProjectDependencyAnalyzerException( "Cannot analyze dependencies", exception );
}
}
/**
* This method defines a new way to remove the artifacts by using the
* conflict id. We don't care about the version here because there can be
* only 1 for a given artifact anyway.
*
* @param start
* initial set
* @param remove
* set to exclude
* @return set with remove excluded
*/
private Set removeAll( Set start, Set remove )
{
Set results = new LinkedHashSet( start.size() );
Iterator iter = start.iterator();
while ( iter.hasNext() )
{
Artifact artifact = (Artifact) iter.next();
Iterator iter2 = remove.iterator();
boolean found = false;
while ( iter2.hasNext() )
{
Artifact artifact2 = (Artifact) iter2.next();
if ( artifact.getDependencyConflictId().equals( artifact2.getDependencyConflictId() ) )
{
found = true;
}
}
if ( !found )
{
results.add( artifact );
}
}
return results;
}
// private methods --------------------------------------------------------
private Map buildArtifactClassMap( MavenProject project )
throws IOException
{
Map artifactClassMap = new LinkedHashMap();
Set dependencyArtifacts = project.getArtifacts();
for ( Iterator iterator = dependencyArtifacts.iterator(); iterator.hasNext(); )
{
Artifact artifact = (Artifact) iterator.next();
File file = artifact.getFile();
if ( file != null && file.getName().endsWith( ".jar" ) )
{
URL url = file.toURL();
Set classes = classAnalyzer.analyze( url );
artifactClassMap.put( artifact, classes );
}
}
return artifactClassMap;
}
protected Set buildDependencyClasses( MavenProject project , Map artifactClassMap )
throws IOException
{
Set dependencyClasses = new HashSet();
String outputDirectory = project.getBuild().getOutputDirectory();
dependencyClasses.addAll( buildDependencyClasses( outputDirectory ) );
String testOutputDirectory = project.getBuild().getTestOutputDirectory();
dependencyClasses.addAll( buildDependencyClasses( testOutputDirectory ) );
return dependencyClasses;
}
private Set buildDependencyClasses( String path )
throws IOException
{
URL url = new File( path ).toURI().toURL();
return dependencyAnalyzer.analyze( url );
}
private Set buildDeclaredArtifacts( MavenProject project )
{
Set declaredArtifacts = project.getDependencyArtifacts();
if ( declaredArtifacts == null )
{
declaredArtifacts = Collections.EMPTY_SET;
}
return declaredArtifacts;
}
private Set buildUsedArtifacts( Map artifactClassMap, Set dependencyClasses )
{
Set usedArtifacts = new HashSet();
for ( Iterator dependencyIterator = dependencyClasses.iterator(); dependencyIterator.hasNext(); )
{
String className = (String) dependencyIterator.next();
Artifact artifact = findArtifactForClassName( artifactClassMap, className );
if ( artifact != null )
{
usedArtifacts.add( artifact );
}
}
return usedArtifacts;
}
protected Artifact findArtifactForClassName( Map artifactClassMap, String className )
{
for ( Iterator artifactIterator = artifactClassMap.keySet().iterator(); artifactIterator.hasNext(); )
{
Artifact artifact = (Artifact) artifactIterator.next();
Set artifactClassNames = (Set) artifactClassMap.get( artifact );
if ( artifactClassNames.contains( className ) )
{
return artifact;
}
}
return null;
}
}
././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/CollectorClassFileVisitor.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/CollectorCla0000644 0001750 0001750 00000003633 11020006575 033634 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.io.InputStream;
import java.util.HashSet;
import java.util.Set;
/**
*
*
* @author Mark Hobson
* @version $Id: CollectorClassFileVisitor.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public class CollectorClassFileVisitor
implements ClassFileVisitor
{
// fields -----------------------------------------------------------------
private final Set classes;
// constructors -----------------------------------------------------------
public CollectorClassFileVisitor()
{
classes = new HashSet();
}
// ClassFileVisitor methods -----------------------------------------------
/*
* @see org.apache.maven.shared.dependency.analyzer.ClassFileVisitor#visitClass(java.lang.String,
* java.io.InputStream)
*/
public void visitClass( String className, InputStream in )
{
classes.add( className );
}
// public methods ---------------------------------------------------------
public Set getClasses()
{
return classes;
}
}
././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalysis.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ProjectDepen0000644 0001750 0001750 00000011303 11020006575 033641 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
/**
*
*
* @author Mark Hobson
* @version $Id: ProjectDependencyAnalysis.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public class ProjectDependencyAnalysis
{
// fields -----------------------------------------------------------------
private final Set usedDeclaredArtifacts;
private final Set usedUndeclaredArtifacts;
private final Set unusedDeclaredArtifacts;
// constructors -----------------------------------------------------------
public ProjectDependencyAnalysis()
{
this( null, null, null );
}
public ProjectDependencyAnalysis( Set usedDeclaredArtifacts, Set usedUndeclaredArtifacts,
Set unusedDeclaredArtifacts )
{
this.usedDeclaredArtifacts = safeCopy(usedDeclaredArtifacts);
this.usedUndeclaredArtifacts = safeCopy(usedUndeclaredArtifacts);
this.unusedDeclaredArtifacts = safeCopy(unusedDeclaredArtifacts);
}
// public methods ---------------------------------------------------------
public Set getUsedDeclaredArtifacts()
{
return usedDeclaredArtifacts;
}
public Set getUsedUndeclaredArtifacts()
{
return usedUndeclaredArtifacts;
}
public Set getUnusedDeclaredArtifacts()
{
return unusedDeclaredArtifacts;
}
// Object methods ---------------------------------------------------------
/*
* @see java.lang.Object#hashCode()
*/
public int hashCode()
{
int hashCode = getUsedDeclaredArtifacts().hashCode();
hashCode = (hashCode * 37) + getUsedUndeclaredArtifacts().hashCode();
hashCode = (hashCode * 37) + getUnusedDeclaredArtifacts().hashCode();
return hashCode;
}
/*
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals( Object object )
{
boolean equals;
if ( object instanceof ProjectDependencyAnalysis )
{
ProjectDependencyAnalysis analysis = (ProjectDependencyAnalysis) object;
equals = getUsedDeclaredArtifacts().equals( analysis.getUsedDeclaredArtifacts() )
&& getUsedUndeclaredArtifacts().equals( analysis.getUsedUndeclaredArtifacts() )
&& getUnusedDeclaredArtifacts().equals( analysis.getUnusedDeclaredArtifacts() );
}
else
{
equals = false;
}
return equals;
}
/*
* @see java.lang.Object#toString()
*/
public String toString()
{
StringBuffer buffer = new StringBuffer();
if ( !getUsedDeclaredArtifacts().isEmpty() )
{
buffer.append( "usedDeclaredArtifacts=" ).append( getUsedDeclaredArtifacts() );
}
if ( !getUsedUndeclaredArtifacts().isEmpty() )
{
if ( buffer.length() > 0)
{
buffer.append( "," );
}
buffer.append( "usedUndeclaredArtifacts=" ).append( getUsedUndeclaredArtifacts() );
}
if ( !getUnusedDeclaredArtifacts().isEmpty() )
{
if ( buffer.length() > 0)
{
buffer.append( "," );
}
buffer.append( "unusedDeclaredArtifacts=" ).append( getUnusedDeclaredArtifacts() );
}
buffer.insert( 0, "[" );
buffer.insert( 0, getClass().getName() );
buffer.append( "]" );
return buffer.toString();
}
// private methods --------------------------------------------------------
private Set safeCopy( Set set )
{
return ( set == null ) ? Collections.EMPTY_SET : Collections.unmodifiableSet( new LinkedHashSet( set ) );
}
}
././@LongLink 0000000 0000000 0000000 00000000160 00000000000 011562 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/DependencyAnalyzer.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/DependencyAn0000644 0001750 0001750 00000002621 11020006575 033617 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.io.IOException;
import java.net.URL;
import java.util.Set;
/**
* DependencyAnalyzer
*
* @author Mark Hobson
* @version $Id: DependencyAnalyzer.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public interface DependencyAnalyzer
{
// fields -----------------------------------------------------------------
String ROLE = DependencyAnalyzer.class.getName();
// public methods ---------------------------------------------------------
Set analyze( URL url )
throws IOException;
}
maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ 0000755 0001750 0001750 00000000000 11624300054 032115 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000174 00000000000 011567 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyClassFileVisitor.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/Dependen0000644 0001750 0001750 00000005206 11020006575 033566 0 ustar twerner twerner 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.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;
import org.apache.maven.shared.dependency.analyzer.ClassFileVisitor;
import org.objectweb.asm.ClassReader;
/**
*
*
* @author Mark Hobson
* @version $Id: DependencyClassFileVisitor.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public class DependencyClassFileVisitor
implements ClassFileVisitor
{
// fields -----------------------------------------------------------------
private final Set dependencies;
// constructors -----------------------------------------------------------
public DependencyClassFileVisitor()
{
dependencies = new HashSet();
}
// ClassFileVisitor methods -----------------------------------------------
/*
* @see org.apache.maven.shared.dependency.analyzer.ClassFileVisitor#visitClass(java.lang.String,
* java.io.InputStream)
*/
public void visitClass( String className, InputStream in )
{
try
{
ClassReader reader = new ClassReader( in );
DependencyVisitor visitor = new DependencyVisitor();
reader.accept( visitor, 0 );
dependencies.addAll( visitor.getClasses() );
}
catch ( IOException exception )
{
exception.printStackTrace();
}
catch (IndexOutOfBoundsException e)
{
//some bug inside ASM causes an IOB exception. Log it and move on?
//this happens when the class isn't valid.
System.out.println("Unable to process: "+ className);
}
}
// public methods ---------------------------------------------------------
public Set getDependencies()
{
return dependencies;
}
}
././@LongLink 0000000 0000000 0000000 00000000163 00000000000 011565 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DependencyVisitor.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/Dependen0000644 0001750 0001750 00000040724 11464577763 033622 0 ustar twerner twerner 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.util.HashSet;
import java.util.Set;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Type;
import org.objectweb.asm.signature.SignatureReader;
import org.objectweb.asm.signature.SignatureVisitor;
/**
* Inspired by org.objectweb.asm.depend.DependencyVisitor
in the ASM dependencies example.
*
* @author Mark Hobson
* @version $Id: DependencyVisitor.java 1031144 2010-11-04 18:48:19Z brianf $
*/
public class DependencyVisitor
implements AnnotationVisitor, SignatureVisitor, ClassVisitor, FieldVisitor, MethodVisitor
{
// fields -----------------------------------------------------------------
private final Set classes;
// constructors -----------------------------------------------------------
public DependencyVisitor()
{
classes = new HashSet();
}
// ClassVisitor methods ---------------------------------------------------
/*
* @see org.objectweb.asm.ClassVisitor#visit(int, int, java.lang.String, java.lang.String, java.lang.String,
* java.lang.String[])
*/
public void visit( final int version, final int access, final String name, final String signature,
final String superName, final String[] interfaces )
{
if ( signature == null )
{
addName( superName );
addNames( interfaces );
}
else
{
addSignature( signature );
}
}
/*
* @see org.objectweb.asm.ClassVisitor#visitSource(java.lang.String, java.lang.String)
*/
public void visitSource( final String source, final String debug )
{
// no-op
}
/*
* @see org.objectweb.asm.ClassVisitor#visitOuterClass(java.lang.String, java.lang.String, java.lang.String)
*/
public void visitOuterClass( final String owner, final String name, final String desc )
{
// addName(owner);
// addMethodDesc(desc);
}
/*
* @see org.objectweb.asm.ClassVisitor#visitAnnotation(java.lang.String, boolean)
*/
public AnnotationVisitor visitAnnotation( final String desc, final boolean visible )
{
addDesc( desc );
return this;
}
/*
* @see org.objectweb.asm.ClassVisitor#visitAttribute(org.objectweb.asm.Attribute)
*/
public void visitAttribute( final Attribute attr )
{
// no-op
}
/*
* @see org.objectweb.asm.ClassVisitor#visitInnerClass(java.lang.String, java.lang.String, java.lang.String, int)
*/
public void visitInnerClass( final String name, final String outerName, final String innerName, final int access )
{
// addName( outerName);
// addName( innerName);
}
/*
* @see org.objectweb.asm.ClassVisitor#visitField(int, java.lang.String, java.lang.String, java.lang.String,
* java.lang.Object)
*/
public FieldVisitor visitField( final int access, final String name, final String desc, final String signature,
final Object value )
{
if ( signature == null )
addDesc( desc );
else
addTypeSignature( signature );
if ( value instanceof Type )
addType( (Type) value );
return this;
}
/*
* @see org.objectweb.asm.ClassVisitor#visitMethod(int, java.lang.String, java.lang.String, java.lang.String,
* java.lang.String[])
*/
public MethodVisitor visitMethod( final int access, final String name, final String desc, final String signature,
final String[] exceptions )
{
if ( signature == null )
addMethodDesc( desc );
else
addSignature( signature );
addNames( exceptions );
return this;
}
// MethodVisitor methods --------------------------------------------------
/*
* @see org.objectweb.asm.MethodVisitor#visitAnnotationDefault()
*/
public AnnotationVisitor visitAnnotationDefault()
{
return this;
}
/*
* @see org.objectweb.asm.MethodVisitor#visitParameterAnnotation(int, java.lang.String, boolean)
*/
public AnnotationVisitor visitParameterAnnotation( final int parameter, final String desc, final boolean visible )
{
addDesc( desc );
return this;
}
/*
* @see org.objectweb.asm.MethodVisitor#visitCode()
*/
public void visitCode()
{
// no-op
}
/*
* @see org.objectweb.asm.MethodVisitor#visitFrame(int, int, java.lang.Object[], int, java.lang.Object[])
*/
public void visitFrame( final int type, final int nLocal, final Object[] local, final int nStack,
final Object[] stack )
{
// no-op
}
/*
* @see org.objectweb.asm.MethodVisitor#visitInsn(int)
*/
public void visitInsn( final int opcode )
{
// no-op
}
/*
* @see org.objectweb.asm.MethodVisitor#visitIntInsn(int, int)
*/
public void visitIntInsn( final int opcode, final int operand )
{
// no-op
}
/*
* @see org.objectweb.asm.MethodVisitor#visitVarInsn(int, int)
*/
public void visitVarInsn( final int opcode, final int var )
{
// no-op
}
/*
* @see org.objectweb.asm.MethodVisitor#visitTypeInsn(int, java.lang.String)
*/
public void visitTypeInsn( final int opcode, final String desc )
{
if ( desc.charAt( 0 ) == '[' )
addDesc( desc );
else
addName( desc );
}
/*
* @see org.objectweb.asm.MethodVisitor#visitFieldInsn(int, java.lang.String, java.lang.String, java.lang.String)
*/
public void visitFieldInsn( final int opcode, final String owner, final String name, final String desc )
{
addName( owner );
/*
* NOTE: Merely accessing a field does not impose a direct dependency on its type. For example, the code line
* java.lang.Object var = bean.field;
does not directly depend on the type of the field. A direct
* dependency is only introduced when the code explicitly references the field's type by means of a variable
* declaration or a type check/cast. Those cases are handled by other visitor callbacks.
*/
}
/*
* @see org.objectweb.asm.MethodVisitor#visitMethodInsn(int, java.lang.String, java.lang.String, java.lang.String)
*/
public void visitMethodInsn( final int opcode, final String owner, final String name, final String desc )
{
addName( owner );
/*
* NOTE: Merely invoking a method does not impose a direct dependency on its return type nor its parameter
* types. For example, the code line bean.method(null);
only depends on the owner type of the
* method. A direct dependency is only introduced when the code explicitly references the method's types by
* means of a variable declaration or a type check/cast. Those cases are handled by other visitor callbacks.
*/
}
/*
* @see org.objectweb.asm.MethodVisitor#visitJumpInsn(int, org.objectweb.asm.Label)
*/
public void visitJumpInsn( final int opcode, final Label label )
{
// no-op
}
/*
* @see org.objectweb.asm.MethodVisitor#visitLabel(org.objectweb.asm.Label)
*/
public void visitLabel( final Label label )
{
// no-op
}
/*
* @see org.objectweb.asm.MethodVisitor#visitLdcInsn(java.lang.Object)
*/
public void visitLdcInsn( final Object cst )
{
if ( cst instanceof Type )
addType( (Type) cst );
}
/*
* @see org.objectweb.asm.MethodVisitor#visitIincInsn(int, int)
*/
public void visitIincInsn( final int var, final int increment )
{
// no-op
}
/*
* @see org.objectweb.asm.MethodVisitor#visitTableSwitchInsn(int, int, org.objectweb.asm.Label,
* org.objectweb.asm.Label[])
*/
public void visitTableSwitchInsn( final int min, final int max, final Label dflt, final Label[] labels )
{
// no-op
}
/*
* @see org.objectweb.asm.MethodVisitor#visitLookupSwitchInsn(org.objectweb.asm.Label, int[],
* org.objectweb.asm.Label[])
*/
public void visitLookupSwitchInsn( final Label dflt, final int[] keys, final Label[] labels )
{
// no-op
}
/*
* @see org.objectweb.asm.MethodVisitor#visitMultiANewArrayInsn(java.lang.String, int)
*/
public void visitMultiANewArrayInsn( final String desc, final int dims )
{
addDesc( desc );
}
/*
* @see org.objectweb.asm.MethodVisitor#visitTryCatchBlock(org.objectweb.asm.Label, org.objectweb.asm.Label,
* org.objectweb.asm.Label, java.lang.String)
*/
public void visitTryCatchBlock( final Label start, final Label end, final Label handler, final String type )
{
addName( type );
}
/*
* @see org.objectweb.asm.MethodVisitor#visitLocalVariable(java.lang.String, java.lang.String, java.lang.String,
* org.objectweb.asm.Label, org.objectweb.asm.Label, int)
*/
public void visitLocalVariable( final String name, final String desc, final String signature, final Label start,
final Label end, final int index )
{
if ( signature == null )
{
addDesc( desc );
}
else
{
addTypeSignature( signature );
}
}
/*
* @see org.objectweb.asm.MethodVisitor#visitLineNumber(int, org.objectweb.asm.Label)
*/
public void visitLineNumber( final int line, final Label start )
{
// no-op
}
/*
* @see org.objectweb.asm.MethodVisitor#visitMaxs(int, int)
*/
public void visitMaxs( final int maxStack, final int maxLocals )
{
// no-op
}
// AnnotationVisitor methods ----------------------------------------------
/*
* @see org.objectweb.asm.AnnotationVisitor#visit(java.lang.String, java.lang.Object)
*/
public void visit( final String name, final Object value )
{
if ( value instanceof Type )
addType( (Type) value );
}
/*
* @see org.objectweb.asm.AnnotationVisitor#visitEnum(java.lang.String, java.lang.String, java.lang.String)
*/
public void visitEnum( final String name, final String desc, final String value )
{
addDesc( desc );
}
/*
* @see org.objectweb.asm.AnnotationVisitor#visitAnnotation(java.lang.String, java.lang.String)
*/
public AnnotationVisitor visitAnnotation( final String name, final String desc )
{
addDesc( desc );
return this;
}
/*
* @see org.objectweb.asm.AnnotationVisitor#visitArray(java.lang.String)
*/
public AnnotationVisitor visitArray( final String name )
{
return this;
}
/*
* @see org.objectweb.asm.AnnotationVisitor#visitEnd()
*/
public void visitEnd()
{
// no-op
}
// SignatureVisitor methods -----------------------------------------------
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitFormalTypeParameter(java.lang.String)
*/
public void visitFormalTypeParameter( final String name )
{
// no-op
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitClassBound()
*/
public SignatureVisitor visitClassBound()
{
return this;
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitInterfaceBound()
*/
public SignatureVisitor visitInterfaceBound()
{
return this;
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitSuperclass()
*/
public SignatureVisitor visitSuperclass()
{
return this;
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitInterface()
*/
public SignatureVisitor visitInterface()
{
return this;
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitParameterType()
*/
public SignatureVisitor visitParameterType()
{
return this;
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitReturnType()
*/
public SignatureVisitor visitReturnType()
{
return this;
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitExceptionType()
*/
public SignatureVisitor visitExceptionType()
{
return this;
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitBaseType(char)
*/
public void visitBaseType( final char descriptor )
{
// no-op
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitTypeVariable(java.lang.String)
*/
public void visitTypeVariable( final String name )
{
// TODO: verify
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitArrayType()
*/
public SignatureVisitor visitArrayType()
{
return this;
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitClassType(java.lang.String)
*/
public void visitClassType( final String name )
{
addName( name );
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitInnerClassType(java.lang.String)
*/
public void visitInnerClassType( final String name )
{
addName( name );
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitTypeArgument()
*/
public void visitTypeArgument()
{
// no-op
}
/*
* @see org.objectweb.asm.signature.SignatureVisitor#visitTypeArgument(char)
*/
public SignatureVisitor visitTypeArgument( final char wildcard )
{
return this;
}
// public methods ---------------------------------------------------------
public Set getClasses()
{
return classes;
}
// private methods --------------------------------------------------------
private void addName( String name )
{
if ( name == null )
return;
// decode arrays
if ( name.startsWith( "[L" ) && name.endsWith( ";" ) )
name = name.substring( 2, name.length() - 1 );
// decode internal representation
name = name.replace( '/', '.' );
classes.add( name );
}
private void addNames( final String[] names )
{
if ( names == null )
return;
for ( int i = 0; i < names.length; i++ )
addName( names[i] );
}
private void addDesc( final String desc )
{
addType( Type.getType( desc ) );
}
private void addMethodDesc( final String desc )
{
addType( Type.getReturnType( desc ) );
Type[] types = Type.getArgumentTypes( desc );
for ( int i = 0; i < types.length; i++ )
addType( types[i] );
}
private void addType( final Type t )
{
switch ( t.getSort() )
{
case Type.ARRAY:
addType( t.getElementType() );
break;
case Type.OBJECT:
addName( t.getClassName().replace( '.', '/' ) );
break;
}
}
private void addSignature( final String signature )
{
if ( signature != null )
new SignatureReader( signature ).accept( this );
}
private void addTypeSignature( final String signature )
{
if ( signature != null )
new SignatureReader( signature ).acceptType( this );
}
}
././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ASMDependencyAnalyzer.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ASMDepen0000644 0001750 0001750 00000003525 11020006575 033442 0 ustar twerner twerner 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.io.IOException;
import java.net.URL;
import java.util.Set;
import org.apache.maven.shared.dependency.analyzer.ClassFileVisitorUtils;
import org.apache.maven.shared.dependency.analyzer.DependencyAnalyzer;
/**
* ASMDependencyAnalyzer
*
* @author Mark Hobson
* @version $Id: ASMDependencyAnalyzer.java 661727 2008-05-30 14:21:49Z bentmann $
* @plexus.component role="org.apache.maven.shared.dependency.analyzer.DependencyAnalyzer"
*/
public class ASMDependencyAnalyzer
implements DependencyAnalyzer
{
// DependencyAnalyzer methods ---------------------------------------------
/*
* @see org.apache.maven.shared.dependency.analyzer.DependencyAnalyzer#analyze(java.net.URL)
*/
public Set analyze( URL url )
throws IOException
{
DependencyClassFileVisitor visitor = new DependencyClassFileVisitor();
ClassFileVisitorUtils.accept( url, visitor );
return visitor.getDependencies();
}
}
././@LongLink 0000000 0000000 0000000 00000000153 00000000000 011564 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ClassAnalyzer.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ClassAnalyze0000644 0001750 0001750 00000002560 11020006575 033655 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.io.IOException;
import java.net.URL;
import java.util.Set;
/**
*
*
* @author Mark Hobson
* @version $Id: ClassAnalyzer.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public interface ClassAnalyzer
{
// fields -----------------------------------------------------------------
String ROLE = ClassAnalyzer.class.getName();
// public methods ---------------------------------------------------------
Set analyze( URL url )
throws IOException;
}
././@LongLink 0000000 0000000 0000000 00000000162 00000000000 011564 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/DefaultClassAnalyzer.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/DefaultClass0000644 0001750 0001750 00000004151 11346730223 033641 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.io.IOException;
import java.net.URL;
import java.util.Set;
import java.util.zip.ZipException;
/**
*
*
* @author Mark Hobson
* @version $Id: DefaultClassAnalyzer.java 922584 2010-03-13 15:34:43Z hboutemy $
* @plexus.component role="org.apache.maven.shared.dependency.analyzer.ClassAnalyzer"
*/
public class DefaultClassAnalyzer
implements ClassAnalyzer
{
// ClassAnalyzer methods --------------------------------------------------
/*
* @see org.apache.maven.shared.dependency.analyzer.ClassAnalyzer#analyze(java.net.URL)
*/
public Set analyze( URL url )
throws IOException
{
CollectorClassFileVisitor visitor = new CollectorClassFileVisitor();
try
{
ClassFileVisitorUtils.accept( url, visitor );
}
catch( ZipException e )
{
// since the current ZipException gives no indication what jar file is corrupted
// we prefer to wrap another ZipException for better error visibility
ZipException ze = new ZipException( "Cannot process Jar entry on URL: " + url + " due to " + e.getMessage() );
ze.initCause( e );
throw ze;
}
return visitor.getClasses();
}
}
././@LongLink 0000000 0000000 0000000 00000000156 00000000000 011567 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ClassFileVisitor.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ClassFileVis0000644 0001750 0001750 00000002171 11020006575 033611 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.io.InputStream;
/**
*
*
* @author Mark Hobson
* @version $Id: ClassFileVisitor.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public interface ClassFileVisitor
{
void visitClass( String className, InputStream in );
}
././@LongLink 0000000 0000000 0000000 00000000200 00000000000 011555 L ustar root root maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzerException.java maven-dependency-analyzer-1.2/src/main/java/org/apache/maven/shared/dependency/analyzer/ProjectDepen0000644 0001750 0001750 00000003135 11020006575 033645 0 ustar twerner twerner package org.apache.maven.shared.dependency.analyzer;
/*
* 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.
*/
/**
*
*
* @author Mark Hobson
* @version $Id: ProjectDependencyAnalyzerException.java 661727 2008-05-30 14:21:49Z bentmann $
*/
public class ProjectDependencyAnalyzerException
extends Exception
{
// constants --------------------------------------------------------------
/**
* The serialisation unique ID.
*/
private static final long serialVersionUID = -5954447543668196977L;
// constructors -----------------------------------------------------------
public ProjectDependencyAnalyzerException( String message )
{
super( message );
}
public ProjectDependencyAnalyzerException( String message, Throwable cause )
{
super( message, cause );
}
}