Search in sources :

Example 1 with Repository

use of org.apache.maven.plugins.assembly.model.Repository in project maven-plugins by apache.

the class DefaultDependencyResolverTest method test_getRepositoryResolutionRequirements.

public void test_getRepositoryResolutionRequirements() {
    final List<Repository> repositories = new ArrayList<Repository>();
    {
        final Repository r = new Repository();
        r.setScope(Artifact.SCOPE_COMPILE);
        repositories.add(r);
    }
    {
        final Repository r = new Repository();
        r.setScope(Artifact.SCOPE_SYSTEM);
        repositories.add(r);
    }
    final MavenProject project = createMavenProject("group", "artifact", "1.0", null);
    final Assembly assembly = new Assembly();
    assembly.setRepositories(repositories);
    final ResolutionManagementInfo info = new ResolutionManagementInfo(project);
    resolver.updateRepositoryResolutionRequirements(assembly, info);
    assertTrue(info.isResolutionRequired());
    assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_COMPILE));
    assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_SYSTEM));
    assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_PROVIDED));
    assertFalse(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_RUNTIME));
    assertFalse(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_TEST));
}
Also used : ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) Repository(org.apache.maven.plugins.assembly.model.Repository) StubArtifactRepository(org.apache.maven.plugin.testing.stubs.StubArtifactRepository) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 2 with Repository

use of org.apache.maven.plugins.assembly.model.Repository in project maven-plugins by apache.

the class RepositoryAssemblyPhase method execute.

/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("ResultOfMethodCallIgnored")
public void execute(final Assembly assembly, final Archiver archiver, final AssemblerConfigurationSource configSource) throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
    final List<Repository> repositoriesList = assembly.getRepositories();
    final File tempRoot = configSource.getTemporaryRootDirectory();
    for (final Repository repository : repositoriesList) {
        final String outputDirectory = AssemblyFormatUtils.getOutputDirectory(repository.getOutputDirectory(), configSource.getFinalName(), configSource, AssemblyFormatUtils.moduleProjectInterpolator(configSource.getProject()), AssemblyFormatUtils.artifactProjectInterpolator(null));
        final File repositoryDirectory = new File(tempRoot, outputDirectory);
        if (!repositoryDirectory.exists()) {
            repositoryDirectory.mkdirs();
        }
        try {
            getLogger().debug("Assembling repository to: " + repositoryDirectory);
            repositoryAssembler.buildRemoteRepository(repositoryDirectory, wrap(repository), wrap(configSource));
            getLogger().debug("Finished assembling repository to: " + repositoryDirectory);
        } catch (final RepositoryAssemblyException e) {
            throw new ArchiveCreationException("Failed to assemble repository: " + e.getMessage(), e);
        }
        final AddDirectoryTask task = new AddDirectoryTask(repositoryDirectory);
        final int dirMode = TypeConversionUtils.modeToInt(repository.getDirectoryMode(), getLogger());
        if (dirMode != -1) {
            task.setDirectoryMode(dirMode);
        }
        final int fileMode = TypeConversionUtils.modeToInt(repository.getFileMode(), getLogger());
        if (fileMode != -1) {
            task.setFileMode(fileMode);
        }
        task.setOutputDirectory(outputDirectory);
        task.execute(archiver);
    }
}
Also used : Repository(org.apache.maven.plugins.assembly.model.Repository) RepositoryAssemblyException(org.apache.maven.plugins.assembly.repository.RepositoryAssemblyException) ArchiveCreationException(org.apache.maven.plugins.assembly.archive.ArchiveCreationException) AddDirectoryTask(org.apache.maven.plugins.assembly.archive.task.AddDirectoryTask) File(java.io.File)

Example 3 with Repository

use of org.apache.maven.plugins.assembly.model.Repository in project maven-plugins by apache.

the class DefaultAssemblyReaderTest method testMergeComponentWithAssembly_ShouldAddOneRepositoryToExistingListOfTwo.

public void testMergeComponentWithAssembly_ShouldAddOneRepositoryToExistingListOfTwo() {
    final Assembly assembly = new Assembly();
    Repository repo = new Repository();
    repo.setScope(Artifact.SCOPE_RUNTIME);
    assembly.addRepository(repo);
    repo = new Repository();
    repo.setScope(Artifact.SCOPE_COMPILE);
    assembly.addRepository(repo);
    final Component component = new Component();
    repo = new Repository();
    repo.setScope(Artifact.SCOPE_SYSTEM);
    component.addRepository(repo);
    new DefaultAssemblyReader().mergeComponentWithAssembly(component, assembly);
    final List<Repository> depSets = assembly.getRepositories();
    assertNotNull(depSets);
    assertEquals(3, depSets.size());
    assertEquals(Artifact.SCOPE_RUNTIME, depSets.get(0).getScope());
    assertEquals(Artifact.SCOPE_COMPILE, depSets.get(1).getScope());
    assertEquals(Artifact.SCOPE_SYSTEM, depSets.get(2).getScope());
}
Also used : ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) Repository(org.apache.maven.plugins.assembly.model.Repository) Component(org.apache.maven.plugins.assembly.model.Component) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 4 with Repository

use of org.apache.maven.plugins.assembly.model.Repository in project maven-plugins by apache.

the class DefaultDependencyResolver method updateRepositoryResolutionRequirements.

void updateRepositoryResolutionRequirements(final Assembly assembly, final ResolutionManagementInfo requirements) {
    final List<Repository> repositories = assembly.getRepositories();
    Set<String> rootScopes = new HashSet<String>();
    if (repositories != null && !repositories.isEmpty()) {
        requirements.setResolutionRequired(true);
        for (final Repository repo : repositories) {
            rootScopes.add(repo.getScope());
        }
    }
    requirements.setScopeFilter(FilterUtils.newScopeFilter(rootScopes));
}
Also used : ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) Repository(org.apache.maven.plugins.assembly.model.Repository) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 5 with Repository

use of org.apache.maven.plugins.assembly.model.Repository in project maven-plugins by apache.

the class RepositoryAssemblyPhaseTest method testExecute_ShouldIncludeOneRepository.

public void testExecute_ShouldIncludeOneRepository() throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForRepositoryAssembler macRepo = new MockAndControlForRepositoryAssembler(mm);
    final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
    final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
    final File tempRoot = fileManager.createTempDir();
    macCS.expectGetTemporaryRootDirectory(tempRoot);
    macCS.expectGetProject(new MavenProject(new Model()));
    macCS.expectGetFinalName("final-name");
    macCS.expectInterpolators();
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    final Repository repo = new Repository();
    repo.setOutputDirectory("out");
    repo.setDirectoryMode("777");
    repo.setFileMode("777");
    final int mode = TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
    final File outDir = new File(tempRoot, "out");
    macArchiver.expectModeChange(-1, -1, mode, mode, true);
    macArchiver.expectAddDirectory(outDir, "out/", null, null);
    macRepo.expectAssemble();
    assembly.addRepository(repo);
    mm.replayAll();
    createPhase(macRepo.repositoryAssembler, new ConsoleLogger(Logger.LEVEL_DEBUG, "test")).execute(assembly, macArchiver.archiver, macCS.configSource);
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) Repository(org.apache.maven.plugins.assembly.model.Repository) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Aggregations

Repository (org.apache.maven.plugins.assembly.model.Repository)6 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)3 Assembly (org.apache.maven.plugins.assembly.model.Assembly)3 File (java.io.File)2 MavenProject (org.apache.maven.project.MavenProject)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 Model (org.apache.maven.model.Model)1 StubArtifactRepository (org.apache.maven.plugin.testing.stubs.StubArtifactRepository)1 ArchiveCreationException (org.apache.maven.plugins.assembly.archive.ArchiveCreationException)1 AddDirectoryTask (org.apache.maven.plugins.assembly.archive.task.AddDirectoryTask)1 Component (org.apache.maven.plugins.assembly.model.Component)1 ContainerDescriptorHandlerConfig (org.apache.maven.plugins.assembly.model.ContainerDescriptorHandlerConfig)1 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)1 FileItem (org.apache.maven.plugins.assembly.model.FileItem)1 FileSet (org.apache.maven.plugins.assembly.model.FileSet)1 ModuleSet (org.apache.maven.plugins.assembly.model.ModuleSet)1 RepositoryAssemblyException (org.apache.maven.plugins.assembly.repository.RepositoryAssemblyException)1 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)1