use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.
the class AddArtifactTaskTest method testShouldAddArchiveFileWithDefaultOutputLocation.
public void testShouldAddArchiveFileWithDefaultOutputLocation() throws ArchiveCreationException, AssemblyFormattingException, IOException {
String artifactId = "myArtifact";
String version = "1";
String ext = "jar";
String outputDir = "tmp/";
ArtifactMock mock = new ArtifactMock(mockManager, "group", artifactId, version, ext, false);
File file = mock.setNewFile();
mock.setExtension(ext);
mac.expectGetMode(0222, 0222);
mac.expectGetDestFile(new File("junk"));
mac.expectAddFile(file, outputDir + artifactId + "-" + version + "." + ext);
mac.expectInterpolators();
mockManager.replayAll();
AddArtifactTask task = new AddArtifactTask(mock.getArtifact(), new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null);
task.setOutputDirectory(outputDir);
task.setFileNameMapping(new DependencySet().getOutputFileNameMapping());
Model model = new Model();
model.setArtifactId(artifactId);
model.setVersion(version);
MavenProject project = new MavenProject(model);
task.setProject(project);
task.execute(mac.archiver, mac.configSource);
mockManager.verifyAll();
}
use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.
the class DefaultDependencyResolverTest method test_getModuleSetResolutionRequirements.
public void test_getModuleSetResolutionRequirements() throws DependencyResolutionException {
final EasyMockSupport mm = new EasyMockSupport();
final AssemblerConfigurationSource cs = mm.createMock(AssemblerConfigurationSource.class);
final File rootDir = new File("root");
final MavenProject project = createMavenProject("main-group", "main-artifact", "1", rootDir);
final File module1Dir = new File(rootDir, "module-1");
final MavenProject module1 = createMavenProject("main-group", "module-1", "1", module1Dir);
final MavenProject module1a = createMavenProject("group1", "module-1a", "1", new File(module1Dir, "module-1a"));
final MavenProject module1b = createMavenProject("group1.b", "module-1b", "1", new File(module1Dir, "module-1b"));
module1.getModel().addModule(module1a.getArtifactId());
module1.getModel().addModule(module1b.getArtifactId());
final File module2Dir = new File(rootDir, "module-2");
final MavenProject module2 = createMavenProject("main-group", "module-2", "1", module2Dir);
final MavenProject module2a = createMavenProject("main-group", "module-2a", "1", new File(module2Dir, "module-2a"));
module2.getModel().addModule(module2a.getArtifactId());
project.getModel().addModule(module1.getArtifactId());
project.getModel().addModule(module2.getArtifactId());
final List<MavenProject> allProjects = new ArrayList<MavenProject>();
allProjects.add(project);
allProjects.add(module1);
allProjects.add(module1a);
allProjects.add(module1b);
allProjects.add(module2);
allProjects.add(module2a);
expect(cs.getReactorProjects()).andReturn(allProjects).anyTimes();
expect(cs.getProject()).andReturn(project).anyTimes();
expect(cs.getMavenSession()).andReturn(newMavenSession(project)).anyTimes();
final ResolutionManagementInfo info = new ResolutionManagementInfo(project);
final List<ModuleSet> moduleSets = new ArrayList<ModuleSet>();
final ModuleSet ms1 = new ModuleSet();
final DependencySet ds1 = new DependencySet();
{
ms1.addInclude("*module1*");
ms1.setIncludeSubModules(false);
final ModuleBinaries mb = new ModuleBinaries();
ds1.setScope(Artifact.SCOPE_COMPILE);
mb.addDependencySet(ds1);
ms1.setBinaries(mb);
moduleSets.add(ms1);
}
final ModuleSet ms2 = new ModuleSet();
final DependencySet ds2 = new DependencySet();
{
ms2.addInclude("main-group:*");
ms2.setIncludeSubModules(true);
final ModuleBinaries mb = new ModuleBinaries();
ds2.setScope(Artifact.SCOPE_TEST);
mb.addDependencySet(ds2);
ms2.setBinaries(mb);
moduleSets.add(ms2);
}
mm.replayAll();
resolver.enableLogging(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
final Assembly assembly = new Assembly();
assembly.setModuleSets(moduleSets);
resolver.updateModuleSetResolutionRequirements(AssemblyId.createAssemblyId(assembly), ms1, ds1, info, cs);
resolver.updateModuleSetResolutionRequirements(AssemblyId.createAssemblyId(assembly), ms2, ds2, info, cs);
assertTrue(info.isResolutionRequired());
final Set<MavenProject> enabledProjects = info.getEnabledProjects();
assertTrue(enabledProjects.contains(project));
assertTrue(enabledProjects.contains(module1));
// these should be excluded since sub-modules are not traversable
assertFalse(enabledProjects.contains(module1a));
assertFalse(enabledProjects.contains(module1b));
assertTrue(enabledProjects.contains(module2));
assertTrue(enabledProjects.contains(module2a));
// these are the two we directly set above.
assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_TEST));
assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_COMPILE));
// this combination should be implied by the two direct scopes set above.
assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_RUNTIME));
assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_PROVIDED));
assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_SYSTEM));
mm.verifyAll();
}
use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testMergeComponentsWithMainAssembly_ShouldAddOneFileSetToAssembly.
public void testMergeComponentsWithMainAssembly_ShouldAddOneFileSetToAssembly() throws IOException, AssemblyReadException {
final Component component = new Component();
final FileSet fileSet = new FileSet();
fileSet.setDirectory("/dir");
component.addFileSet(fileSet);
final File componentFile = fileManager.createTempFile();
Writer writer = null;
try {
writer = new OutputStreamWriter(new FileOutputStream(componentFile), "UTF-8");
final ComponentXpp3Writer componentWriter = new ComponentXpp3Writer();
componentWriter.write(writer, component);
writer.close();
writer = null;
} finally {
IOUtil.close(writer);
}
final String filename = componentFile.getName();
final Assembly assembly = new Assembly();
assembly.addComponentDescriptor(filename);
final File basedir = componentFile.getParentFile();
final MavenProject project = new MavenProject();
expect(configSource.getProject()).andReturn(project).anyTimes();
expect(configSource.getBasedir()).andReturn(basedir).anyTimes();
DefaultAssemblyArchiverTest.setupInterpolators(configSource);
InterpolationState is = new InterpolationState();
ComponentXpp3Reader.ContentTransformer componentIp = AssemblyInterpolator.componentInterpolator(FixedStringSearchInterpolator.create(), is, new ConsoleLogger(Logger.LEVEL_DEBUG, "console"));
mockManager.replayAll();
new DefaultAssemblyReader().mergeComponentsWithMainAssembly(assembly, null, configSource, componentIp);
final List<FileSet> fileSets = assembly.getFileSets();
assertNotNull(fileSets);
assertEquals(1, fileSets.size());
final FileSet fs = fileSets.get(0);
assertEquals("/dir", fs.getDirectory());
mockManager.verifyAll();
}
use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.
the class FileItemAssemblyPhaseTest method testExecute_ShouldAddAbsoluteFileNoFilterNoLineEndingConversion.
public void testExecute_ShouldAddAbsoluteFileNoFilterNoLineEndingConversion() throws ArchiveCreationException, AssemblyFormattingException, IOException {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
final File basedir = fileManager.createTempDir();
final File file = fileManager.createFile(basedir, "file.txt", "This is a test file.");
macCS.expectGetBasedir(basedir);
macCS.expectGetProject(new MavenProject(new Model()));
macCS.expectGetFinalName("final-name");
macCS.expectInterpolators();
final MockAndControlForLogger macLogger = new MockAndControlForLogger(mm);
final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
final Assembly assembly = new Assembly();
assembly.setId("test");
final FileItem fi = new FileItem();
fi.setSource(file.getAbsolutePath());
fi.setFiltered(false);
fi.setLineEnding("keep");
fi.setFileMode("777");
macArchiver.expectAddFile(file, "file.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
assembly.addFile(fi);
mm.replayAll();
createPhase(macLogger.logger).execute(assembly, macArchiver.archiver, macCS.configSource);
mm.verifyAll();
}
use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.
the class FileItemAssemblyPhaseTest method testExecute_WithOutputDirectoryAndDestNameAndIncludeBaseDirectoryFalse.
public void testExecute_WithOutputDirectoryAndDestNameAndIncludeBaseDirectoryFalse() throws Exception {
final EasyMockSupport mm = new EasyMockSupport();
final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
final File basedir = fileManager.createTempDir();
final File readmeFile = fileManager.createFile(basedir, "README.txt", "This is a test file for README.txt.");
final File licenseFile = fileManager.createFile(basedir, "LICENSE.txt", "This is a test file for LICENSE.txt.");
final File configFile = fileManager.createFile(basedir, "config/config.txt", "This is a test file for config/config.txt");
macCS.expectGetBasedir(basedir);
macCS.expectGetProject(new MavenProject(new Model()));
macCS.expectGetFinalName("final-name");
macCS.expectInterpolators();
final MockAndControlForLogger macLogger = new MockAndControlForLogger(mm);
final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
final Assembly assembly = new Assembly();
assembly.setId("test");
assembly.setIncludeBaseDirectory(false);
final FileItem readmeFileItem = new FileItem();
readmeFileItem.setSource("README.txt");
readmeFileItem.setDestName("README_renamed.txt");
readmeFileItem.setFiltered(false);
readmeFileItem.setLineEnding("keep");
readmeFileItem.setFileMode("777");
final FileItem licenseFileItem = new FileItem();
licenseFileItem.setSource("LICENSE.txt");
licenseFileItem.setDestName("LICENSE_renamed.txt");
licenseFileItem.setFiltered(false);
licenseFileItem.setLineEnding("keep");
licenseFileItem.setFileMode("777");
final FileItem configFileItem = new FileItem();
configFileItem.setSource("config/config.txt");
configFileItem.setDestName("config_renamed.txt");
configFileItem.setOutputDirectory("config");
configFileItem.setFiltered(false);
configFileItem.setLineEnding("keep");
configFileItem.setFileMode("777");
macArchiver.expectAddFile(readmeFile, "README_renamed.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
macArchiver.expectAddFile(licenseFile, "LICENSE_renamed.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
macArchiver.expectAddFile(configFile, "config/config_renamed.txt", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
assembly.addFile(readmeFileItem);
assembly.addFile(licenseFileItem);
assembly.addFile(configFileItem);
mm.replayAll();
createPhase(macLogger.logger).execute(assembly, macArchiver.archiver, macCS.configSource);
mm.verifyAll();
}
Aggregations