use of org.apache.maven.model.Resource in project OpenAM by OpenRock.
the class CLIDefinitionGenerator method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
for (String className : definitions) {
try {
Class clazz = Class.forName(className);
Field pdtField = clazz.getDeclaredField("product");
if (pdtField != null) {
DefinitionClassInfo classInfo = pdtField.getAnnotation(DefinitionClassInfo.class);
PrintStream rbOut = createResourcePrintStream(outputDir, classInfo);
getCommonResourceStrings(rbOut, clazz);
rbOut.println("product-name=" + classInfo.productName());
getCommands(className, clazz, rbOut);
rbOut.close();
} else {
throw new Exception("Incorrect Definiton, class=" + className + " missing product field");
}
} catch (Exception ex) {
throw new MojoFailureException("An error occured while generating CLI resources", ex);
}
}
Resource resource = new Resource();
resource.setDirectory(outputDir);
project.addResource(resource);
}
use of org.apache.maven.model.Resource in project jangaroo-tools by CoreMedia.
the class JooTestMojoTest method testNoTestsAvailable.
public void testNoTestsAvailable() throws MojoExecutionException, MojoFailureException, IOException {
File f = File.createTempFile("JooTestMojoTest", "");
Assert.assertTrue(f.delete());
Assert.assertTrue(f.mkdirs());
jooTestMojo.setTestSourceDirectory(f);
jooTestMojo.setTestResources(new ArrayList<Resource>());
jooTestMojo.execute();
Assert.assertTrue(f.delete());
}
use of org.apache.maven.model.Resource in project maven-plugins by apache.
the class MavenProjectResourcesStub method setupResources.
private void setupResources() {
Resource resource = new Resource();
// see MavenProjectBasicStub for details
// of getBasedir
// setup default resources
resource.setDirectory(getBasedir().getPath() + "/src/main/resources");
resource.setFiltering(false);
resource.setTargetPath(null);
build.addResource(resource);
}
use of org.apache.maven.model.Resource in project maven-plugins by apache.
the class AbstractSourceJarMojo method archiveProjectContent.
/**
* @param p {@link MavenProject}
* @param archiver {@link Archiver}
* @throws MojoExecutionException in case of an error.
*/
protected void archiveProjectContent(MavenProject p, Archiver archiver) throws MojoExecutionException {
if (includePom) {
try {
archiver.addFile(p.getFile(), p.getFile().getName());
} catch (ArchiverException e) {
throw new MojoExecutionException("Error adding POM file to target jar file.", e);
}
}
for (String s : getSources(p)) {
File sourceDirectory = new File(s);
if (sourceDirectory.exists()) {
addDirectory(archiver, sourceDirectory, getCombinedIncludes(null), getCombinedExcludes(null));
}
}
// MAPI: this should be taken from the resources plugin
for (Resource resource : getResources(p)) {
File sourceDirectory = new File(resource.getDirectory());
if (!sourceDirectory.exists()) {
continue;
}
List<String> resourceIncludes = resource.getIncludes();
String[] combinedIncludes = getCombinedIncludes(resourceIncludes);
List<String> resourceExcludes = resource.getExcludes();
String[] combinedExcludes = getCombinedExcludes(resourceExcludes);
String targetPath = resource.getTargetPath();
if (targetPath != null) {
if (!targetPath.trim().endsWith("/")) {
targetPath += "/";
}
addDirectory(archiver, sourceDirectory, targetPath, combinedIncludes, combinedExcludes);
} else {
addDirectory(archiver, sourceDirectory, combinedIncludes, combinedExcludes);
}
}
}
use of org.apache.maven.model.Resource in project maven-plugins by apache.
the class MavenJDOMWriter method iterateResource.
// -- void iterateRepository(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
* Method iterateResource
*
* @param counter
* @param childTag
* @param parentTag
* @param list
* @param parent
*/
protected void iterateResource(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) {
boolean shouldExist = list != null && list.size() > 0;
Element element = updateElement(counter, parent, parentTag, shouldExist);
if (shouldExist) {
Iterator it = list.iterator();
Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator();
if (!elIt.hasNext()) {
elIt = null;
}
Counter innerCount = new Counter(counter.getDepth() + 1);
while (it.hasNext()) {
Resource value = (Resource) it.next();
Element el;
if (elIt != null && elIt.hasNext()) {
el = (Element) elIt.next();
if (!elIt.hasNext()) {
elIt = null;
}
} else {
el = factory.element(childTag, element.getNamespace());
insertAtPreferredLocation(element, el, innerCount);
}
updateResource(value, childTag, innerCount, el);
innerCount.increaseCount();
}
if (elIt != null) {
while (elIt.hasNext()) {
elIt.next();
elIt.remove();
}
}
}
}
Aggregations