use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class FileItemAssemblyPhaseTest method testExecute_WithOutputDirectoryAndDestName.
public void testExecute_WithOutputDirectoryAndDestName() 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);
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
macLogger.logger.error("OS=Windows and the assembly descriptor contains a *nix-specific " + "root-relative-reference (starting with slash) /");
} else {
macLogger.logger.warn((String) anyObject());
}
final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
final Assembly assembly = new Assembly();
assembly.setId("test");
assembly.setIncludeBaseDirectory(true);
final FileItem readmeFileItem = new FileItem();
readmeFileItem.setSource("README.txt");
readmeFileItem.setOutputDirectory("");
readmeFileItem.setDestName("README_renamed.txt");
readmeFileItem.setFiltered(false);
readmeFileItem.setLineEnding("keep");
readmeFileItem.setFileMode("777");
final FileItem licenseFileItem = new FileItem();
licenseFileItem.setSource("LICENSE.txt");
licenseFileItem.setOutputDirectory("/");
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();
}
use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class ModuleSetAssemblyPhaseTest method testGetModuleProjects_ShouldExcludeModuleAndDescendentsTransitively.
public void testGetModuleProjects_ShouldExcludeModuleAndDescendentsTransitively() throws ArchiveCreationException {
final EasyMockSupport mm = new EasyMockSupport();
final MavenProject project = createProject("group", "artifact", "version", null);
final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, project);
addArtifact(project, mm, false);
final MavenProject project2 = createProject("group", "artifact2", "version", project);
addArtifact(project2, mm, false);
final MavenProject project3 = createProject("group", "artifact3", "version", project2);
addArtifact(project3, mm, true);
final List<MavenProject> projects = new ArrayList<MavenProject>();
projects.add(project);
projects.add(project2);
projects.add(project3);
macTask.expectGetReactorProjects(projects);
final ModuleSet moduleSet = new ModuleSet();
moduleSet.setIncludeSubModules(true);
moduleSet.addExclude("group:artifact2");
mm.replayAll();
final Set<MavenProject> moduleProjects = ModuleSetAssemblyPhase.getModuleProjects(moduleSet, macTask.configSource, logger);
assertTrue(moduleProjects.isEmpty());
mm.verifyAll();
}
use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class ModuleSetAssemblyPhaseTest method testCreateFileSet_ShouldPrependModuleDirWhenOutDirIsProvided.
public void testCreateFileSet_ShouldPrependModuleDirWhenOutDirIsProvided() throws AssemblyFormattingException {
final EasyMockSupport mm = new EasyMockSupport();
final Model model = new Model();
model.setArtifactId("artifact");
final MavenProject project = new MavenProject(model);
final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm, project);
macTask.expectGetFinalName(null);
final FileSet fs = new FileSet();
fs.setOutputDirectory("out");
final ModuleSources sources = new ModuleSources();
sources.setIncludeModuleDirectory(true);
final MavenProject artifactProject = new MavenProject(new Model());
final File basedir = fileManager.createTempDir();
artifactProject.setFile(new File(basedir, "pom.xml"));
final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "jar", false);
artifactProject.setArtifact(artifactMock.getArtifact());
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mm.replayAll();
final FileSet result = createPhase(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null).createFileSet(fs, sources, artifactProject, macTask.configSource);
assertEquals("artifact/out/", result.getOutputDirectory());
mm.verifyAll();
}
use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class AddArtifactTaskTest method setUp.
public void setUp() throws IOException {
mockManager = new EasyMockSupport();
Model model = new Model();
model.setGroupId("group");
model.setArtifactId("main");
model.setVersion("1000");
MavenProject mainProject = new MavenProject(model);
mac = new MockAndControlForAddArtifactTask(mockManager, mainProject);
mac.expectGetFinalName("final-name");
}
use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class AddDependencySetsTaskTest method testGetDependencyArtifacts_ShouldGetOneDependencyArtifact.
public void testGetDependencyArtifacts_ShouldGetOneDependencyArtifact() throws ArchiveCreationException, InvalidAssemblerConfigurationException {
final MavenProject project = new MavenProject(new Model());
final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager);
final ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", "version", "jar", false);
project.setArtifacts(Collections.singleton(artifactMock.getArtifact()));
final DependencySet dependencySet = new DependencySet();
final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
mockManager.replayAll();
final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(dependencySet), Collections.singleton(artifactMock.getArtifact()), project, macTask.projectBuilder, logger);
final Set<Artifact> result = task.resolveDependencyArtifacts(dependencySet);
assertNotNull(result);
assertEquals(1, result.size());
assertSame(artifactMock.getArtifact(), result.iterator().next());
mockManager.verifyAll();
}
Aggregations