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));
}
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);
}
}
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());
}
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));
}
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();
}
Aggregations