Skip to content

Commit

Permalink
Added addon dependency api
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Nov 12, 2012
1 parent 4a75107 commit 131042e
Show file tree
Hide file tree
Showing 21 changed files with 194 additions and 344 deletions.
10 changes: 10 additions & 0 deletions forge-dependency-api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jboss.forge</groupId>
<artifactId>forge-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>forge-dependency-api</artifactId>
<name>Forge - Addon Dependency API</name>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright 2012 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.addon.dependency;

public interface AddonManager
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2012 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.addon.dependency;

/**
* Marker interface for a Coordinate object.
*
* Implementations should provide additional methods about how to locate an artifact.
*
* Eg: If using Maven, the {@link Coordinate} implementation should return the artifact's groupId, artifactId and
* version
*
* @author <a href="mailto:ggastald@redhat.com">George Gastaldi</a>
*
*/
public interface Coordinate
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.maven.dependency;
package org.jboss.forge.addon.dependency;

import java.io.File;

Expand All @@ -16,6 +16,11 @@
*/
public interface Dependency
{
/**
* Get the major identifier for this {@link Dependency}.
*/
String getGroupId();

/**
* Get the minor-identifier for this {@link Dependency}.
*/
Expand All @@ -26,11 +31,6 @@ public interface Dependency
*/
String getClassifier();

/**
* Get the major identifier for this {@link Dependency}.
*/
String getGroupId();

/**
* Get the version of this {@link Dependency}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,27 @@
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.maven.dependency;
package org.jboss.forge.addon.dependency;

import java.io.File;

/**
* Builder to create {@link DependencyImpl} objects. This class implements {@link DependencyImpl} for easy consumption.
* (I.e.: Use this class wherever you need to create and use a new {@link DependencyImpl})
* Builder to create {@link Dependency} objects. This class implements {@link Dependency} for easy consumption. (I.e.:
* Use this class wherever you need to create and use a new {@link Dependency})
*
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public class DependencyBuilder implements Dependency
{
private final DependencyImpl dep = new DependencyImpl();
private String groupId;
private String artifactId;
private String version;
private String scopeType;
private String packagingType;
private String classifier;
private String systemPath;
private File artifact;
private boolean optional;

private DependencyBuilder()
{
Expand Down Expand Up @@ -111,92 +119,92 @@ public static DependencyBuilder create(final String identifier)

public DependencyBuilder setGroupId(final String groupId)
{
dep.setGroupId(groupId);
this.groupId = groupId;
return this;
}

public DependencyBuilder setArtifactId(final String artifactId)
{
dep.setArtifactId(artifactId);
this.artifactId = artifactId;
return this;
}

public DependencyBuilder setVersion(final String version)
{
dep.setVersion(version);
this.version = version;
return this;
}

public DependencyBuilder setScopeType(final String scope)
{
dep.setScopeType(scope);
this.scopeType = scope;
return this;
}

public DependencyBuilder setPackagingType(final String type)
{
dep.setPackagingType(type);
this.packagingType = type;
return this;
}

public DependencyBuilder setClassifier(final String classifier)
{
dep.setClassifier(classifier);
this.classifier = classifier;
return this;
}

public DependencyBuilder setSystemPath(final String systemPath)
{
dep.setSystemPath(systemPath);
this.systemPath = systemPath;
return this;
}

@Override
public String getSystemPath()
{
return dep.getSystemPath();
return systemPath;
}

@Override
public String getArtifactId()
{
return dep.getArtifactId();
return artifactId;
}

@Override
public String getGroupId()
{
return dep.getGroupId();
return groupId;
}

@Override
public String getVersion()
{
return dep.getVersion();
return version;
}

@Override
public String getScopeType()
{
return dep.getScopeType();
return scopeType;
}

@Override
public boolean isSnapshot()
{
return dep.isSnapshot();
return getVersion() != null && getVersion().endsWith("SNAPSHOT");
}

@Override
public String getPackagingType()
{
return dep.getPackagingType();
return packagingType;
}

@Override
public String getClassifier()
{
return dep.getClassifier();
return classifier;
}

/**
Expand All @@ -215,16 +223,6 @@ public static String toId(final Dependency dep)
return gav;
}

/**
* Convenience method which should be used to convert a {@link Dependency} object into its string representation, for
* example: "groupId:artifactId:version:scope:packaging"
*/
public static String toString(final Dependency dep)
{
String gav = dep.toCoordinates();
return gav;
}

@Override
public String toCoordinates()
{
Expand All @@ -234,69 +232,31 @@ public String toCoordinates()
@Override
public String toString()
{
return DependencyBuilder.toString(dep);
return toCoordinates();
}

@Override
public boolean isOptional()
{
return dep.isOptional();
return this.optional;
}

public DependencyBuilder setOptional(boolean optional)
{
dep.setOptional(optional);
this.optional = optional;
return this;
}

@Override
public File getArtifact()
{
return dep.getArtifact();
return artifact;
}

public DependencyBuilder setArtifact(File artifact)
{
dep.setArtifact(artifact);
this.artifact = artifact;
return this;
}

@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((dep == null) ? 0 : dep.hashCode());
return result;
}

@Override
public boolean equals(final Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
DependencyBuilder other = (DependencyBuilder) obj;
if (dep == null)
{
if (other.dep != null)
{
return false;
}
}
else if (!dep.equals(other.dep))
{
return false;
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.maven.dependency;
package org.jboss.forge.addon.dependency;

/**
* Used to filter {@link Dependency} objects in collections.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.maven.dependency;
package org.jboss.forge.addon.dependency;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.maven.dependency;
package org.jboss.forge.addon.dependency;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.maven.dependency;
package org.jboss.forge.addon.dependency;

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright 2012 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.addon.dependency.spi;

import org.jboss.forge.addon.dependency.Coordinate;

public interface CoordinateFactory
{
Coordinate createCoordinate(String coordinate) throws UnsupportedCoordinateException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
* http://www.eclipse.org/legal/epl-v10.html
*/

package org.jboss.forge.maven.dependency;
package org.jboss.forge.addon.dependency.spi;

import java.util.List;
import java.util.Set;

import org.jboss.forge.addon.dependency.Dependency;
import org.jboss.forge.addon.dependency.DependencyQuery;

public interface DependencyResolver
{
/**
Expand Down
Loading

0 comments on commit 131042e

Please sign in to comment.