Skip to content

Commit

Permalink
Maven plugin use the maven configuration to find repos
Browse files Browse the repository at this point in the history
  • Loading branch information
jetoile committed Jan 11, 2017
1 parent 20994c0 commit 334c7dc
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 26 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,6 @@ To use it, add into the pom project stuff like that:
</execution>
</executions>
<configuration>
<localRepo>/home/khanh/.m2/repository</localRepo>
<centralRepo>https://repo.maven.apache.org/maven2/</centralRepo>
<components>
<componentArtifact implementation="fr.jetoile.hadoopunit.ComponentArtifact">
<componentName>HDFS</componentName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.*;

import static com.sun.tools.doclint.Entity.prop;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


@Mojo(name = "embedded-start", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST, threadSafe = false)
Expand All @@ -66,11 +68,23 @@ public class HadoopBootstrapStarter extends AbstractMojo {
@Parameter(property = "components", required = true)
protected List<ComponentArtifact> components;

@Parameter(property = "localRepo", required = true)
protected String localRepo;
/**
* The current repository/network configuration of Maven.
*
* @parameter default-value="${repositorySystemSession}"
* @readonly
*/
@Parameter(property = "repoSession", defaultValue = "${repositorySystemSession}")
private RepositorySystemSession repoSession;

@Parameter(property = "centralRepo", required = true)
protected String centralRepo;
/**
* The project's remote repositories to use for the resolution.
*
* @parameter default-value="${project.remoteProjectRepositories}"
* @readonly
*/
@Parameter(property = "remoteRepos", defaultValue = "${project.remoteProjectRepositories}")
private List<RemoteRepository> remoteRepos;

private List<ComponentProperties> componentProperties = new ArrayList<>();

Expand All @@ -93,7 +107,7 @@ public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable except
public DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system) {
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();

LocalRepository localRepo1 = new LocalRepository(localRepo);
LocalRepository localRepo1 = new LocalRepository(repoSession.getLocalRepository().getBasedir());
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo1));

// session.setTransferListener(new ConsoleTransferListener());
Expand All @@ -103,11 +117,7 @@ public DefaultRepositorySystemSession newRepositorySystemSession(RepositorySyste
}

public List<RemoteRepository> newRepositories(RepositorySystem system, RepositorySystemSession session) {
return new ArrayList<>(Arrays.asList(newCentralRepository()));
}

private RemoteRepository newCentralRepository() {
return new RemoteRepository.Builder("central", "default", centralRepo).build();
return remoteRepos;
}

@Override
Expand All @@ -128,7 +138,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
collectRequest.setRepositories(newRepositories(system, session));

getLog().info("Resolving artifact " + artifact + " from " + centralRepo);
getLog().info("Resolving artifact " + artifact + " from " + remoteRepos.stream().map(r -> r.getId() + "-" + r.getUrl()).collect(Collectors.joining(", ")));

DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFilter);

Expand Down
2 changes: 0 additions & 2 deletions sample/kafka-spark-streaming/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@
</execution>
</executions>
<configuration>
<localRepo>/home/khanh/.m2/repository</localRepo>
<centralRepo>https://repo.maven.apache.org/maven2/</centralRepo>
<components>
<componentArtifact implementation="fr.jetoile.hadoopunit.ComponentArtifact">
<componentName>ZOOKEEPER</componentName>
Expand Down
2 changes: 0 additions & 2 deletions sample/kafka-stream/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@
</execution>
</executions>
<configuration>
<localRepo>/home/khanh/.m2/repository</localRepo>
<centralRepo>https://repo.maven.apache.org/maven2/</centralRepo>
<components>
<componentArtifact implementation="fr.jetoile.hadoopunit.ComponentArtifact">
<componentName>ZOOKEEPER</componentName>
Expand Down
2 changes: 0 additions & 2 deletions sample/parquet-spark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@
</execution>
</executions>
<configuration>
<localRepo>/home/khanh/.m2/repository</localRepo>
<centralRepo>https://repo.maven.apache.org/maven2/</centralRepo>
<components>
<componentArtifact implementation="fr.jetoile.hadoopunit.ComponentArtifact">
<componentName>HDFS</componentName>
Expand Down
2 changes: 0 additions & 2 deletions sample/solr-parquet-spark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@
</execution>
</executions>
<configuration>
<localRepo>/home/khanh/.m2/repository</localRepo>
<centralRepo>https://repo.maven.apache.org/maven2/</centralRepo>
<components>
<componentArtifact implementation="fr.jetoile.hadoopunit.ComponentArtifact">
<componentName>HDFS</componentName>
Expand Down
2 changes: 0 additions & 2 deletions sample/spark-streaming-cassandra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@
</execution>
</executions>
<configuration>
<localRepo>/home/khanh/.m2/repository</localRepo>
<centralRepo>https://repo.maven.apache.org/maven2/</centralRepo>
<components>
<componentArtifact implementation="fr.jetoile.hadoopunit.ComponentArtifact">
<componentName>ZOOKEEPER</componentName>
Expand Down

0 comments on commit 334c7dc

Please sign in to comment.