use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testReadAssembly_ShouldReadAssemblyWithSiteDirInclusionFromAssemblyWithoutComponentsOrInterpolation.
public void testReadAssembly_ShouldReadAssemblyWithSiteDirInclusionFromAssemblyWithoutComponentsOrInterpolation() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
final Assembly assembly = new Assembly();
assembly.setId("test");
assembly.setIncludeSiteDirectory(true);
final StringReader sr = writeToStringReader(assembly);
final File siteDir = fileManager.createTempDir();
expect(configSource.getSiteDirectory()).andReturn(siteDir).anyTimes();
final File basedir = fileManager.createTempDir();
expect(configSource.getBasedir()).andReturn(basedir).anyTimes();
final Model model = new Model();
model.setGroupId("group");
model.setArtifactId("artifact");
model.setVersion("version");
final MavenProject project = new MavenProject(model);
expect(configSource.getProject()).andReturn(project).anyTimes();
DefaultAssemblyArchiverTest.setupInterpolators(configSource);
mockManager.replayAll();
final Assembly result = new DefaultAssemblyReader().readAssembly(sr, "testLocation", null, configSource);
assertEquals(assembly.getId(), result.getId());
final List<FileSet> fileSets = result.getFileSets();
assertEquals(1, fileSets.size());
assertEquals("/site", fileSets.get(0).getOutputDirectory());
mockManager.verifyAll();
}
use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testReadAssembly_ShouldReadAssemblyWithComponentWithoutSiteDirInclusionOrInterpolation.
public void testReadAssembly_ShouldReadAssemblyWithComponentWithoutSiteDirInclusionOrInterpolation() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
final File componentsFile = fileManager.createTempFile();
final File basedir = componentsFile.getParentFile();
final String componentsFilename = componentsFile.getName();
final Component component = new Component();
final FileSet fs = new FileSet();
fs.setDirectory("/dir");
component.addFileSet(fs);
Writer fw = null;
try {
fw = new OutputStreamWriter(new FileOutputStream(componentsFile), "UTF-8");
new ComponentXpp3Writer().write(fw, component);
fw.close();
fw = null;
} finally {
IOUtil.close(fw);
}
final Assembly assembly = new Assembly();
assembly.setId("test");
assembly.addComponentDescriptor(componentsFilename);
final StringReader sr = writeToStringReader(assembly);
expect(configSource.getBasedir()).andReturn(basedir).anyTimes();
final Model model = new Model();
model.setGroupId("group");
model.setArtifactId("artifact");
model.setVersion("version");
final MavenProject project = new MavenProject(model);
expect(configSource.getProject()).andReturn(project).anyTimes();
DefaultAssemblyArchiverTest.setupInterpolators(configSource);
mockManager.replayAll();
final Assembly result = new DefaultAssemblyReader().readAssembly(sr, "testLocation", null, configSource);
assertEquals(assembly.getId(), result.getId());
final List<FileSet> fileSets = result.getFileSets();
assertEquals(1, fileSets.size());
assertEquals("/dir", fileSets.get(0).getDirectory());
mockManager.verifyAll();
}
use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class AssemblyFormatUtilsTest method createProject.
private MavenProject createProject(String groupId, String artifactId, String version, final Properties projectProperties) {
if (artifactId == null) {
artifactId = "artifact";
}
if (groupId == null) {
groupId = "group";
}
if (version == null) {
version = "version";
}
final Model model = new Model();
model.setGroupId(groupId);
model.setArtifactId(artifactId);
model.setVersion(version);
model.setProperties(projectProperties);
return new MavenProject(model);
}
use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class AssemblyInterpolatorTest method testShouldResolveModelPropertyBeforeModelGroupIdInAssemblyId.
public void testShouldResolveModelPropertyBeforeModelGroupIdInAssemblyId() throws AssemblyInterpolationException, InvalidAssemblerConfigurationException, AssemblyReadException, IOException {
final Model model = new Model();
model.setArtifactId("artifact-id");
model.setGroupId("group.id");
model.setVersion("1");
model.setPackaging("jar");
final Properties props = new Properties();
props.setProperty("groupId", "other.id");
model.setProperties(props);
final PojoConfigSource configSourceStub = new PojoConfigSource();
configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
final Assembly assembly = new Assembly();
assembly.setId("assembly.${groupId}");
final MavenProject project = new MavenProject(model);
configSourceStub.setMavenProject(project);
final Assembly result = roundTripInterpolation(assembly, configSourceStub);
assertEquals("assembly.other.id", result.getId());
}
use of org.apache.maven.project.MavenProject in project maven-plugins by apache.
the class DefaultCheckstyleExecutor method configureResourceLocator.
/**
* Configures search paths in the resource locator.
* This method should only be called once per execution.
*
* @param request executor request data.
*/
private void configureResourceLocator(final ResourceManager resourceManager, final CheckstyleExecutorRequest request, final List<Artifact> additionalArtifacts) {
final MavenProject project = request.getProject();
resourceManager.setOutputDirectory(new File(project.getBuild().getDirectory()));
// Recurse up the parent hierarchy and add project directories to the search roots
MavenProject parent = project;
while (parent != null && parent.getFile() != null) {
// MCHECKSTYLE-131 ( olamy ) I don't like this hack.
// (dkulp) Me either. It really pollutes the location stuff
// by allowing searches of stuff outside the current module.
File dir = parent.getFile().getParentFile();
resourceManager.addSearchPath(FileResourceLoader.ID, dir.getAbsolutePath());
parent = parent.getParent();
}
resourceManager.addSearchPath("url", "");
// MCHECKSTYLE-225: load licenses from additional artifacts, not from classpath
if (additionalArtifacts != null) {
for (Artifact licenseArtifact : additionalArtifacts) {
try {
resourceManager.addSearchPath("jar", "jar:" + licenseArtifact.getFile().toURI().toURL());
} catch (MalformedURLException e) {
// noop
}
}
}
}
Aggregations