Пример #1
0
  public void testRuntimeBuilder() throws Exception {
    PlexusRuntimeBuilder runtimeBuilder = (PlexusRuntimeBuilder) lookup(PlexusRuntimeBuilder.ROLE);

    ArtifactRepositoryFactory artifactRepositoryFactory =
        (ArtifactRepositoryFactory) lookup(ArtifactRepositoryFactory.ROLE);

    // ----------------------------------------------------------------------
    // Clean the output directory
    // ----------------------------------------------------------------------

    File workingDirectory = getTestFile("target/test-runtime");

    FileUtils.deleteDirectory(workingDirectory);

    // ----------------------------------------------------------------------
    //
    // ----------------------------------------------------------------------

    List remoteRepositories = new ArrayList();

    ArtifactRepositoryLayout repositoryLayout =
        (ArtifactRepositoryLayout) lookup(ArtifactRepositoryLayout.ROLE, "legacy");

    ArtifactRepository localRepository =
        artifactRepositoryFactory.createArtifactRepository(
            "local",
            "file://" + getTestFile("src/test/repository").getAbsolutePath(),
            repositoryLayout);

    Set projectArtifacts = new HashSet();

    projectArtifacts.add(makeArtifact("classworlds", "classworlds", "1.1-alpha-1"));
    projectArtifacts.add(
        makeArtifact("org.codehaus.plexus", "plexus-container-default", "1.0-alpha-7"));
    projectArtifacts.add(makeArtifact("plexus", "plexus-container-artifact", "1.0-alpha-2"));
    projectArtifacts.add(makeArtifact("org.codehaus.plexus", "plexus-appserver-host", "1.0"));
    projectArtifacts.add(makeArtifact("org.codehaus.plexus", "plexus-utils", "1.0.4"));

    // ----------------------------------------------------------------------
    //
    // ----------------------------------------------------------------------

    File plexusConfiguration = getTestFile("src/test/resources/conf/plexus.xml");

    File configurationPropertiesFile = getTestFile("src/test/resources/configuration.properties");

    runtimeBuilder.build(
        workingDirectory,
        remoteRepositories,
        localRepository,
        projectArtifacts,
        plexusConfiguration,
        configurationPropertiesFile);
  }
Пример #2
0
 private ArtifactRepository getDeploymentRepository(
     ArtifactRepositoryFactory factory,
     ArtifactRepositoryLayout layout,
     String repositoryId,
     String repositoryUrl)
     throws ComponentLookupException {
   if (repositoryUrl == null) return null;
   final ArtifactRepository repository =
       factory.createDeploymentArtifactRepository(
           repositoryId, repositoryUrl, layout, uniqueVersion);
   return new WrappedArtifactRepository(repository, uniqueVersion);
 }
Пример #3
0
 private List<String> deployArtifactRepository() throws MojoExecutionException {
   ArtifactRepositoryLayout artifactRepositoryLayout =
       availableRepositoryLayouts.get(repositoryLayout);
   if (artifactRepositoryLayout == null) {
     throw new MojoExecutionException("Unknown repository layout '" + repositoryLayout + "'.");
   }
   // The repo where the jar files will be installed
   ArtifactRepository artifactRepository =
       artifactRepositoryFactory.createDeploymentArtifactRepository(
           project.getArtifactId(),
           "file://" + outputDirectory.getAbsolutePath() + "/lib",
           artifactRepositoryLayout,
           false);
   List<String> classPaths = new ArrayList<String>();
   for (Artifact artifact : artifacts) {
     classPaths.add(installArtifact(artifactRepository, artifact));
   }
   // install the project's artifact in the new repository
   classPaths.add(installArtifact(artifactRepository, projectArtifact));
   return classPaths;
 }