Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue1 - improved hadoop dependency filter #3

Merged
merged 7 commits into from
May 2, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.github.maven-hadoop.plugin</groupId>
<artifactId>maven-hadoop-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>0.20.2-SNAPSHOT</version>
<version>1.0.2-SNAPSHOT</version>
<name>Maven Plugin for Hadoop </name>
<description>Maven plugin for Hadoop</description>
<url>http://github.com/akkumar/maven-hadoop/tree/master</url>
Expand All @@ -18,6 +18,7 @@
</license>
</licenses>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mvn.plugin.version>2.0.9</mvn.plugin.version>
<git.url>http://github.com/akkumar/maven-hadoop.git</git.url>
</properties>
Expand Down Expand Up @@ -51,7 +52,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<version>2.4</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
Expand All @@ -61,7 +62,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-7</version>
<version>2.2.2</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
Expand Down Expand Up @@ -98,7 +99,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
<version>2.3</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -137,7 +138,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.0-alpha-4</version>
<version>1.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down
52 changes: 13 additions & 39 deletions src/main/java/com/github/hadoop/maven/plugin/PackMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;

import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -95,13 +94,6 @@ public class PackMojo extends AbstractMojo {
*/
protected MavenProject project;

/**
* Hadoop Configuration properties
*
* @parameter
*/
private Properties hadoopConfiguration;

/**
* @parameter expression="${project.build.directory}/hadoop-deploy"
* @readonly
Expand Down Expand Up @@ -189,16 +181,22 @@ private File createHadoopDeployArtifacts() throws IOException {
*/
private Set<Artifact> filterArtifacts(Set<Artifact> artifacts) {
List<String> hadoopArtifactIds = getHadoopArtifactIds();
getLog().info("Hadoop Artifact Ids are " + hadoopArtifactIds);
getLog().info("Hadoop Artifact Ids are " + hadoopArtifactIds);
Set<Artifact> output = new HashSet<Artifact>();
for (final Artifact inputArtifact : artifacts) {
final String name = inputArtifact.getArtifactId();
if (name.startsWith("hadoop") || name.startsWith("jsp-")
|| hadoopArtifactIds.contains(name)) {
getLog().info(
"Ignoring " + inputArtifact
+ " because of that being a hadoop dependency ");
continue; // skip other dependencies in hadoop cp as well.
final String group = inputArtifact.getGroupId();
if (hadoopArtifactIds.contains(name)) {
getLog().info("Ignoring " + inputArtifact
+ " (it is a hadoop dependency)");
}
else if (group.startsWith("org.apache") && name.startsWith("hadoop")) {
getLog().info("Ignoring " + inputArtifact
+ " (it is in 'org.apache' and starts with 'hadoop')");
}
else if (name.startsWith("jsp-")) {
getLog().info("Ignoring " + inputArtifact
+ " (it starts with 'jsp-')");
} else {
output.add(inputArtifact);
}
Expand Down Expand Up @@ -228,30 +226,6 @@ List<String> getHadoopArtifactIds() {
return outputJars;
}

/**
* Retrieve the project dependencies.
*
* @param scope
* Scope of the dependency to resolve to .
* @return
*/
@SuppressWarnings("unchecked")
private List<File> getScopedDependencies(final String scope) {
List<File> jarDependencies = new ArrayList<File>();
final Set<Artifact> artifacts = project.getDependencyArtifacts();
for (Artifact artifact : artifacts) {
if ("jar".equals(artifact.getType())) {
File file = artifact.getFile();
if (file != null && file.exists()) {
jarDependencies.add(file);
} else {
getLog().warn("Dependency file not found: " + artifact);
}
}
}
return jarDependencies;
}

private File packToJar(final File jarRootDir) throws FileNotFoundException,
IOException {
File jarName = new File(this.outputDirectory.getAbsolutePath()
Expand Down