Java Examples for org.apache.maven.artifact.DependencyResolutionRequiredException
The following java examples will help you to understand the usage of org.apache.maven.artifact.DependencyResolutionRequiredException. These source code samples are taken from different open source projects.
Example 1
Project: apt-maven-plugin-master File: AbstractProcessorMojo.java View source code |
@SuppressWarnings("unchecked")
private String buildCompileClasspath() {
List<String> pathElements = null;
try {
if (isForTest()) {
pathElements = project.getTestClasspathElements();
} else {
pathElements = project.getCompileClasspathElements();
}
} catch (DependencyResolutionRequiredException e) {
super.getLog().warn("exception calling getCompileClasspathElements", e);
return null;
}
if (pluginArtifacts != null) {
for (Artifact a : pluginArtifacts) {
if (a.getFile() != null) {
pathElements.add(a.getFile().getAbsolutePath());
}
}
}
if (pathElements.isEmpty()) {
return null;
}
StringBuilder result = new StringBuilder();
int i = 0;
for (i = 0; i < pathElements.size() - 1; ++i) {
result.append(pathElements.get(i)).append(File.pathSeparatorChar);
}
result.append(pathElements.get(i));
return result.toString();
}
Example 2
Project: ginger-master File: ClasspathUtils.java View source code |
public static List<URL> getResources(MavenProject project, boolean testClasspath) throws MojoExecutionException {
try {
Set<String> classpathElements = new HashSet<String>();
classpathElements.addAll(project.getCompileClasspathElements());
classpathElements.addAll(project.getRuntimeClasspathElements());
if (testClasspath) {
classpathElements.addAll(project.getTestClasspathElements());
}
List<URL> projectClasspathList = new ArrayList<URL>();
for (String element : classpathElements) {
try {
projectClasspathList.add(new File(element).toURI().toURL());
} catch (MalformedURLException e) {
throw new MojoExecutionException(element + " is an invalid classpath element", e);
}
}
URL[] urls = projectClasspathList.toArray(new URL[projectClasspathList.size()]);
return Arrays.asList(urls);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Dependency resolution failed", e);
}
}
Example 3
Project: liquigraph-master File: ProjectClassLoader.java View source code |
public static ClassLoader getClassLoader(MavenProject project) throws DependencyResolutionRequiredException, MalformedURLException {
List<String> classPathElements = compileClassPathElements(project);
List<URL> classpathElementUrls = new ArrayList<>(classPathElements.size());
for (String classPathElement : classPathElements) {
classpathElementUrls.add(new File(classPathElement).toURI().toURL());
}
return new URLClassLoader(classpathElementUrls.toArray(new URL[classpathElementUrls.size()]), Thread.currentThread().getContextClassLoader());
}
Example 4
Project: maven-guvnor-bulk-importer-master File: ImportFileGeneratorMojo.java View source code |
private void addProjectDependenciesToClasspath(MavenProject project) {
try {
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
ClassLoader newClassLoader = new ProjectClasspath().getClassLoader(project, oldClassLoader, getLog());
Thread.currentThread().setContextClassLoader(newClassLoader);
} catch (DependencyResolutionRequiredException e) {
getLog().info("Skipping addition of project artifacts, there appears to be a dependecy resolution problem", e);
}
}
Example 5
Project: clojureshell-maven-plugin-master File: AbstractClassloaderMojo.java View source code |
private ClassLoader getClassLoader(ClassLoader parent) throws DependencyResolutionRequiredException {
Scope sc = Scope.valueOf(scope.toUpperCase());
List<URL> urls = new ArrayList<URL>();
getLog().debug("Creating class loader...");
try {
if (classpath != null) {
addClasspathElements(Arrays.asList(classpath.split(File.pathSeparator)), urls);
}
if (includeStdDirs) {
addClasspathElement("src/main/clojure", urls);
}
addClasspathElements(project.getRuntimeClasspathElements(), urls);
if (sc == Scope.TEST) {
if (includeStdDirs) {
addClasspathElement("src/test/clojure", urls);
}
addClasspathElements(project.getTestClasspathElements(), urls);
}
} catch (MalformedURLException e) {
getLog().error(e);
}
return new URLClassLoader(urls.toArray(new URL[urls.size()]), parent);
}
Example 6
Project: fitnesse-maven-classpath-master File: MavenClasspathExtractor.java View source code |
public List<String> extractClasspathEntries(File pomFile, String scope) throws MavenClasspathExtractionException {
try {
MavenRequest mavenRequest = mavenConfiguration();
mavenRequest.setResolveDependencies(true);
mavenRequest.setBaseDirectory(pomFile.getParent());
mavenRequest.setPom(pomFile.getAbsolutePath());
DependencyResolvingMavenEmbedder dependencyResolvingMavenEmbedder = new DependencyResolvingMavenEmbedder(getClass().getClassLoader(), mavenRequest);
ProjectBuildingResult projectBuildingResult = dependencyResolvingMavenEmbedder.buildProject(pomFile);
return getClasspathForScope(projectBuildingResult, scope);
} catch (MavenEmbedderException mee) {
throw new MavenClasspathExtractionException(mee);
} catch (ComponentLookupException cle) {
throw new MavenClasspathExtractionException(cle);
} catch (DependencyResolutionRequiredException e) {
throw new MavenClasspathExtractionException(e);
} catch (ProjectBuildingException e) {
throw new MavenClasspathExtractionException(e);
}
}
Example 7
Project: GMavenPlus-master File: AbstractGroovyDocMojo.java View source code |
/**
* Generates the GroovyDoc for the specified sources.
*
* @param sourceDirectories The source directories to generate GroovyDoc for
* @param classpath The classpath to use for compilation
* @param outputDirectory The directory to save the generated GroovyDoc in
* @throws ClassNotFoundException when a class needed for GroovyDoc generation cannot be found
* @throws InstantiationException when a class needed for GroovyDoc generation cannot be instantiated
* @throws IllegalAccessException when a method needed for GroovyDoc generation cannot be accessed
* @throws InvocationTargetException when a reflection invocation needed for GroovyDoc generation cannot be completed
* @throws MalformedURLException when a classpath element provides a malformed URL
*/
@SuppressWarnings("unchecked")
protected synchronized void doGroovyDocGeneration(final FileSet[] sourceDirectories, final List classpath, final File outputDirectory) throws ClassNotFoundException, InvocationTargetException, IllegalAccessException, InstantiationException, MalformedURLException {
classWrangler = new ClassWrangler(classpath, getLog());
if (skipGroovyDoc) {
getLog().info("Skipping generation of GroovyDoc because ${maven.groovydoc.skip} was set to true.");
return;
}
if (sourceDirectories == null || sourceDirectories.length == 0) {
getLog().info("No source directories specified for GroovyDoc generation. Skipping.");
return;
}
if (groovyVersionSupportsAction()) {
classWrangler.logGroovyVersion(mojoExecution.getMojoDescriptor().getGoal());
logPluginClasspath();
try {
getLog().debug("Project compile classpath:\n" + project.getCompileClasspathElements());
} catch (DependencyResolutionRequiredException e) {
getLog().warn("Unable to log project compile classpath", e);
}
} else {
getLog().error("Your Groovy version (" + classWrangler.getGroovyVersionString() + ") doesn't support GroovyDoc. The minimum version of Groovy required is " + minGroovyVersion + ". Skipping GroovyDoc generation.");
return;
}
if (groovyIs(GROOVY_1_6_0_RC1) || groovyIs(GROOVY_1_5_8)) {
// Groovy 1.5.8 and 1.6-RC-1 are blacklisted because of their dependency on org.apache.tools.ant.types.Path in GroovyDocTool constructor
getLog().warn("Groovy " + GROOVY_1_5_8 + " and " + GROOVY_1_6_0_RC1 + " are blacklisted from the supported GroovyDoc versions because of their dependency on Ant. Skipping GroovyDoc generation.");
return;
}
// get classes we need with reflection
Class<?> groovyDocToolClass = classWrangler.getClass("org.codehaus.groovy.tools.groovydoc.GroovyDocTool");
Class<?> outputToolClass = classWrangler.getClass("org.codehaus.groovy.tools.groovydoc.OutputTool");
Class<?> fileOutputToolClass = classWrangler.getClass("org.codehaus.groovy.tools.groovydoc.FileOutputTool");
Class<?> resourceManagerClass = classWrangler.getClass("org.codehaus.groovy.tools.groovydoc.ResourceManager");
Class<?> classpathResourceManagerClass = classWrangler.getClass("org.codehaus.groovy.tools.groovydoc.ClasspathResourceManager");
// set up GroovyDoc options
Properties docProperties = setupProperties();
Object fileOutputTool = invokeConstructor(findConstructor(fileOutputToolClass));
Object classpathResourceManager = invokeConstructor(findConstructor(classpathResourceManagerClass));
FileSetManager fileSetManager = new FileSetManager(getLog());
List<String> sourceDirectoriesStrings = new ArrayList<String>();
for (FileSet sourceDirectory : sourceDirectories) {
sourceDirectoriesStrings.add(sourceDirectory.getDirectory());
}
GroovyDocTemplateInfo groovyDocTemplateInfo = new GroovyDocTemplateInfo(classWrangler.getGroovyVersion());
List groovyDocLinks = setupLinks();
if (groovyOlderThan(GROOVY_1_6_0_RC2)) {
getLog().warn("Your Groovy version (" + classWrangler.getGroovyVersionString() + ") doesn't support GroovyDoc documentation properties (docTitle, footer, header, displayAuthor, overviewFile, and scope). You need Groovy 1.6-RC-2 or newer to support this. Ignoring properties.");
}
// prevent Java stubs (which lack Javadoc) from overwriting GroovyDoc by removing Java sources
List<String> groovyDocSources = setupGroovyDocSources(sourceDirectories, fileSetManager);
// instantiate GroovyDocTool
Object groovyDocTool = createGroovyDocTool(groovyDocToolClass, resourceManagerClass, docProperties, classpathResourceManager, sourceDirectoriesStrings, groovyDocTemplateInfo, groovyDocLinks);
// generate GroovyDoc
generateGroovyDoc(outputDirectory, groovyDocToolClass, outputToolClass, fileOutputTool, groovyDocSources, groovyDocTool);
// overwrite stylesheet.css with provided stylesheet (if configured)
if (stylesheetFile != null) {
copyStylesheet(outputDirectory);
}
}
Example 8
Project: Jnario-master File: XtendTestCompile.java View source code |
@SuppressWarnings("deprecation")
protected List<String> getTestClassPath() {
Set<String> classPath = Sets.newLinkedHashSet();
classPath.add(project.getBuild().getTestSourceDirectory());
try {
classPath.addAll(project.getTestClasspathElements());
} catch (DependencyResolutionRequiredException e) {
throw new WrappedException(e);
}
addDependencies(classPath, project.getTestArtifacts());
return newArrayList(filter(classPath, FILE_EXISTS));
}
Example 9
Project: jsonschema2pojo-master File: Jsonschema2PojoMojo.java View source code |
private void addProjectDependenciesToClasspath() {
try {
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
ClassLoader newClassLoader = new ProjectClasspath().getClassLoader(project, oldClassLoader, getLog());
Thread.currentThread().setContextClassLoader(newClassLoader);
} catch (DependencyResolutionRequiredException e) {
getLog().info("Skipping addition of project artifacts, there appears to be a dependecy resolution problem", e);
}
}
Example 10
Project: maven-openfire-plugin-master File: OpenfireMojo.java View source code |
/**
* Executes the OpenfireMojo on the current project.
*
* @throws MojoExecutionException if an error occured while building the webapp
*/
public void execute() throws MojoExecutionException, MojoFailureException {
File warFile = getWarFile(new File(outputDirectory), warName, classifier);
try {
performPackaging(warFile);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Error assembling Openfire Plugin: " + e.getMessage(), e);
} catch (ManifestException e) {
throw new MojoExecutionException("Error assembling Openfire Plugin", e);
} catch (IOException e) {
throw new MojoExecutionException("Error assembling Openfire Plugin", e);
} catch (ArchiverException e) {
throw new MojoExecutionException("Error assembling Openfire Plugin: " + e.getMessage(), e);
}
}
Example 11
Project: ocamljava-maven-plugin-master File: ClassPathGatherer.java View source code |
protected Set<String> getClassPathRec(final MavenProject project, final boolean isTest) throws DependencyResolutionRequiredException, MalformedURLException {
final ImmutableSet.Builder<String> builder = ImmutableSet.<String>builder().addAll(project.getCompileClasspathElements()).addAll(project.getRuntimeClasspathElements()).addAll(project.getSystemClasspathElements());
if (isTest)
builder.addAll(project.getTestClasspathElements());
final List<MavenProject> collectedProjects = project.getCollectedProjects();
for (final MavenProject mavenProject : collectedProjects) {
mojo.getLog().info("mavenProject: " + mavenProject.getArtifactId());
builder.addAll(getClassPathRec(mavenProject, isTest));
}
return builder.build();
}
Example 12
Project: Prime-Mover-master File: TestTransform.java View source code |
@Override
protected String getCompileClasspath() throws MojoExecutionException {
List<?> testClasspathElements;
try {
testClasspathElements = project.getTestClasspathElements();
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Unable to perform test dependency resolution", e);
}
getLog().debug(String.format("Runtime classpath elements: %s", testClasspathElements));
StringBuffer classpath = new StringBuffer();
classpath.append(getBootClasspath());
for (Object element : testClasspathElements) {
classpath.append(':');
classpath.append(element);
}
String pathString = classpath.toString();
getLog().info(String.format("Test transform classpath: %s", pathString));
return pathString;
}
Example 13
Project: avro-master File: IDLProtocolMojo.java View source code |
@Override
protected void doCompile(String filename, File sourceDirectory, File outputDirectory) throws IOException {
try {
@SuppressWarnings("rawtypes") List runtimeClasspathElements = project.getRuntimeClasspathElements();
Idl parser;
List<URL> runtimeUrls = new ArrayList<URL>();
// Add the source directory of avro files to the classpath so that
// imports can refer to other idl files as classpath resources
runtimeUrls.add(sourceDirectory.toURI().toURL());
// If runtimeClasspathElements is not empty values add its values to Idl path.
if (runtimeClasspathElements != null && !runtimeClasspathElements.isEmpty()) {
for (Object runtimeClasspathElement : runtimeClasspathElements) {
String element = (String) runtimeClasspathElement;
runtimeUrls.add(new File(element).toURI().toURL());
}
}
URLClassLoader projPathLoader = new URLClassLoader(runtimeUrls.toArray(new URL[0]), Thread.currentThread().getContextClassLoader());
parser = new Idl(new File(sourceDirectory, filename), projPathLoader);
Protocol p = parser.CompilationUnit();
String json = p.toString(true);
Protocol protocol = Protocol.parse(json);
SpecificCompiler compiler = new SpecificCompiler(protocol);
compiler.setStringType(GenericData.StringType.valueOf(stringType));
compiler.setTemplateDir(templateDirectory);
compiler.setFieldVisibility(getFieldVisibility());
compiler.setCreateSetters(createSetters);
compiler.setEnableDecimalLogicalType(enableDecimalLogicalType);
compiler.compileToDestination(null, outputDirectory);
} catch (ParseException e) {
throw new IOException(e);
} catch (DependencyResolutionRequiredException drre) {
throw new IOException(drre);
}
}
Example 14
Project: codehaus-mojo-master File: AbstractXmlBeansPlugin.java View source code |
/**
* <p/>
* Map the parameters to the schema compilers parameter object, make sure the necessary output directories exist,
* then call on the schema compiler to produce the java objects and supporting resources.
* </p>
*
* @throws MojoExecutionException Errors occurred during compile.
* @number MOJO-270
*/
public final void execute() throws MojoExecutionException {
if (hasSchemas()) {
try {
SchemaCompiler.Parameters compilerParams = ParameterAdapter.getCompilerParameters(this);
boolean stale = isOutputStale();
if (stale) {
try {
compilerParams.getSrcDir().mkdirs();
boolean result = SchemaCompiler.compile(compilerParams);
if (!result) {
StringBuffer errors = new StringBuffer();
for (Iterator iter = compilerParams.getErrorListener().iterator(); iter.hasNext(); ) {
Object o = iter.next();
errors.append("xml Error").append(o);
errors.append("\n");
}
throw new XmlBeansException(XmlBeansException.COMPILE_ERRORS, errors.toString());
}
touchStaleFile();
} catch (IOException ioe) {
throw new XmlBeansException(XmlBeansException.STALE_FILE_TOUCH, getStaleFile().getAbsolutePath(), ioe);
}
} else if (getLog().isInfoEnabled()) {
getLog().info("All schema objects are up to date.");
}
updateProject(project, compilerParams, stale);
} catch (DependencyResolutionRequiredException drre) {
throw new XmlBeansException(XmlBeansException.CLASSPATH_DEPENDENCY, drre);
}
} else if (getLog().isInfoEnabled()) {
getLog().info("Nothing to generate.");
}
}
Example 15
Project: core-integration-testing-master File: TestMojo.java View source code |
/**
* Runs this mojo.
*
* @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved.
*/
public void execute() throws MojoExecutionException {
try {
writeArtifacts(projectArtifacts, project.getArtifacts());
writeArtifacts(dependencyArtifacts, project.getDependencyArtifacts());
writeArtifacts(testArtifacts, project.getTestArtifacts());
writeClassPath(testClassPath, project.getTestClasspathElements());
writeClassPathChecksums(testClassPathChecksums, project.getTestClasspathElements());
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Failed to resolve dependencies", e);
}
}
Example 16
Project: coroutines-master File: TestInstrumentMojo.java View source code |
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
Log log = getLog();
File testOutputFolder = new File(getProject().getBuild().getTestOutputDirectory());
if (!testOutputFolder.isDirectory()) {
log.warn("Test folder doesn't exist -- nothing to instrument");
return;
}
List<String> classpath;
try {
classpath = getProject().getTestClasspathElements();
} catch (DependencyResolutionRequiredException ex) {
throw new MojoExecutionException("Dependency resolution problem", ex);
}
log.info("Processing test output folder ... ");
instrumentPath(log, classpath, testOutputFolder);
}
Example 17
Project: evosuite-master File: GenerateMojo.java View source code |
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("Going to generate tests with EvoSuite");
getLog().info("Total memory: " + memoryInMB + "mb");
getLog().info("Time per class: " + timeInMinutesPerClass + " minutes");
getLog().info("Number of used cores: " + numberOfCores);
if (cuts != null) {
getLog().info("Specified classes under test: " + cuts);
}
String target = null;
String cp = null;
try {
//the targets we want to generate tests for, ie the CUTs
for (String element : project.getCompileClasspathElements()) {
if (// we only target what has been compiled to a folder
element.endsWith(".jar")) {
continue;
}
File file = new File(element);
if (!file.exists()) {
/*
* don't add to target an element that does not exist
*/
continue;
}
if (!file.getAbsolutePath().startsWith(project.getBasedir().getAbsolutePath())) {
/*
This can happen in multi-module projects when module A has dependency on
module B. Then, both A and B source folders will end up on compile classpath,
although we are interested only in A
*/
continue;
}
if (target == null) {
target = element;
} else {
target = target + File.pathSeparator + element;
}
}
//build the classpath
Set<String> alreadyAdded = new HashSet<>();
for (String element : project.getTestClasspathElements()) {
if (element.toLowerCase().contains("powermock")) {
//PowerMock just leads to a lot of troubles, as it includes tools.jar code
getLog().warn("Skipping PowerMock dependency at: " + element);
continue;
}
if (element.toLowerCase().contains("jmockit")) {
//JMockit has same issue
getLog().warn("Skipping JMockit dependency at: " + element);
continue;
}
getLog().debug("TEST ELEMENT: " + element);
cp = addPathIfExists(cp, element, alreadyAdded);
}
} catch (DependencyResolutionRequiredException e) {
getLog().error("Error: " + e.getMessage(), e);
return;
}
File basedir = project.getBasedir();
getLog().info("Target: " + target);
getLog().debug("Classpath: " + cp);
getLog().info("Basedir: " + basedir.getAbsolutePath());
if (target == null || cp == null || basedir == null) {
getLog().info("Nothing to test");
return;
}
runEvoSuiteOnSeparatedProcess(target, cp, basedir.getAbsolutePath());
}
Example 18
Project: fenix-framework-master File: DmlZipCreatorMojo.java View source code |
@Override
public void execute() throws MojoExecutionException {
if (mavenProject.getArtifact().getType().equals("pom")) {
getLog().info("Cannot compute dml files for pom projects");
return;
}
Collection<String> compileClasspathElements;
try {
compileClasspathElements = mavenProject.getCompileClasspathElements();
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
List<String> classpath = new ArrayList<String>(compileClasspathElements);
for (Artifact artifact : mavenProject.getDependencyArtifacts()) {
if (artifact.getFile() != null && artifact.getFile().isDirectory()) {
classpath.add(artifact.getFile().getAbsolutePath());
}
}
DmlMojoUtils.augmentClassLoader(getLog(), classpath);
List<URL> dmlFiles = new ArrayList<URL>();
if (dmlSourceDirectory.exists()) {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(dmlSourceDirectory);
String[] includes = { "**\\*.dml" };
scanner.setIncludes(includes);
scanner.scan();
Resource resource = new Resource();
resource.setDirectory(dmlSourceDirectory.getAbsolutePath());
resource.addInclude("*.dml");
mavenProject.addResource(resource);
for (String includedFile : scanner.getIncludedFiles()) {
String filePath = dmlSourceDirectory.getAbsolutePath() + "/" + includedFile;
File file = new File(filePath);
try {
dmlFiles.add(file.toURI().toURL());
} catch (MalformedURLException e) {
getLog().error(e);
}
}
Collections.sort(dmlFiles, new Comparator<URL>() {
@Override
public int compare(URL o1, URL o2) {
return o1.toExternalForm().compareTo(o2.toExternalForm());
}
});
}
try {
Project project = DmlMojoUtils.getProject(mavenProject, dmlSourceDirectory, zipDestinationDirectory, dmlFiles, getLog(), verbose);
List<URL> dmls = new ArrayList<URL>();
for (DmlFile dmlFile : project.getFullDmlSortedList()) {
dmls.add(dmlFile.getUrl());
}
if (dmls.isEmpty()) {
getLog().info("No dml files found");
return;
} else {
File zipFile = new File(String.format("%s/%s_dmls.zip", zipDestinationDirectory, mavenProject.getArtifactId()));
zipFile.getParentFile().mkdirs();
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
Integer i = 1;
for (URL dmlURL : dmls) {
String name = String.format("/dmls/domain_model_%02d.dml", i++);
ZipEntry e = new ZipEntry(name);
out.putNextEntry(e);
File f = new File(zipDestinationDirectory + name);
FileUtils.copyURLToFile(dmlURL, f);
out.write(FileUtils.readFileToByteArray(f));
out.closeEntry();
}
out.close();
}
} catch (Exception e) {
getLog().error(e);
}
}
Example 19
Project: idea-plugin-maven-plugin-master File: PackagingMojo.java View source code |
private void addDependenciesToBundle(ZipBuilder zipBuilder) {
try {
for (String classPathElement : project.getRuntimeClasspathElements()) {
if (isOutputDirectory(classPathElement)) {
continue;
}
addToBundle(new File(classPathElement), zipBuilder);
}
} catch (DependencyResolutionRequiredException e) {
throw new RuntimeException(e);
}
}
Example 20
Project: incubator-streams-master File: StreamsPojoSourceGeneratorMojo.java View source code |
private void addProjectDependenciesToClasspath() {
try {
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
ClassLoader newClassLoader = new ProjectClasspath().getClassLoader(project, oldClassLoader, getLog());
Thread.currentThread().setContextClassLoader(newClassLoader);
} catch (DependencyResolutionRequiredException ex) {
LOGGER.info("Skipping addition of project artifacts, there appears to be a dependecy resolution problem", ex);
}
}
Example 21
Project: maven-integration-testing-master File: TestMojo.java View source code |
/**
* Runs this mojo.
*
* @throws MojoExecutionException If the output file could not be created or any dependency could not be resolved.
*/
public void execute() throws MojoExecutionException {
try {
writeArtifacts(projectArtifacts, project.getArtifacts());
writeArtifacts(dependencyArtifacts, project.getDependencyArtifacts());
writeArtifacts(testArtifacts, project.getTestArtifacts());
writeClassPath(testClassPath, project.getTestClasspathElements());
writeClassPathChecksums(testClassPathChecksums, project.getTestClasspathElements());
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Failed to resolve dependencies", e);
}
}
Example 22
Project: maven-plugins-master File: AbstractFixJavadocMojo.java View source code |
/** * @return the classLoader for the given project using lazy instantiation. * @throws MojoExecutionException if any */ private ClassLoader getProjectClassLoader() throws MojoExecutionException { if (projectClassLoader == null) { List<String> classPath; try { classPath = getCompileClasspathElements(project); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("DependencyResolutionRequiredException: " + e.getMessage(), e); } List<URL> urls = new ArrayList<URL>(classPath.size()); for (String filename : classPath) { try { urls.add(new File(filename).toURL()); } catch (MalformedURLException e) { throw new MojoExecutionException("MalformedURLException: " + e.getMessage(), e); } } projectClassLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]), null); } return projectClassLoader; }
Example 23
Project: piraso-master File: WarMojo.java View source code |
// ----------------------------------------------------------------------
// Implementation
// ----------------------------------------------------------------------
/**
* Executes the WarMojo on the current project.
*
* @throws org.apache.maven.plugin.MojoExecutionException if an error occurred while building the webapp
*/
public void execute() throws MojoExecutionException, MojoFailureException {
File warFile = getTargetWarFile();
try {
performPackaging(warFile);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Error assembling WAR: " + e.getMessage(), e);
} catch (ManifestException e) {
throw new MojoExecutionException("Error assembling WAR", e);
} catch (IOException e) {
throw new MojoExecutionException("Error assembling WAR", e);
} catch (ArchiverException e) {
throw new MojoExecutionException("Error assembling WAR: " + e.getMessage(), e);
}
}
Example 24
Project: axis2-java-master File: MarMojo.java View source code |
/** * Generates the mar. * * @param marFile * the target mar file * @throws IOException * @throws ArchiverException * @throws ManifestException * @throws DependencyResolutionRequiredException */ private void performPackaging(File marFile) throws IOException, ArchiverException, ManifestException, DependencyResolutionRequiredException, MojoExecutionException { buildExplodedMar(); // generate mar file getLog().info("Generating mar " + marFile.getAbsolutePath()); MavenArchiver archiver = new MavenArchiver(); archiver.setArchiver(jarArchiver); archiver.setOutputFile(marFile); jarArchiver.addDirectory(marDirectory); // create archive archiver.createArchive(session, project, archive); if (classifier != null) { projectHelper.attachArtifact(project, "mar", classifier, marFile); } else { Artifact artifact = project.getArtifact(); if (primaryArtifact) { artifact.setFile(marFile); } else if (artifact.getFile() == null || artifact.getFile().isDirectory()) { artifact.setFile(marFile); } else { projectHelper.attachArtifact(project, "mar", marFile); } } }
Example 25
Project: camel-master File: SpringBootAutoConfigurationMojo.java View source code |
protected ClassLoader getProjectClassLoader() throws MojoFailureException {
final List classpathElements;
try {
classpathElements = project.getTestClasspathElements();
} catch (org.apache.maven.artifact.DependencyResolutionRequiredException e) {
throw new MojoFailureException(e.getMessage(), e);
}
final URL[] urls = new URL[classpathElements.size()];
int i = 0;
for (Iterator it = classpathElements.iterator(); it.hasNext(); i++) {
try {
urls[i] = new File((String) it.next()).toURI().toURL();
} catch (MalformedURLException e) {
throw new MojoFailureException(e.getMessage(), e);
}
}
final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
return new URLClassLoader(urls, tccl != null ? tccl : getClass().getClassLoader());
}
Example 26
Project: cdk-master File: AbstractDatasetMojo.java View source code |
void configureSchema(DatasetDescriptor.Builder descriptorBuilder, String avroSchemaFile, String avroSchemaReflectClass) throws MojoExecutionException {
if (avroSchemaFile != null) {
File avroSchema = new File(avroSchemaFile);
try {
if (avroSchema.exists()) {
descriptorBuilder.schema(avroSchema);
} else {
descriptorBuilder.schema(Resources.getResource(avroSchemaFile).openStream());
}
} catch (IOException e) {
throw new MojoExecutionException("Problem while reading file " + avroSchemaFile, e);
}
} else if (avroSchemaReflectClass != null) {
try {
List<URL> classpath = new ArrayList<URL>();
for (Object element : mavenProject.getCompileClasspathElements()) {
String path = (String) element;
classpath.add(new File(path).toURI().toURL());
}
// use Maven's classloader, not the system one
ClassLoader parentClassLoader = getClass().getClassLoader();
ClassLoader classLoader = new URLClassLoader(classpath.toArray(new URL[classpath.size()]), parentClassLoader);
descriptorBuilder.schema(Class.forName(avroSchemaReflectClass, true, classLoader));
} catch (ClassNotFoundException e) {
throw new MojoExecutionException("Problem finding class " + avroSchemaReflectClass, e);
} catch (MalformedURLException e) {
throw new MojoExecutionException("Problem finding class " + avroSchemaReflectClass, e);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Problem finding class " + avroSchemaReflectClass, e);
}
}
}
Example 27
Project: com.cedarsoft.rest-master File: GeneratorMojoTest.java View source code |
@Nonnull
private GeneratorMojo createMojo(@Nonnull String name) throws Exception {
File testPom = new File(getBasedir(), "src/test/resources/unit/" + name + "/plugin-config.xml");
assertTrue(testPom.getAbsolutePath() + " not found", testPom.exists());
GeneratorMojo mojo = (GeneratorMojo) lookupMojo("generate", testPom);
assertNotNull(mojo);
MavenProjectStub project = new MavenProjectStub() {
@Override
public List getCompileClasspathElements() throws DependencyResolutionRequiredException {
File target = new File(getBasedir(), "target/test-classes");
return Lists.newArrayList(target.getAbsolutePath());
}
};
mojo.mavenProject = project;
cleanUp(mojo);
return mojo;
}
Example 28
Project: com.idega.maven.webapp-master File: WarMojo.java View source code |
/**
* Executes the WarMojo on the current project.
*
* @throws MojoExecutionException if an error occured while building the webapp
*/
public void execute() throws MojoExecutionException {
File warFile = getWarFile(new File(outputDirectory), warName, classifier);
try {
performPackaging(warFile);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Error assembling WAR: " + e.getMessage(), e);
} catch (ManifestException e) {
throw new MojoExecutionException("Error assembling WAR", e);
} catch (IOException e) {
throw new MojoExecutionException("Error assembling WAR", e);
} catch (ArchiverException e) {
throw new MojoExecutionException("Error assembling WAR: " + e.getMessage(), e);
}
}
Example 29
Project: cuke4duke-master File: AbstractJRubyMojo.java View source code |
protected Project getProject() throws MojoExecutionException {
Project project = new Project();
project.setBaseDir(mavenProject.getBasedir());
project.setProperty("jruby.home", jrubyHome().getAbsolutePath());
project.addBuildListener(new LogAdapter());
Path jrubyClasspath = new Path(project);
project.addReference("jruby.classpath", jrubyClasspath);
try {
append(jrubyClasspath, testClasspathElements);
append(jrubyClasspath, compileClasspathElements);
append(jrubyClasspath, pluginArtifacts);
return project;
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("error resolving dependencies", e);
}
}
Example 30
Project: k3po-master File: StartMojo.java View source code |
private ClassLoader createScriptLoader() throws DependencyResolutionRequiredException, MalformedURLException {
List<URL> scriptPath = new LinkedList<>();
if (scriptDir != null) {
scriptPath.add(scriptDir.getAbsoluteFile().toURI().toURL());
}
for (Object scriptPathEntry : project.getTestClasspathElements()) {
URI scriptPathURI = new File(scriptPathEntry.toString()).getAbsoluteFile().toURI();
scriptPath.add(scriptPathURI.toURL());
}
ClassLoader parent = getClass().getClassLoader();
return new URLClassLoader(scriptPath.toArray(new URL[scriptPath.size()]), parent);
}
Example 31
Project: Kite-master File: AbstractDatasetMojo.java View source code |
void configureSchema(DatasetDescriptor.Builder descriptorBuilder, String avroSchemaFile, String avroSchemaReflectClass) throws MojoExecutionException {
if (avroSchemaFile != null) {
File avroSchema = new File(avroSchemaFile);
try {
if (avroSchema.exists()) {
descriptorBuilder.schema(avroSchema);
} else {
descriptorBuilder.schema(Resources.getResource(avroSchemaFile).openStream());
}
} catch (IOException e) {
throw new MojoExecutionException("Problem while reading file " + avroSchemaFile, e);
}
} else if (avroSchemaReflectClass != null) {
try {
List<URL> classpath = new ArrayList<URL>();
for (Object element : mavenProject.getCompileClasspathElements()) {
String path = (String) element;
classpath.add(new File(path).toURI().toURL());
}
// use Maven's classloader, not the system one
ClassLoader parentClassLoader = getClass().getClassLoader();
ClassLoader classLoader = new URLClassLoader(classpath.toArray(new URL[classpath.size()]), parentClassLoader);
descriptorBuilder.schema(Class.forName(avroSchemaReflectClass, true, classLoader));
} catch (ClassNotFoundException e) {
throw new MojoExecutionException("Problem finding class " + avroSchemaReflectClass, e);
} catch (MalformedURLException e) {
throw new MojoExecutionException("Problem finding class " + avroSchemaReflectClass, e);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Problem finding class " + avroSchemaReflectClass, e);
}
}
}
Example 32
Project: maven-anno-mojo-master File: AnnoMojoDescriptorExtractor.java View source code |
@SuppressWarnings({ "unchecked" })
public List<MojoDescriptor> execute(MavenProject project, PluginDescriptor pluginDescriptor) throws InvalidPluginDescriptorException {
List<String> sourceRoots = project.getCompileSourceRoots();
Set<String> sourcePathElements = new HashSet<String>();
String srcRoot = null;
try {
for (String sourceRoot : sourceRoots) {
srcRoot = sourceRoot;
List<File> files = FileUtils.getFiles(new File(srcRoot), "**/*.java", null, true);
for (File file : files) {
String path = file.getPath();
sourcePathElements.add(path);
}
}
} catch (Exception e) {
throw new InvalidPluginDescriptorException("Failed to get source files from " + srcRoot, e);
}
List<String> argsList = new ArrayList<String>();
argsList.add("-nocompile");
argsList.add("-cp");
StringBuilder cp = new StringBuilder();
//Add the compile classpath
List<String> compileClasspathElements;
try {
compileClasspathElements = project.getCompileClasspathElements();
} catch (DependencyResolutionRequiredException e) {
throw new InvalidPluginDescriptorException("Failed to get compileClasspathElements.", e);
}
for (String ccpe : compileClasspathElements) {
appendToPath(cp, ccpe);
}
//Add the current CL classptah
URL[] urls = ((URLClassLoader) getClass().getClassLoader()).getURLs();
for (URL url : urls) {
String path;
try {
path = url.getPath();
} catch (Exception e) {
throw new InvalidPluginDescriptorException("Failed to get classpath files from " + url, e);
}
appendToPath(cp, path);
}
// Attempts to add dependencies to the classpath so that parameters inherited from abstract mojos in other
// projects will be processed.
Set s = project.getDependencyArtifacts();
if (s != null) {
for (Object untypedArtifact : project.getDependencyArtifacts()) {
if (untypedArtifact instanceof Artifact) {
Artifact artifact = (Artifact) untypedArtifact;
File artifactFile = artifact.getFile();
if (artifactFile != null) {
appendToPath(cp, artifactFile.getAbsolutePath());
}
}
}
}
String classpath = cp.toString();
debug("cl=" + classpath);
argsList.add(classpath);
argsList.addAll(sourcePathElements);
String[] args = argsList.toArray(new String[argsList.size()]);
List<MojoDescriptor> descriptors = new ArrayList<MojoDescriptor>();
MojoDescriptorTls.setDescriptors(descriptors);
try {
Main.process(new MojoApf(pluginDescriptor), new PrintWriter(System.out), args);
} catch (Throwable t) {
throw new InvalidPluginDescriptorException("Failed to extract plugin descriptor.", t);
}
return MojoDescriptorTls.getDescriptors();
}
Example 33
Project: Maven-Archetype-master File: JarMojo.java View source code |
public void execute() throws MojoExecutionException, MojoFailureException {
try {
getLog().info("Building archetype jar: " + new File(outputDirectory, finalName));
File jarFile = manager.archiveArchetype(archetypeDirectory, outputDirectory, finalName);
checkArchetypeFile(jarFile);
project.getArtifact().setFile(jarFile);
} catch (DependencyResolutionRequiredException ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
} catch (IOException ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
}
}
Example 34
Project: mdl4ui-master File: AbstractDepsMojo.java View source code |
final ClassLoader getClassLoader() throws MojoFailureException {
final List<?> classpathFiles;
try {
classpathFiles = project.getCompileClasspathElements();
} catch (DependencyResolutionRequiredException e) {
throw new MojoFailureException(e.getMessage());
}
final URL[] urls = new URL[classpathFiles.size() + 1];
try {
for (int i = 0; i < classpathFiles.size(); ++i) {
getLog().debug((String) classpathFiles.get(i));
urls[i] = new File((String) classpathFiles.get(i)).toURI().toURL();
}
urls[classpathFiles.size()] = new File(buildDirectory + "/classes").toURI().toURL();
} catch (MalformedURLException e) {
throw new MojoFailureException(e.getMessage());
}
return new URLClassLoader(urls, Thread.currentThread().getContextClassLoader());
}
Example 35
Project: microjiac-public-master File: ReducedArchiver.java View source code |
/**
* Return a pre-configured manifest
*
* @todo Add user attributes list and user groups list
*/
public Manifest getManifest(MavenProject project, ManifestConfiguration config) throws ManifestException, DependencyResolutionRequiredException {
// Added basic entries
Manifest m = new Manifest();
Manifest.Attribute buildAttr = new Manifest.Attribute("Built-By", System.getProperty("user.name"));
m.addConfiguredAttribute(buildAttr);
Manifest.Attribute createdAttr = new Manifest.Attribute("Created-By", "Apache Maven");
m.addConfiguredAttribute(createdAttr);
if (config.getPackageName() != null) {
Manifest.Attribute packageAttr = new Manifest.Attribute("Package", config.getPackageName());
m.addConfiguredAttribute(packageAttr);
}
Manifest.Attribute buildJdkAttr = new Manifest.Attribute("Build-Jdk", System.getProperty("java.version"));
m.addConfiguredAttribute(buildJdkAttr);
if (config.isAddClasspath()) {
StringBuffer classpath = new StringBuffer();
List artifacts = project.getRuntimeClasspathElements();
String classpathPrefix = config.getClasspathPrefix();
for (Iterator iter = artifacts.iterator(); iter.hasNext(); ) {
File f = new File((String) iter.next());
if (f.isFile()) {
if (classpath.length() > 0) {
classpath.append(" ");
}
classpath.append(classpathPrefix);
classpath.append(f.getName());
}
}
if (classpath.length() > 0) {
Manifest.Attribute classpathAttr = new Manifest.Attribute("Class-Path", classpath.toString());
m.addConfiguredAttribute(classpathAttr);
}
}
String mainClass = config.getMainClass();
if (mainClass != null && !"".equals(mainClass)) {
Manifest.Attribute mainClassAttr = new Manifest.Attribute("Main-Class", mainClass);
m.addConfiguredAttribute(mainClassAttr);
}
return m;
}
Example 36
Project: novelang-master File: BatchProducerMojo.java View source code |
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
ConcreteLoggerFactory.setMojoLog(getLog());
LoggerFactory.configurationComplete();
final List<String> classpathElements;
try {
classpathElements = project.getRuntimeClasspathElements();
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Something got wrong", e);
}
/*
for( final String classpathElement : classpathElements ) {
log.info( "%s - Classpath element: %s", getClass().getSimpleName(), classpathElement ) ;
}
*/
final Version version = getVersion();
final String[] documentNames = documentsToRender.toArray(new String[documentsToRender.size()]);
DocumentGeneratorDriver.Configuration configuration = Husk.create(DocumentGeneratorDriver.Configuration.class).withJavaClasses(new JavaClasses.ClasspathAndMain(EngineDriver.NOVELANG_BOOTSTRAP_MAIN_CLASS_NAME, classpathElements)).withContentRootDirectory(contentRootDirectory).withOutputDirectory(outputDirectory).withWorkingDirectory(workingDirectory).withProgramArguments(documentNames).withVersion(version);
if (logDirectory != null) {
configuration = configuration.withLogDirectory(logDirectory);
}
if (jvmHeapSizeMegabytes != null) {
configuration = configuration.withJvmHeapSizeMegabytes(jvmHeapSizeMegabytes);
}
final DocumentGeneratorDriver driver = new DocumentGeneratorDriver(configuration);
try {
driver.start(1L, TimeUnit.MINUTES);
final int exitCode = driver.shutdown(false);
if (exitCode != 0) {
throw new Exception("Process ended with exit code " + exitCode);
}
} catch (Exception e) {
throw new MojoExecutionException("Driver execution failed", e);
}
}
Example 37
Project: persistence-jme-master File: PackageMojo.java View source code |
private void unzipDependencies(File outputDirectory) throws IOException, DependencyResolutionRequiredException {
List compileClasspathElements = project.getCompileClasspathElements();
List compileDependecies = project.getCompileDependencies();
for (Iterator iter = compileDependecies.iterator(); iter.hasNext(); ) {
Dependency dependency = (Dependency) iter.next();
if ("COMPILE".equalsIgnoreCase(dependency.getScope())) {
String groupId = dependency.getGroupId().replace('.', File.separatorChar);
String artifactId = dependency.getArtifactId();
String version = dependency.getVersion();
String type = dependency.getType();
String dependencyName = artifactId + '-' + version + '.' + type;
String suffix = groupId + File.separatorChar + artifactId + File.separatorChar + version + File.separatorChar + dependencyName;
for (Iterator iterator = compileClasspathElements.iterator(); iterator.hasNext(); ) {
String path = (String) iterator.next();
if (path.endsWith(suffix)) {
this.getLog().info("Embbeding the " + dependencyName + " dependency in the final package.");
ZipUtils.unzip(new File(path), outputDirectory);
}
}
}
}
}
Example 38
Project: querydsl-master File: CompileMojo.java View source code |
@SuppressWarnings("unchecked")
private String buildCompileClasspath() {
List<String> pathElements = null;
try {
if (testClasspath) {
pathElements = project.getTestClasspathElements();
} else {
pathElements = project.getCompileClasspathElements();
}
} catch (DependencyResolutionRequiredException e) {
getLog().warn("exception calling getCompileClasspathElements", e);
return null;
}
if (pathElements.isEmpty()) {
return null;
}
StringBuilder result = new StringBuilder();
for (int i = 0; i < pathElements.size(); i++) {
if (i > 0) {
result.append(File.pathSeparatorChar);
}
result.append(pathElements.get(i));
}
return result.toString();
}
Example 39
Project: rdfbean-master File: SchemaGenMojo.java View source code |
public void execute() throws MojoExecutionException, MojoFailureException {
try {
URLClassLoader classLoader = getProjectClassLoader();
final Pattern pattern = Pattern.compile(".*" + toRegex(classes) + "\\.class");
ArchiveBrowser.Filter filter = new ArchiveBrowser.Filter() {
public boolean accept(String name) {
return pattern.matcher(name).matches();
}
};
List<Class<?>> entityClasses = getEntityClasses(classLoader, filter);
Collections.sort(entityClasses, fileComparator);
DefaultConfiguration configuration = new DefaultConfiguration();
configuration.addClasses(entityClasses.toArray(new Class[entityClasses.size()]));
if (ontology == null) {
if (namespace.endsWith("#") || namespace.endsWith("/")) {
ontology = namespace.substring(0, namespace.length() - 1);
} else {
ontology = namespace;
}
}
if (schemaFile != null) {
if (!schemaFile.getParentFile().exists()) {
if (!schemaFile.getParentFile().mkdirs()) {
getLog().info("Creation of " + schemaFile.getParentFile().getPath() + " failed");
}
}
OutputStream out = new FileOutputStream(schemaFile);
SchemaGen schemaGen = new SchemaGen().setNamespace(prefix, namespace).setOntology(ontology).addExportNamespace(namespace).setConfiguration(configuration);
if (useTurtle) {
schemaGen.export(Format.TURTLE, out);
} else {
schemaGen.export(Format.RDFXML, out);
}
}
if (classListFile != null) {
StringBuilder builder = new StringBuilder();
for (Class<?> clazz : entityClasses) {
if (builder.length() > 0) {
builder.append("\n");
}
builder.append(clazz.getName());
}
// FileUtils.writeStringToFile(classListFile,
// builder.toString(), "UTF-8");
Files.write(builder.toString(), classListFile, Charsets.UTF_8);
}
} catch (IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException(e.getMessage(), e);
} catch (ClassNotFoundException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
Example 40
Project: sakai-maven-plugin-master File: ComponentMojo.java View source code |
/**
* Executes the WarMojo on the current project.
*
* @throws MojoExecutionException if an error occured while building the webapp
*/
public void execute() throws MojoExecutionException, MojoFailureException {
File warFile = getWarFile(new File(outputDirectory), warName, classifier);
try {
performPackaging(warFile);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Error assembling WAR: " + e.getMessage(), e);
} catch (ManifestException e) {
throw new MojoExecutionException("Error assembling WAR", e);
} catch (IOException e) {
throw new MojoExecutionException("Error assembling WAR", e);
} catch (ArchiverException e) {
throw new MojoExecutionException("Error assembling WAR: " + e.getMessage(), e);
}
}
Example 41
Project: assertj-assertions-generator-maven-plugin-master File: AssertJAssertionsGeneratorMojo.java View source code |
@SuppressWarnings("unchecked")
private ClassLoader getProjectClassLoader() throws DependencyResolutionRequiredException, MalformedURLException {
List<String> classpathElements = new ArrayList<String>(project.getCompileClasspathElements());
classpathElements.addAll(project.getTestClasspathElements());
List<URL> classpathElementUrls = new ArrayList<URL>(classpathElements.size());
for (int i = 0; i < classpathElements.size(); i++) {
classpathElementUrls.add(new File(classpathElements.get(i)).toURI().toURL());
}
return new URLClassLoader(classpathElementUrls.toArray(new URL[0]), Thread.currentThread().getContextClassLoader());
}
Example 42
Project: byteman-master File: RuleCheckMojo.java View source code |
public void execute() throws MojoExecutionException {
List<File> scripts;
if (skip) {
getLog().info("Checking byteman scripts are skipped");
return;
}
try {
if (verbose) {
getLog().info("find byteman script in " + scriptDir);
}
StringBuffer includebuf = new StringBuffer();
for (int i = 0; i < includes.length; i++) {
includebuf.append(includes[i]);
if (i != includes.length - 1)
includebuf.append(",");
}
StringBuffer excludebuf = new StringBuffer();
for (int i = 0; i < excludes.length; i++) {
excludebuf.append(excludes[i]);
if (i != excludes.length - 1)
excludebuf.append(",");
}
scripts = FileUtils.getFiles(scriptDir, includebuf.toString(), excludebuf.toString());
} catch (Exception e) {
getLog().debug("Can not find " + scriptDir);
return;
}
if (scripts.size() == 0) {
getLog().info("No byteman script in " + scriptDir);
return;
}
List<String> classpathElements;
try {
classpathElements = project.getCompileClasspathElements();
classpathElements.addAll(project.getRuntimeClasspathElements());
classpathElements.add(project.getBuild().getOutputDirectory());
classpathElements.add(project.getBuild().getTestOutputDirectory());
if (additionalClassPath != null) {
String[] cps = (additionalClassPath.split(";"));
for (int i = 0; i < cps.length; i++) {
File file = new File(cps[i]);
String path = null;
if (file.isAbsolute()) {
path = cps[i];
} else {
path = project.getBasedir() + File.separator + cps[i];
}
classpathElements.add(path);
if (verbose) {
getLog().info("add addional classpath " + path);
}
}
}
ClassRealm realm = descriptor.getClassRealm();
for (String element : classpathElements) {
File elementFile = new File(element);
if (verbose) {
getLog().info(element);
} else {
getLog().debug(element);
}
realm.addURL(elementFile.toURI().toURL());
}
} catch (DependencyResolutionRequiredException e) {
getLog().warn(e);
} catch (MalformedURLException e) {
getLog().warn(e);
}
RuleCheck checker = new RuleCheck();
for (File script : scripts) {
if (verbose) {
getLog().info("add script " + script);
} else {
getLog().debug("add script " + script);
}
checker.addRuleFile(script.getAbsolutePath());
}
for (int i = 0; i < packages.length; i++) {
checker.addPackage(packages[i]);
if (verbose) {
getLog().info("add package " + packages[i]);
} else {
getLog().debug("add package " + packages[i]);
}
}
getLog().info("Checking " + scripts.size() + " byteman scripts in " + scriptDir);
checker.checkRules();
RuleCheckResult result = checker.getResult();
if (result.hasWarning()) {
List<String> warns = result.getWarningMessages();
warns.addAll(result.getTypeWarningMessages());
for (String warn : warns) {
getLog().warn(warn);
}
int totalWarnCount = warns.size();
if (failOnWarning && expectWarnings != totalWarnCount) {
throw new MojoExecutionException("check byteman script rules failed with " + totalWarnCount + " warnings. You may config failOnWarning with false or expectWarnings with " + totalWarnCount);
}
}
if (result.hasError()) {
int totalErrorCount = result.getErrorCount() + result.getParseErrorCount() + result.getTypeErrorCount();
getLog().error("Checking byteman script rules failed with " + totalErrorCount + " errors");
List<String> errors = result.getErrorMessages();
errors.addAll(result.getParseErrorMessages());
errors.addAll(result.getTypeErrorMessages());
for (String error : errors) {
getLog().error(error);
}
if (failOnError) {
throw new MojoExecutionException("check byteman script rules failed with " + totalErrorCount + " errors");
}
}
}
Example 43
Project: cq-component-maven-plugin-master File: ComponentMojo.java View source code |
private Set<String> getExcludedClasses() throws DependencyResolutionRequiredException, MalformedURLException {
getLog().debug("Constructing set of excluded Class names");
List<String> excludedDependencyPaths = getExcludedDependencyPaths();
if (excludedDependencyPaths != null) {
ClassLoader exclusionClassLoader = ComponentMojoUtil.getClassLoader(excludedDependencyPaths, this.getClass().getClassLoader());
Reflections reflections = ComponentMojoUtil.getReflections(exclusionClassLoader);
Set<String> excludedClassNames = reflections.getStore().getTypesAnnotatedWith(Component.class.getName());
return excludedClassNames;
}
return null;
}
Example 44
Project: droolsjbpm-integration-master File: BuildMojo.java View source code |
public void execute() throws MojoExecutionException, MojoFailureException {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
List<InternalKieModule> kmoduleDeps = new ArrayList<InternalKieModule>();
try {
Set<URL> urls = new HashSet<URL>();
for (String element : project.getCompileClasspathElements()) {
urls.add(new File(element).toURI().toURL());
}
project.setArtifactFilter(new CumulativeScopeArtifactFilter(Arrays.asList("compile", "runtime")));
for (Artifact artifact : project.getArtifacts()) {
File file = artifact.getFile();
if (file != null) {
urls.add(file.toURI().toURL());
KieModuleModel depModel = getDependencyKieModel(file);
if (depModel != null) {
ReleaseId releaseId = new ReleaseIdImpl(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
kmoduleDeps.add(new ZipKieModule(releaseId, depModel, file));
}
}
}
urls.add(outputDirectory.toURI().toURL());
ClassLoader projectClassLoader = URLClassLoader.newInstance(urls.toArray(new URL[0]), Thread.currentThread().getContextClassLoader());
Thread.currentThread().setContextClassLoader(projectClassLoader);
BPMN2ProcessFactory.loadProvider(projectClassLoader);
DecisionTableFactory.loadProvider(projectClassLoader);
ProcessBuilderFactory.loadProvider(projectClassLoader);
PMMLCompilerFactory.loadProvider(projectClassLoader);
GuidedDecisionTableFactory.loadProvider(projectClassLoader);
GuidedRuleTemplateFactory.loadProvider(projectClassLoader);
GuidedScoreCardFactory.loadProvider(projectClassLoader);
} catch (DependencyResolutionRequiredException e) {
throw new RuntimeException(e);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
KieServices ks = KieServices.Factory.get();
try {
setSystemProperties(properties);
KieRepository kr = ks.getRepository();
InternalKieModule kModule = (InternalKieModule) kr.addKieModule(ks.getResources().newFileSystemResource(sourceFolder));
for (InternalKieModule kmoduleDep : kmoduleDeps) {
kModule.addKieDependency(kmoduleDep);
}
KieContainerImpl kContainer = (KieContainerImpl) ks.newKieContainer(kModule.getReleaseId());
KieProject kieProject = kContainer.getKieProject();
ResultsImpl messages = kieProject.verify();
List<Message> errors = messages.filterMessages(Message.Level.ERROR);
if (!errors.isEmpty()) {
for (Message error : errors) {
getLog().error(error.toString());
}
throw new MojoFailureException("Build failed!");
} else {
new KieMetaInfoBuilder(new DiskResourceStore(outputDirectory), kModule).writeKieModuleMetaInfo();
}
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
getLog().info("KieModule successfully built!");
}
Example 45
Project: eguan-master File: Javah.java View source code |
protected final List getClassPaths() throws MojoExecutionException {
if (classPaths.isEmpty()) {
try {
classPaths.addAll(mojo.getMavenProject().getCompileClasspathElements());
// Add jar dependencies from the local repository
ArtifactRepository repository = mojo.getLocalRepository();
for (Iterator i = mojo.getMavenProject().getDependencyArtifacts().iterator(); i.hasNext(); ) {
Artifact a = (Artifact) i.next();
if (Artifact.SCOPE_COMPILE.equals(a.getScope()) && a.getArtifactHandler().isAddedToClasspath())
classPaths.add(new File(repository.getBasedir(), repository.pathOf(a)).getAbsolutePath());
}
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("JAVAH, cannot get classpath", e);
}
}
return classPaths;
}
Example 46
Project: freehep-ncolor-pdf-master File: Javah.java View source code |
protected List getClassPaths() throws MojoExecutionException {
if (classPaths.isEmpty()) {
try {
classPaths.addAll(mojo.getMavenProject().getCompileClasspathElements());
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("JAVAH, cannot get classpath", e);
}
}
return classPaths;
}
Example 47
Project: handlebars.java-master File: PrecompilePluginTest.java View source code |
@Test(expected = MojoFailureException.class)
public void mustFailOnUnExpectedException() throws Exception {
MavenProject project = createMock(MavenProject.class);
Artifact artifact = createMock(Artifact.class);
expect(project.getRuntimeClasspathElements()).andThrow(new DependencyResolutionRequiredException(artifact));
replay(project, artifact);
PrecompilePlugin plugin = new PrecompilePlugin();
plugin.setPrefix("src/test/resources/no templates");
plugin.setSuffix(".html");
plugin.setOutput("target/no-helpers.js");
plugin.setProject(project);
plugin.setHandlebarsJsFile("/handlebars-v4.0.4.js");
plugin.execute();
}
Example 48
Project: infinispan-master File: DefaultsExtractorMojo.java View source code |
public void execute() throws MojoExecutionException {
try {
this.classPaths = mavenProject.getCompileClasspathElements();
URL[] classLoaderUrls = classPaths.stream().map( strPath -> FileSystems.getDefault().getPath(strPath)).map(this::pathToUrl).toArray(URL[]::new);
this.classLoader = new URLClassLoader(classLoaderUrls, Thread.currentThread().getContextClassLoader());
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Exception encountered during class extraction", e);
}
Set<Class> configClasses = new HashSet<>();
getClassesFromClasspath(configClasses);
jars.forEach( jar -> getClassesFromJar(jar, configClasses));
Map<String, String> defaults = extractDefaults(configClasses);
writeDefaultsToFile(defaults);
if (filterXsd)
filterXsdSchemas();
}
Example 49
Project: jangaroo-tools-master File: JooTestMojoBase.java View source code |
protected List<File> findJars() throws DependencyResolutionRequiredException {
List<File> jars = new ArrayList<File>();
for (Object jarUrl : project.getTestClasspathElements()) {
File file = new File((String) jarUrl);
if (file.isFile()) {
// should be a jar--don't add folders!
jars.add(file);
getLog().info("Test classpath: " + jarUrl);
} else {
getLog().info("Ignoring test classpath: " + jarUrl);
}
}
return jars;
}
Example 50
Project: javadrop-master File: JavadropMojo.java View source code |
/*
* (non-Javadoc)
*
* @see org.apache.maven.plugin.AbstractMojo#execute()
*/
public void execute() throws MojoExecutionException {
getLog().info("Javadrop Mojo processing started...");
try {
if ((mavenProject != null) && (mavenProject.getCompileClasspathElements() != null)) {
getLog().info("Class augmented with project.");
for (int index = 0; index < mavenProject.getCompileClasspathElements().size(); index++) {
String path = (String) mavenProject.getCompileClasspathElements().get(index);
URL cpUrl = new File(path).toURL();
addURLToSystemClassLoader(cpUrl);
}
}
initStrategies();
} catch (MalformedURLException e) {
getLog().warn("Can't add compile classpath elements to mojo!", e);
} catch (DependencyResolutionRequiredException e) {
getLog().warn("Can't add compile classpath elements to mojo!", e);
} catch (IntrospectionException e) {
getLog().warn("Can't add compile classpath elements to mojo!", e);
} catch (ClassNotFoundException e) {
getLog().warn(e);
} catch (InstantiationException e) {
getLog().warn(e);
} catch (IllegalAccessException e) {
getLog().warn(e);
}
// Process runner scripts in the context of a packager.
TemplateProcessor processor = new VelocityTemplateProcessorImpl(getLog());
for (PackagerStrategy packager : packagerStrategies) {
for (RunnerStrategy runner : runnerStrategies) {
// Convert scripts
packager.processTemplates(runner, processor, workingDirectory);
// Do mappings, renames, whatever in the runner.
packager.postProcessArtifacts(runner, workingDirectory);
}
packager.createPackage(packageDirectory, workingDirectory, filteredRunnerStrats(packager, runnerStrategies), getLog());
// packager.createPackage(packageDirectory, workingDirectory,
// runnerStrategies, getLog());
}
getLog().info("Javadrop complete.");
}
Example 51
Project: jersey-1.x-old-master File: AbstractMojoProjectClasspathSupport.java View source code |
/** * Create a list of classpath elements including declared build dependencies, the build * output directory and additionally configured dependencies. * @param mavenProject * @param additionalDependencies * @return a list of classpath elements * @throws DependencyResolutionRequiredException * @throws ArtifactResolutionException * @throws ArtifactNotFoundException * @author Martin Grotzke */ protected List<String> getClasspathElements(final MavenProject mavenProject, final List<com.sun.jersey.wadl.Dependency> additionalDependencies) throws DependencyResolutionRequiredException, ArtifactResolutionException, ArtifactNotFoundException { final List<String> paths = new ArrayList<String>(); /* Add maven compile classpath elements */ @SuppressWarnings("unchecked") final List<String> compileClasspathElements = mavenProject.getCompileClasspathElements(); paths.addAll(compileClasspathElements); /* Add build dependencies as classpath elements */ @SuppressWarnings("unchecked") final Collection<Dependency> dependencies = mavenProject.getDependencies(); if (dependencies != null) { for (Dependency dependency : dependencies) { if (dependency.getSystemPath() != null) { getLog().debug("Adding dependency with systemPath " + dependency.getSystemPath()); paths.add(dependency.getSystemPath()); } else { final Artifact artifact = artifactFactory.createArtifactWithClassifier(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getType(), dependency.getClassifier()); resolver.resolve(artifact, remoteRepositories, localRepository); getLog().debug("Adding artifact " + artifact.getFile().getPath()); paths.add(artifact.getFile().getPath()); } } } /* Add additional dependencies */ if (additionalDependencies != null) { for (com.sun.jersey.wadl.Dependency dependency : additionalDependencies) { if (dependency.getSystemPath() != null) { getLog().debug("Adding additional dependency with systemPath " + dependency.getSystemPath()); paths.add(dependency.getSystemPath()); } else { final Artifact artifact = artifactFactory.createArtifactWithClassifier(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), "jar", null); resolver.resolve(artifact, remoteRepositories, localRepository); getLog().debug("Adding additional artifact " + artifact.getFile().getPath()); paths.add(artifact.getFile().getPath()); } } } return paths; }
Example 52
Project: jersey-old-master File: AbstractMojoProjectClasspathSupport.java View source code |
/** * Create a list of classpath elements including declared build dependencies, the build * output directory and additionally configured dependencies. * @param mavenProject * @param additionalDependencies * @return a list of classpath elements * @throws DependencyResolutionRequiredException * @throws ArtifactResolutionException * @throws ArtifactNotFoundException * @author Martin Grotzke */ protected List<String> getClasspathElements(final MavenProject mavenProject, final List<com.sun.jersey.wadl.Dependency> additionalDependencies) throws DependencyResolutionRequiredException, ArtifactResolutionException, ArtifactNotFoundException { final List<String> paths = new ArrayList<String>(); /* Add maven compile classpath elements */ @SuppressWarnings("unchecked") final List<String> compileClasspathElements = mavenProject.getCompileClasspathElements(); paths.addAll(compileClasspathElements); /* Add build dependencies as classpath elements */ @SuppressWarnings("unchecked") final Collection<Dependency> dependencies = mavenProject.getDependencies(); if (dependencies != null) { for (Dependency dependency : dependencies) { if (dependency.getSystemPath() != null) { getLog().debug("Adding dependency with systemPath " + dependency.getSystemPath()); paths.add(dependency.getSystemPath()); } else { final Artifact artifact = artifactFactory.createArtifactWithClassifier(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), dependency.getType(), dependency.getClassifier()); resolver.resolve(artifact, remoteRepositories, localRepository); getLog().debug("Adding artifact " + artifact.getFile().getPath()); paths.add(artifact.getFile().getPath()); } } } /* Add additional dependencies */ if (additionalDependencies != null) { for (com.sun.jersey.wadl.Dependency dependency : additionalDependencies) { if (dependency.getSystemPath() != null) { getLog().debug("Adding additional dependency with systemPath " + dependency.getSystemPath()); paths.add(dependency.getSystemPath()); } else { final Artifact artifact = artifactFactory.createArtifactWithClassifier(dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion(), "jar", null); resolver.resolve(artifact, remoteRepositories, localRepository); getLog().debug("Adding additional artifact " + artifact.getFile().getPath()); paths.add(artifact.getFile().getPath()); } } } return paths; }
Example 53
Project: jewelcli-master File: JewelCliReportMojo.java View source code |
private ClassLoader getClassLoader() throws MavenReportException {
final List<URL> urls = new ArrayList<URL>();
try {
for (final Object object : project.getCompileClasspathElements()) {
final String path = (String) object;
final URL url = new File(path).toURL();
getLog().debug("adding classpath element " + url);
urls.add(url);
}
} catch (final MalformedURLException e) {
throw new MavenReportException("Unable to load command line interface class", e);
} catch (final DependencyResolutionRequiredException e) {
throw new MavenReportException("Unable to resolve dependencies of project", e);
}
return new URLClassLoader(urls.toArray(new URL[] {}), getClass().getClassLoader());
}
Example 54
Project: jgitflow-master File: AbstractJGitFlowMojo.java View source code |
protected String getClasspath() throws MojoExecutionException {
Set<String> allPaths = new HashSet<String>();
StringBuffer finalPath = new StringBuffer(File.pathSeparator + project.getBuild().getOutputDirectory());
try {
allPaths.addAll(project.getCompileClasspathElements());
allPaths.addAll(project.getRuntimeClasspathElements());
allPaths.addAll(project.getSystemClasspathElements());
URL[] pluginUrls = ((URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs();
for (URL pluginUrl : pluginUrls) {
allPaths.add(new File(pluginUrl.getFile()).getPath());
}
for (String path : allPaths) {
finalPath.append(File.pathSeparator);
finalPath.append(path);
}
return finalPath.toString();
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Dependencies must be resolved", e);
}
}
Example 55
Project: jruby-maven-plugins-master File: AbstractGemMojo.java View source code |
@Override
protected ScriptFactory newScriptFactory(Artifact artifact) throws MojoExecutionException {
try {
final GemScriptFactory factory = artifact == null ? new GemScriptFactory(this.logger, this.classRealm, null, getProjectClasspath(), this.jrubyFork, this.gemsConfig) : (JRUBY_CORE.equals(artifact.getArtifactId()) ? new GemScriptFactory(this.logger, this.classRealm, artifact.getFile(), resolveJRubyStdlibArtifact(artifact).getFile(), getProjectClasspath(), this.jrubyFork, this.gemsConfig) : new GemScriptFactory(this.logger, this.classRealm, artifact.getFile(), getProjectClasspath(), this.jrubyFork, this.gemsConfig));
if (supportNative) {
factory.addJvmArgs("-Djruby.home=" + setupNativeSupport().getAbsolutePath());
}
if (rubySourceDirectory != null && rubySourceDirectory.exists()) {
if (jrubyVerbose) {
getLog().info("add to ruby loadpath: " + rubySourceDirectory.getAbsolutePath());
}
// add it to the load path for all scripts using that factory
factory.addSwitch("-I", rubySourceDirectory.getAbsolutePath());
}
if (libDirectory != null && libDirectory.exists()) {
if (jrubyVerbose) {
getLog().info("add to ruby loadpath: " + libDirectory.getAbsolutePath());
}
// add it to the load path for all scripts using that factory
factory.addSwitch("-I", libDirectory.getAbsolutePath());
}
return factory;
} catch (final DependencyResolutionRequiredException e) {
throw new MojoExecutionException("could not resolve jruby", e);
} catch (final ScriptException e) {
throw new MojoExecutionException("could not initialize script factory", e);
} catch (final IOException e) {
throw new MojoExecutionException("could not initialize script factory", e);
}
}
Example 56
Project: jspresso-ce-master File: SjsMojo.java View source code |
private void runSjsCompilation() throws IOException, ResourceException, ScriptException, DependencyResolutionRequiredException {
Properties projectProperties = project.getProperties();
projectProperties.put("srcDir", srcDir.getAbsolutePath());
projectProperties.put("outputDir", outputDir.getAbsolutePath());
projectProperties.put("modelOutputFileName", modelOutputFileName);
projectProperties.put("viewOutputFileName", viewOutputFileName);
projectProperties.put("backOutputFileName", backOutputFileName);
projectProperties.put("frontOutputFileName", frontOutputFileName);
List<URL> classpath;
classpath = new ArrayList<>();
classpath.add(srcDir.toURI().toURL());
List<String> compileClasspathElements = project.getCompileClasspathElements();
for (String element : compileClasspathElements) {
if (!element.equals(project.getBuild().getOutputDirectory())) {
File elementFile = new File(element);
getLog().debug("Adding element to plugin classpath " + elementFile.getPath());
URL url = elementFile.toURI().toURL();
classpath.add(url);
}
}
GroovyScriptEngine gse = new GroovyScriptEngine(classpath.toArray(new URL[classpath.size()]));
Binding binding = new Binding();
binding.setVariable("project", project);
binding.setVariable("fail", new FailClosure());
String refinedApplicationFileName = applicationFileName;
if (!new File(srcDir + File.separator + applicationFileName).exists()) {
if (applicationFileName.contains(SJSEXT)) {
refinedApplicationFileName = applicationFileName.replaceAll(SJSEXT, GROOVY_EXT);
} else if (applicationFileName.contains(GROOVY_EXT)) {
refinedApplicationFileName = applicationFileName.replaceAll(GROOVY_EXT, SJSEXT);
}
}
gse.run(refinedApplicationFileName, binding);
}
Example 57
Project: karaf-master File: GenerateHelpMojo.java View source code |
private ClassFinder createFinder(String classloaderType) throws DependencyResolutionRequiredException, MalformedURLException, Exception, MojoFailureException {
ClassFinder finder;
if ("project".equals(classloaderType)) {
List<URL> urls = new ArrayList<URL>();
for (Object object : project.getCompileClasspathElements()) {
String path = (String) object;
urls.add(new File(path).toURI().toURL());
}
ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());
finder = new ClassFinder(loader, urls);
} else if ("plugin".equals(classLoader)) {
finder = new ClassFinder(getClass().getClassLoader());
} else {
throw new MojoFailureException("classLoader attribute must be 'project' or 'plugin'");
}
return finder;
}
Example 58
Project: kotlin-master File: K2JSCompilerMojo.java View source code |
@Override
protected void configureSpecificCompilerArguments(@NotNull K2JSCompilerArguments arguments) throws MojoExecutionException {
arguments.outputFile = outputFile;
arguments.noStdlib = true;
arguments.metaInfo = metaInfo;
arguments.moduleKind = moduleKind;
arguments.main = main;
List<String> libraries = null;
try {
libraries = getKotlinJavascriptLibraryFiles();
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Unresolved dependencies", e);
}
getLog().debug("libraries: " + libraries);
arguments.libraries = StringUtil.join(libraries, File.pathSeparator);
arguments.sourceMap = sourceMap;
if (outputFile != null) {
ConcurrentMap<String, List<String>> collector = getOutputDirectoriesCollector();
String key = project.getArtifactId();
List<String> paths = collector.computeIfAbsent(key, k -> Collections.synchronizedList(new ArrayList<String>()));
paths.add(new File(outputFile).getParent());
}
}
Example 59
Project: lazydoc-master File: LazyDocMojo.java View source code |
private ClassLoader getClassLoader() throws MojoExecutionException, DependencyResolutionRequiredException {
List<URL> classpathURLs = new ArrayList<URL>();
this.addRelevantPluginDependenciesToClasspath(classpathURLs);
this.addRelevantProjectDependenciesToClasspath(classpathURLs);
for (URL classpath : classpathURLs) {
getLog().debug("Classpath: " + classpath.toString());
}
return new URLClassLoader(classpathURLs.toArray(new URL[classpathURLs.size()]));
}
Example 60
Project: maven-ipcstub-generator-master File: GeneratorModule.java View source code |
private Iterable<Class<? extends IpcCommand>> generateCommandList(Set<String> packages) throws MojoExecutionException {
// create the classpath to use
final List<File> locations = Lists.newArrayList();
try {
for (Object element : project.getRuntimeClasspathElements()) {
log.debug("Adding runtime classpath element: " + element);
locations.add(new File((String) element));
}
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("dependencies not resolved", e);
}
// hack: add the required files to the classloader
boostrapClassloader(Iterables.transform(locations, new Function<File, URL>() {
@Override
public URL apply(File from) {
try {
return from.toURI().toURL();
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
}
}));
final String value = Joiner.on(File.pathSeparator).join(locations);
final Classpath cp = Reflection.classpathOf(value);
final Predicate<Class<?>> predicate = Reflection.isConcreteClass();
return cp.restrictTo(packages).filter(IpcCommand.class, predicate);
}
Example 61
Project: maven-native-plugin-master File: Javah.java View source code |
protected final List getClassPaths() throws MojoExecutionException {
if (this.classPaths.isEmpty()) {
try {
this.classPaths.addAll(this.mojo.getMavenProject().getCompileClasspathElements());
} catch (final DependencyResolutionRequiredException e) {
throw new MojoExecutionException("JAVAH, cannot get classpath", e);
}
}
return this.classPaths;
}
Example 62
Project: mycontainer-master File: MycontainerStartMojo.java View source code |
@SuppressWarnings("unchecked")
private List<File> getProjectsClasspath(Set<MavenProject> projects) throws MojoExecutionException {
try {
getLog().info("Including project classpath. includingTests: " + includeTests);
List<File> ret = new ArrayList<File>(projects.size());
for (MavenProject module : projects) {
List<String> elements = module.getCompileClasspathElements();
for (String element : elements) {
debug("Path: " + element);
ret.add(new File(element));
}
if (includeTests) {
elements = module.getTestClasspathElements();
for (String element : elements) {
debug("Path: " + element);
ret.add(new File(element));
}
}
}
return ret;
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("error", e);
}
}
Example 63
Project: nar-maven-plugin-master File: Javah.java View source code |
protected final List getClassPaths() throws MojoExecutionException {
if (this.classPaths.isEmpty()) {
try {
this.classPaths.addAll(this.mojo.getMavenProject().getCompileClasspathElements());
} catch (final DependencyResolutionRequiredException e) {
throw new MojoExecutionException("JAVAH, cannot get classpath", e);
}
}
return this.classPaths;
}
Example 64
Project: OpenDJ-master File: GenerateManifestClassPathMojo.java View source code |
/** {@inheritDoc} */
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
String classPath = getClasspath();
getLog().info(format("Setting the classpath property: [%s] (debug to see actual value)", classPathProperty));
getLog().debug(String.format("Setting the classpath property %s to:\n%s", classPathProperty, classPath));
project.getProperties().put(classPathProperty, classPath);
} catch (DependencyResolutionRequiredException e) {
getLog().error(String.format("Unable to set the classpath property %s, an error occured", classPathProperty));
throw new MojoFailureException(e.getMessage(), e);
}
}
Example 65
Project: pitest-master File: MojoToReportOptionsConverterTest.java View source code |
public void testParsesExcludedClasspathElements() throws DependencyResolutionRequiredException {
final String sep = File.pathSeparator;
final Set<Artifact> artifacts = new HashSet<Artifact>();
final Artifact dependency = Mockito.mock(Artifact.class);
when(dependency.getGroupId()).thenReturn("group");
when(dependency.getArtifactId()).thenReturn("artifact");
when(dependency.getFile()).thenReturn(new File("group" + sep + "artifact" + sep + "1.0.0" + sep + "group-artifact-1.0.0.jar"));
artifacts.add(dependency);
when(this.project.getArtifacts()).thenReturn(artifacts);
when(this.project.getTestClasspathElements()).thenReturn(Arrays.asList("group" + sep + "artifact" + sep + "1.0.0" + sep + "group-artifact-1.0.0.jar"));
final ReportOptions actual = parseConfig("<classpathDependencyExcludes>" + " <param>group:artifact</param>" + " </classpathDependencyExcludes>");
assertFalse(actual.getClassPathElements().contains("group" + sep + "artifact" + sep + "1.0.0" + sep + "group-artifact-1.0.0.jar"));
}
Example 66
Project: retrolambda-master File: ProcessClassesMojo.java View source code |
private File getClasspathFile() {
try {
String classpath = Joiner.on("\n").join(getClasspathElements());
File file = File.createTempFile("retrolambda", "classpath");
file.deleteOnExit();
Files.write(classpath, file, Charsets.UTF_8);
return file;
} catch (DependencyResolutionRequiredException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Example 67
Project: scala-maven-plugin-master File: ScalaScriptMojo.java View source code |
private void configureClasspath(Set<String> classpath) throws Exception, DependencyResolutionRequiredException {
Set<String> includes = new TreeSet<String>(Arrays.asList(includeScopes.toLowerCase().split(",")));
Set<String> excludes = new TreeSet<String>(Arrays.asList(excludeScopes.toLowerCase().split(",")));
for (Artifact a : project.getArtifacts()) {
if (includes.contains(a.getScope().toLowerCase()) && !excludes.contains(a.getScope())) {
addToClasspath(a, classpath, true);
}
}
if (includes.contains("plugin") && !excludes.contains("plugin")) {
//Plugin plugin = project.getPlugin("scala-maven-plugin");
for (Plugin p : project.getBuildPlugins()) {
if ("scala-maven-plugin".equals(p.getArtifactId())) {
for (Dependency d : p.getDependencies()) {
addToClasspath(factory.createDependencyArtifact(d), classpath, true);
}
}
}
for (Artifact a : project.getPluginArtifacts()) {
if ("scala-maven-plugin".equals(a.getArtifactId())) {
addToClasspath(a, classpath, true);
}
}
}
if (addToClasspath != null) {
classpath.addAll(Arrays.asList(addToClasspath.split(",")));
}
if (removeFromClasspath != null) {
ArrayList<String> toRemove = new ArrayList<String>();
String[] jars = removeFromClasspath.trim().split(",");
for (String string : classpath) {
for (String jar : jars) {
if (string.contains(jar.trim())) {
toRemove.add(string);
}
}
}
classpath.removeAll(toRemove);
}
// String outputDirectory = project.getBuild().getOutputDirectory();
// if(!outputDirectory.endsWith("/")){
// // need it to end with / for URLClassloader
// outputDirectory+="/";
// }
// classpath.add( outputDirectory);
addCompilerToClasspath(classpath);
addLibraryToClasspath(classpath);
//TODO check that every entry from the classpath exists !
boolean ok = true;
for (String s : classpath) {
File f = new File(s);
getLog().debug("classpath entry for running and compiling scripts: " + f);
if (!f.exists()) {
getLog().error("classpath entry for script not found : " + f);
ok = false;
}
}
if (!ok) {
throw new MojoFailureException("some script dependencies not found (see log)");
}
getLog().debug("Using the following classpath for running and compiling scripts: " + classpath);
}
Example 68
Project: substeps-runner-master File: SubstepsRunnerMojo.java View source code |
private ForkedRunner createForkedRunner() throws MojoExecutionException {
try {
return new ForkedRunner(getLog(), this.jmxPort, this.vmArgs, this.project.getTestClasspathElements(), this.stepImplementationArtifacts, this.artifactResolver, this.artifactFactory, this.mavenProjectBuilder, this.localRepository, this.remoteRepositories, this.artifactMetadataSource);
} catch (final DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Unable to resolve dependencies", e);
}
}
Example 69
Project: was-maven-plugin-master File: AntTaskUtils.java View source code |
private static Project generateAntProject(WebSphereModel model, File antBuildFile, MavenProject project, MavenProjectHelper projectHelper, List<Artifact> pluginArtifact, Log logger) throws MojoExecutionException { try { Project antProject = new Project(); ProjectHelper.configureProject(antProject, antBuildFile); antProject.init(); setupLogger(antBuildFile, logger, antProject); antProject.setBaseDir(project.getBasedir()); Path p = new Path(antProject); p.setPath(StringUtils.join(project.getCompileClasspathElements().iterator(), File.pathSeparator)); antProject.addReference("maven.compile.classpath", p); p = new Path(antProject); p.setPath(StringUtils.join(project.getRuntimeClasspathElements().iterator(), File.pathSeparator)); antProject.addReference("maven.runtime.classpath", p); p = new Path(antProject); p.setPath(StringUtils.join(project.getTestClasspathElements().iterator(), File.pathSeparator)); antProject.addReference("maven.test.classpath", p); antProject.addReference("maven.plugin.classpath", getPathFromArtifacts(pluginArtifact, antProject)); antProject.addReference(DEFAULT_MAVEN_PROJECT_REFID, project); antProject.addReference(DEFAULT_MAVEN_PROJECT_HELPER_REFID, projectHelper); initMavenTasks(antProject); copyProperties(project, antProject); copyProperties(model.getProperties(), antProject); return antProject; } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("DependencyResolutionRequiredException: " + e.getMessage(), e); } catch (BuildException e) { throw new MojoExecutionException("An Ant BuildException has occurred: " + e.getMessage(), e); } catch (Throwable e) { throw new MojoExecutionException("Error executing ant tasks: " + e.getMessage(), e); } }
Example 70
Project: xapi-master File: CodeServerMojo.java View source code |
public void keepAlive() throws MojoExecutionException {
final MavenProject project = getProject();
X_Log.info(getClass(), "Preparing gwt recompiler for " + project, "Include test sources? " + isUseTestSources());
if (null != project) {
addSource(project.getBasedir());
LinkedList<String> modules = new LinkedList<String>();
if (isUseTestSources()) {
for (Object o : project.getTestCompileSourceRoots()) {
File f = new File(String.valueOf(o));
if (f.exists()) {
// Add the source location
addTestSource(f);
// also scan for .gwt.xml modules
try {
modules.addAll(findModules(f));
} catch (Exception e) {
getLog().warn("An error was encountered while searching for .gwt.xml modules", e);
}
} else {
X_Log.warn(getClass(), "Test source does not exist", f);
}
}
for (Resource o : project.getTestResources()) {
File f = new File(o.getDirectory());
if (f.exists()) {
addTestSource(f);
// already
try {
modules.addAll(findModules(f));
} catch (Exception e) {
getLog().warn("An error was encountered while searching for .gwt.xml modules", e);
}
} else {
X_Log.warn(getClass(), "Test resource does not exist", f);
}
}
}
for (Object o : project.getCompileSourceRoots()) {
File f = new File(String.valueOf(o));
if (f.exists()) {
// Add the source location
addSource(f);
// also scan for .gwt.xml modules
try {
modules.addAll(findModules(f));
} catch (Exception e) {
getLog().warn("An error was encountered while searching for .gwt.xml modules in " + f, e);
}
}
}
for (Resource o : project.getResources()) {
File f = new File(o.getDirectory());
if (f.exists()) {
addSource(f);
// already
try {
modules.addAll(findModules(f));
} catch (Exception e) {
getLog().warn("An error was encountered while searching for .gwt.xml modules in " + f, e);
}
}
}
if (modules.size() > 0) {
setModule(modules.get(0));
}
try {
if (isUseTestSources()) {
for (Object o : project.getTestClasspathElements()) {
File f = new File(String.valueOf(o));
if (f.exists()) {
if (f.isDirectory()) {
// directories are to be handled differently
addToTestClasspath(f);
} else {
addTestSource(f);
}
} else {
X_Log.warn(getClass(), "Test classpath element does not exist", f, "from " + o);
}
}
} else {
for (Object o : project.getCompileClasspathElements()) {
File f = new File(String.valueOf(o));
if (f.exists()) {
if (f.isDirectory()) {
// directories are to be handled differently
addToClasspath(f);
} else {
addSource(f);
}
}
}
}
} catch (DependencyResolutionRequiredException e1) {
getLog().error("Unable to load compile-scoped classpath elements." + "\nIf you are extending this plugin, " + "you may need to include <requiresDependencyResolution>compile</requiresDependencyResolution> " + "in your @Mojo annotation / plugin.xml file", e1);
}
}
setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String cp = getClasspath(includeTestSource, ":");
gwtLocations.findArtifact(cp, "gwt-dev", ":");
gwtLocations.findArtifact(cp, "gwt-codeserver", ":");
int before = cp.length();
gwtLocations.findArtifact(cp, "gwt-user", ":");
if (before != cp.length()) {
// Missing gwt-user means we're probably missing org.json and validation apis...
}
if (autoCompile) {
launchServer(includeTestSource, jsInteropMode, logLevel);
}
}
});
try {
while (isVisible()) {
Thread.sleep(1000);
}
} catch (Exception e) {
throw new MojoExecutionException("Error while waiting on codeserver", e);
}
}
Example 71
Project: jboss-modules-surefire-plugin-master File: AbstractSurefireMojo.java View source code |
protected SurefireBooter constructSurefireBooter() throws MojoExecutionException, MojoFailureException {
SurefireBooter surefireBooter = new SurefireBooter();
Artifact surefireArtifact = (Artifact) getPluginArtifactMap().get("org.jboss.maven.surefire.modular:surefire-booter");
if (surefireArtifact == null) {
throw new MojoExecutionException("Unable to locate surefire-booter in the list of plugin artifacts");
}
// MNG-2961: before Maven 2.0.8, fixes getBaseVersion to be -SNAPSHOT if needed
surefireArtifact.isSnapshot();
Artifact junitArtifact;
Artifact testNgArtifact;
try {
addArtifact(surefireBooter, surefireArtifact);
junitArtifact = (Artifact) getProjectArtifactMap().get(getJunitArtifactName());
// SUREFIRE-378, junit can have an alternate artifact name
if (junitArtifact == null && "junit:junit".equals(getJunitArtifactName())) {
junitArtifact = (Artifact) getProjectArtifactMap().get("junit:junit-dep");
}
// TODO: this is pretty manual, but I'd rather not require the plugin > dependencies section right now
testNgArtifact = (Artifact) getProjectArtifactMap().get(getTestNGArtifactName());
if (testNgArtifact != null) {
VersionRange range = VersionRange.createFromVersionSpec("[4.7,)");
if (!range.containsVersion(new DefaultArtifactVersion(testNgArtifact.getVersion()))) {
throw new MojoFailureException("TestNG support requires version 4.7 or above. You have declared version " + testNgArtifact.getVersion());
}
convertTestNGParameters();
if (this.getTestClassesDirectory() != null) {
getProperties().setProperty("testng.test.classpath", getTestClassesDirectory().getAbsolutePath());
}
addArtifact(surefireBooter, testNgArtifact);
// The plugin uses a JDK based profile to select the right testng. We might be explicity using a
// different one since its based on the source level, not the JVM. Prune using the filter.
addProvider(surefireBooter, "surefire-testng", Versions.PROPER_SUREFIRE_VERSION, testNgArtifact);
} else if (junitArtifact != null && isAnyJunit4(junitArtifact)) {
if (isAnyConcurrencySelected() && isJunit47Compatible(junitArtifact)) {
convertJunitCoreParameters();
addProvider(surefireBooter, "surefire-junit47", Versions.PROPER_SUREFIRE_VERSION, null);
} else {
addProvider(surefireBooter, "surefire-junit4", Versions.PROPER_SUREFIRE_VERSION, null);
}
} else {
// add the JUnit provider as default - it doesn't require JUnit to be present,
// since it supports POJO tests.
addProvider(surefireBooter, "surefire-junit", Versions.PROPER_SUREFIRE_VERSION, null);
}
} catch (ArtifactNotFoundException e) {
throw new MojoExecutionException("Unable to locate required surefire provider dependency: " + e.getMessage(), e);
} catch (InvalidVersionSpecificationException e) {
throw new MojoExecutionException("Error determining the TestNG version requested: " + e.getMessage(), e);
} catch (ArtifactResolutionException e) {
throw new MojoExecutionException("Error to resolving surefire provider dependency: " + e.getMessage(), e);
}
if (getSuiteXmlFiles() != null && getSuiteXmlFiles().length > 0 && getTest() == null) {
if (testNgArtifact == null) {
throw new MojoExecutionException("suiteXmlFiles is configured, but there is no TestNG dependency");
}
// TODO: properties should be passed in here too
surefireBooter.addTestSuite("org.apache.maven.surefire.testng.TestNGXmlTestSuite", new Object[] { getSuiteXmlFiles(), getTestSourceDirectory().getAbsolutePath(), testNgArtifact.getVersion(), testNgArtifact.getClassifier(), getProperties(), getReportsDirectory() });
} else {
List includes;
List excludes;
if (getTest() != null) {
// Check to see if we are running a single test. The raw parameter will
// come through if it has not been set.
// FooTest -> **/FooTest.java
includes = new ArrayList();
excludes = new ArrayList();
if (getFailIfNoTests() == null) {
setFailIfNoTests(Boolean.TRUE);
}
String[] testRegexes = StringUtils.split(getTest(), ",");
for (int i = 0; i < testRegexes.length; i++) {
String testRegex = testRegexes[i];
if (testRegex.endsWith(".java")) {
testRegex = testRegex.substring(0, testRegex.length() - 5);
}
// Allow paths delimited by '.' or '/'
testRegex = testRegex.replace('.', '/');
includes.add("**/" + testRegex + ".java");
}
} else {
includes = this.getIncludes();
excludes = this.getExcludes();
// Have to wrap in an ArrayList as surefire expects an ArrayList instead of a List for some reason
if (includes == null || includes.size() == 0) {
includes = new ArrayList(Arrays.asList(getDefaultIncludes()));
}
if (excludes == null || excludes.size() == 0) {
excludes = new ArrayList(Arrays.asList(new String[] { "**/*$*" }));
}
}
if (testNgArtifact != null) {
surefireBooter.addTestSuite("org.apache.maven.surefire.testng.TestNGDirectoryTestSuite", new Object[] { getTestClassesDirectory(), includes, excludes, getTestSourceDirectory().getAbsolutePath(), testNgArtifact.getVersion(), testNgArtifact.getClassifier(), getProperties(), getReportsDirectory() });
} else {
String junitDirectoryTestSuite;
if (isAnyConcurrencySelected() && isJunit47Compatible(junitArtifact)) {
junitDirectoryTestSuite = "org.apache.maven.surefire.junitcore.JUnitCoreDirectoryTestSuite";
getLog().info("Concurrency config is " + getProperties().toString());
surefireBooter.addTestSuite(junitDirectoryTestSuite, new Object[] { getTestClassesDirectory(), includes, excludes, getProperties() });
} else {
if (isAnyJunit4(junitArtifact)) {
junitDirectoryTestSuite = "org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite";
} else {
// fall back to JUnit, which also contains POJO support. Also it can run
// classes compiled against JUnit since it has a dependency on JUnit itself.
junitDirectoryTestSuite = "org.apache.maven.surefire.junit.JUnitDirectoryTestSuite";
}
surefireBooter.addTestSuite(junitDirectoryTestSuite, new Object[] { getTestClassesDirectory(), includes, excludes });
}
}
}
List classpathElements = null;
try {
classpathElements = generateTestClasspath();
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Unable to generate test classpath: " + e, e);
}
getLog().debug("Test Classpath :");
for (Iterator i = classpathElements.iterator(); i.hasNext(); ) {
String classpathElement = (String) i.next();
getLog().debug(" " + classpathElement);
surefireBooter.addClassPathUrl(classpathElement);
}
Toolchain tc = getToolchain();
if (tc != null) {
getLog().info("Toolchain in " + getPluginName() + "-plugin: " + tc);
if (isForkModeNever()) {
setForkMode(ForkConfiguration.FORK_ONCE);
}
if (getJvm() != null) {
getLog().warn("Toolchains are ignored, 'executable' parameter is set to " + getJvm());
} else {
//NOI18N
setJvm(tc.findTool("java"));
}
}
// ----------------------------------------------------------------------
// Forking
// ----------------------------------------------------------------------
ForkConfiguration fork = new ForkConfiguration();
fork.setForkMode(getForkMode());
processSystemProperties(!fork.isForking());
if (getLog().isDebugEnabled()) {
showMap(getInternalSystemProperties(), "system property");
}
if (fork.isForking()) {
setUseSystemClassLoader(getUseSystemClassLoader() == null ? Boolean.TRUE : getUseSystemClassLoader());
fork.setUseSystemClassLoader(getUseSystemClassLoader().booleanValue());
fork.setUseManifestOnlyJar(isUseManifestOnlyJar());
fork.setSystemProperties(getInternalSystemProperties());
if ("true".equals(getDebugForkedProcess())) {
setDebugForkedProcess("-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
}
fork.setDebugLine(getDebugForkedProcess());
if (getJvm() == null || "".equals(getJvm())) {
// use the same JVM as the one used to run Maven (the "java.home" one)
setJvm(System.getProperty("java.home") + File.separator + "bin" + File.separator + "java");
getLog().debug("Using JVM: " + getJvm());
}
fork.setJvmExecutable(getJvm());
if (getWorkingDirectory() != null) {
fork.setWorkingDirectory(getWorkingDirectory());
} else {
fork.setWorkingDirectory(getBasedir());
}
fork.setArgLine(getArgLine());
fork.setEnvironmentVariables(getEnvironmentVariables());
if (getLog().isDebugEnabled()) {
showMap(getEnvironmentVariables(), "environment variable");
fork.setDebug(true);
}
if (getArgLine() != null) {
List args = Arrays.asList(getArgLine().split(" "));
if (args.contains("-da") || args.contains("-disableassertions")) {
setEnableAssertions(false);
}
}
}
fork = processForkConfiguration(fork);
surefireBooter.setFailIfNoTests(getFailIfNoTests() == null ? false : getFailIfNoTests().booleanValue());
surefireBooter.setForkedProcessTimeoutInSeconds(getForkedProcessTimeoutInSeconds());
surefireBooter.setRedirectTestOutputToFile(isRedirectTestOutputToFile());
surefireBooter.setForkConfiguration(fork);
surefireBooter.setChildDelegation(isChildDelegation());
surefireBooter.setEnableAssertions(isEnableAssertions());
surefireBooter.setReportsDirectory(getReportsDirectory());
addReporters(surefireBooter, fork.isForking());
return surefireBooter;
}
Example 72
Project: jaxb2-maven-plugin-master File: TestSchemaGenerationMojo.java View source code |
/**
* {@inheritDoc}
*/
@Override
protected List<String> getClasspath() throws MojoExecutionException {
List<String> toReturn = null;
try {
toReturn = getProject().getTestClasspathElements();
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Could not acquire compile classpath elements from MavenProject", e);
}
// All done.
return toReturn;
}
Example 73
Project: lemma-master File: LemmaMojo.java View source code |
public XHTMLTemplateJavadocPipeline createPipeline(List<File> sourceDirectories, List<String> packageNames, MavenProject project) throws Exception {
// Yep, the Javadoc tool has its own classpath, we abuse the javac system property to get it into the Gaftercode
String javadocClasspath = null;
try {
List<String> classpathElements = (List<String>) project.getTestClasspathElements();
StringBuilder sb = new StringBuilder();
for (String classpathElement : classpathElements) {
sb.append(classpathElement).append(File.pathSeparator);
}
if (sb.length() > 0)
sb.deleteCharAt(sb.length() - 1);
javadocClasspath = sb.toString();
if (javadocClasspath != null) {
getLog().debug("Setting Javadoc classpath: " + javadocClasspath);
// The Javadoc code reads this env variable!
System.setProperty("env.class.path", javadocClasspath);
}
} catch (DependencyResolutionRequiredException ex) {
throw new Exception("Can't get test-scope classpath: " + ex.toString(), ex);
}
// Hurray for more logging abstractions!
Handler loggingAdapter = new Handler() {
Formatter formatter = new Formatter() {
@Override
public String format(LogRecord logRecord) {
return formatMessage(logRecord);
}
};
@Override
public void publish(LogRecord logRecord) {
if (logRecord.getLevel().equals(Level.SEVERE) && getLog().isErrorEnabled()) {
getLog().error(formatter.format(logRecord));
} else if (logRecord.getLevel().equals(Level.WARNING) && getLog().isWarnEnabled()) {
getLog().warn(formatter.format(logRecord));
} else if (logRecord.getLevel().equals(Level.INFO) && getLog().isInfoEnabled()) {
getLog().info(formatter.format(logRecord));
} else if (getLog().isDebugEnabled()) {
getLog().debug(formatter.format(logRecord));
}
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
}
};
loggingAdapter.setLevel(Level.ALL);
LoggingUtil.resetRootHandler(loggingAdapter);
LogManager.getLogManager().getLogger("").setLevel(Level.ALL);
for (File sourceDirectory : sourceDirectories) {
if (!sourceDirectory.canRead()) {
throw new Exception("Source directory not found or not readable: " + sourceDirectory);
}
if (!sourceDirectory.isDirectory()) {
throw new Exception("Source directory is not a directory: " + sourceDirectory);
}
}
if (packageNames.size() == 0) {
for (File sourceDirectory : sourceDirectories) {
// Default to all sub-directories in source directory
File[] subdirs = sourceDirectory.listFiles(new FileFilter() {
public boolean accept(File file) {
return file.isDirectory() && file.getName().matches("[a-zA-Z_]+");
}
});
for (File subdir : subdirs) {
packageNames.add(subdir.getName());
}
// Filter duplicates
packageNames = new ArrayList(new LinkedHashSet(packageNames));
}
}
// Finally, do the work
return new XHTMLTemplateJavadocPipeline(sourceDirectories, packageNames, true, processXRefs);
}
Example 74
Project: maven-plugin-tools-master File: GeneratorUtils.java View source code |
@SuppressWarnings("unchecked")
public static boolean isMavenReport(String impl, MavenProject project) throws IllegalArgumentException {
if (impl == null) {
throw new IllegalArgumentException("mojo implementation should be declared");
}
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (project != null) {
List<String> classPathStrings;
try {
classPathStrings = project.getCompileClasspathElements();
if (project.getExecutionProject() != null) {
classPathStrings.addAll(project.getExecutionProject().getCompileClasspathElements());
}
} catch (DependencyResolutionRequiredException e) {
throw new IllegalArgumentException(e);
}
List<URL> urls = new ArrayList<URL>(classPathStrings.size());
for (String classPathString : classPathStrings) {
try {
urls.add(new File(classPathString).toURL());
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
}
classLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]), classLoader);
}
try {
Class<?> clazz = Class.forName(impl, false, classLoader);
return MavenReport.class.isAssignableFrom(clazz);
} catch (ClassNotFoundException e) {
return false;
}
}
Example 75
Project: rh-nexus-maven-tooling-master File: PluginDescriptorMojo.java View source code |
@SuppressWarnings("unchecked")
public void execute() throws MojoExecutionException, MojoFailureException {
if (!mavenProject.getPackaging().equals(mapping.getPluginPackaging())) {
getLog().info("Project is not of packaging type '" + mapping.getPluginPackaging() + "'.");
return;
}
initConfig();
final PluginMetadataGenerationRequest request = new PluginMetadataGenerationRequest();
request.setGroupId(mavenProject.getGroupId());
request.setArtifactId(mavenProject.getArtifactId());
request.setVersion(mavenProject.getVersion());
request.setName(mavenProject.getName());
request.setDescription(mavenProject.getDescription());
request.setPluginSiteURL(mavenProject.getUrl());
request.setApplicationId(applicationId);
request.setApplicationEdition(applicationEdition);
request.setApplicationMinVersion(applicationMinVersion);
request.setApplicationMaxVersion(applicationMaxVersion);
// licenses
if (mavenProject.getLicenses() != null) {
for (final License mavenLicenseModel : (List<License>) mavenProject.getLicenses()) {
request.addLicense(mavenLicenseModel.getName(), mavenLicenseModel.getUrl());
}
}
// scm information
try {
final ScmRepository repository = getScmRepository();
final SvnInfoScmResult scmResult = scmInfo(repository, new ScmFileSet(mavenProject.getBasedir()));
if (!scmResult.isSuccess()) {
throw new ScmException(scmResult.getCommandOutput());
}
final SvnInfoItem info = (SvnInfoItem) scmResult.getInfoItems().get(0);
request.setScmVersion(info.getLastChangedRevision());
request.setScmTimestamp(info.getLastChangedDate());
} catch (final ScmException e) {
getLog().warn("Failed to get scm information: " + e.getMessage());
}
// dependencies
final List<Artifact> artifacts = mavenProject.getTestArtifacts();
final Set<Artifact> classpathArtifacts = new HashSet<Artifact>();
if (artifacts != null) {
final Set<String> excludedArtifactIds = new HashSet<String>();
final ArtifactSelector selector = artifactSet == null ? null : new ArtifactSelector(mavenProject.getArtifact(), artifactSet);
artifactLoop: for (final Artifact artifact : artifacts) {
final GAVCoordinate artifactCoordinate = new GAVCoordinate(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getClassifier(), artifact.getType());
if (artifact.getType().equals(mapping.getPluginPackaging())) {
if (artifact.isSnapshot()) {
artifactCoordinate.setVersion(artifact.getBaseVersion());
}
if (!Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) {
throw new MojoFailureException("Plugin dependency \"" + artifact.getDependencyConflictId() + "\" must have the \"provided\" scope!");
}
excludedArtifactIds.add(artifact.getId());
request.addPluginDependency(artifactCoordinate);
} else if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) || Artifact.SCOPE_TEST.equals(artifact.getScope())) {
excludedArtifactIds.add(artifact.getId());
} else if ((Artifact.SCOPE_COMPILE.equals(artifact.getScope()) || Artifact.SCOPE_RUNTIME.equals(artifact.getScope())) && (!mapping.matchesCoreGroupIds(artifact.getGroupId()))) {
if (artifact.getDependencyTrail() != null) {
for (final String trailId : (List<String>) artifact.getDependencyTrail()) {
if (excludedArtifactIds.contains(trailId)) {
getLog().debug("Dependency artifact: " + artifact.getId() + " is part of the transitive dependency set for a dependency with 'provided' or 'test' scope: " + trailId + "\nThis artifact will be excluded from the plugin classpath.");
continue artifactLoop;
}
}
}
if (selector == null || selector.isSelected(artifact)) {
if (componentDependencies != null && componentDependencies.contains(artifact.getGroupId() + ":" + artifact.getArtifactId())) {
artifactCoordinate.setHasComponents(true);
}
request.addClasspathDependency(artifactCoordinate);
classpathArtifacts.add(artifact);
} else {
getLog().debug("Excluding: " + artifact.getId() + "; excluded by artifactSet.");
excludedArtifactIds.add(artifact.getId());
}
}
}
}
request.setOutputFile(generatedPluginMetadata);
request.setClassesDirectory(new File(mavenProject.getBuild().getOutputDirectory()));
try {
if (mavenProject.getCompileClasspathElements() != null) {
for (final String classpathElement : (List<String>) mavenProject.getCompileClasspathElements()) {
request.getClasspath().add(new File(classpathElement));
}
}
} catch (final DependencyResolutionRequiredException e) {
throw new MojoFailureException("Plugin failed to resolve dependencies: " + e.getMessage(), e);
}
request.getAnnotationClasses().add(ExtensionPoint.class);
request.getAnnotationClasses().add(Managed.class);
// do the work
try {
metadataGenerator.generatePluginDescriptor(request);
} catch (final GleanerException e) {
throw new MojoFailureException("Failed to generate plugin xml file: " + e.getMessage(), e);
}
try {
ClasspathUtils.write(classpathArtifacts, mavenProject);
} catch (final IOException e) {
throw new MojoFailureException("Failed to generate classpath properties file: " + e.getMessage(), e);
}
}
Example 76
Project: richfaces-cdk-master File: AbstractCDKMojo.java View source code |
protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
List<?> compileClasspathElements = project.getCompileClasspathElements();
String outputDirectory = project.getBuild().getOutputDirectory();
URL[] urls = new URL[compileClasspathElements.size() + 1];
int i = 0;
urls[i++] = new File(outputDirectory).toURI().toURL();
for (Iterator<?> iter = compileClasspathElements.iterator(); iter.hasNext(); ) {
String element = (String) iter.next();
urls[i++] = new File(element).toURI().toURL();
}
if (useCCL) {
classLoader = new URLClassLoader(urls, classLoader);
} else {
classLoader = new URLClassLoader(urls);
}
} catch (MalformedURLException e) {
getLog().error("Bad URL in classpath", e);
} catch (DependencyResolutionRequiredException e) {
getLog().error("Dependencies not resolved ", e);
}
return classLoader;
}
Example 77
Project: sarl-master File: AbstractDocumentationMojo.java View source code |
/** Replies the current classpath.
*
* @return the current classpath.
* @throws IOException on failure.
*/
protected List<File> getClassPath() throws IOException {
final Set<String> classPath = new LinkedHashSet<>();
classPath.add(this.session.getCurrentProject().getBuild().getSourceDirectory());
try {
classPath.addAll(this.session.getCurrentProject().getCompileClasspathElements());
} catch (DependencyResolutionRequiredException e) {
throw new IOException(e.getLocalizedMessage(), e);
}
for (final Artifact dep : this.session.getCurrentProject().getArtifacts()) {
classPath.add(dep.getFile().getAbsolutePath());
}
classPath.remove(this.session.getCurrentProject().getBuild().getOutputDirectory());
final List<File> files = new ArrayList<>();
for (final String filename : classPath) {
final File file = new File(filename);
if (file.exists()) {
files.add(file);
}
}
return files;
}
Example 78
Project: speedment-master File: AbstractSpeedmentMojo.java View source code |
@SuppressWarnings("unchecked")
protected final ClassLoader getClassLoader() throws MojoExecutionException, DependencyResolutionRequiredException {
final MavenProject project = project();
final List<String> classpathElements = new ArrayList<>();
classpathElements.addAll(project.getCompileClasspathElements());
classpathElements.addAll(project.getRuntimeClasspathElements());
classpathElements.add(project.getBuild().getOutputDirectory());
final List<URL> projectClasspathList = new ArrayList<>();
for (final String element : classpathElements) {
try {
projectClasspathList.add(new File(element).toURI().toURL());
} catch (final MalformedURLException ex) {
throw new MojoExecutionException(element + " is an invalid classpath element", ex);
}
}
return new URLClassLoader(projectClasspathList.toArray(new URL[projectClasspathList.size()]), Thread.currentThread().getContextClassLoader());
}
Example 79
Project: caliper-maven-plugin-master File: BenchmarkMojo.java View source code |
@SuppressWarnings("unchecked")
protected ClassLoader getBenchmarkClassloader() throws MojoExecutionException {
try {
Collection<String> urls = project.getTestClasspathElements();
URL[] runtimeUrls = new URL[urls.size() + 1];
int i = 0;
for (String url : urls) {
runtimeUrls[i++] = new File(url).toURI().toURL();
}
runtimeUrls[i] = getPathToPluginJar();
return new BenchmarkClassLoader(runtimeUrls, Thread.currentThread().getContextClassLoader());
} catch (MalformedURLException e) {
throw bug(e);
} catch (DependencyResolutionRequiredException e) {
throw bug(e);
} catch (IOException e) {
throw bug(e);
}
}
Example 80
Project: junit-contracts-master File: ContractMojo.java View source code |
private ClassLoader buildClassLoader() throws MojoExecutionException {
final ClassWorld world = new ClassWorld();
ClassRealm realm;
try {
realm = world.newRealm("contract", null);
// add contract test and it's transient dependencies.
for (final Artifact elt : getJunitContractsArtifacts()) {
final String dir = String.format("%s!/", elt.getFile().toURI().toURL());
if (getLog().isDebugEnabled()) {
getLog().debug("Checking for imports from: " + dir);
}
try {
final Set<String> classNames = ClassPathUtils.findClasses(dir, "org.xenei.junit.contract");
for (final String clsName : classNames) {
if (getLog().isDebugEnabled()) {
getLog().debug("Importing from current classloader: " + clsName);
}
importFromCurrentClassLoader(realm, Class.forName(clsName));
}
} catch (final ClassNotFoundException e) {
throw new MojoExecutionException(e.toString(), e);
} catch (final IOException e) {
throw new MojoExecutionException(e.toString(), e);
}
}
// add source dirs
for (final String elt : project.getCompileSourceRoots()) {
final URL url = new File(elt).toURI().toURL();
realm.addURL(url);
if (getLog().isDebugEnabled()) {
getLog().debug("Source root: " + url);
}
}
// add Compile classpath
for (final String elt : project.getCompileClasspathElements()) {
final URL url = new File(elt).toURI().toURL();
realm.addURL(url);
if (getLog().isDebugEnabled()) {
getLog().debug("Compile classpath: " + url);
}
}
// add Test classpath
for (final String elt : project.getTestClasspathElements()) {
final URL url = new File(elt).toURI().toURL();
realm.addURL(url);
if (getLog().isDebugEnabled()) {
getLog().debug("Test classpath: " + url);
}
}
} catch (final DuplicateRealmException e) {
throw new MojoExecutionException(e.getMessage(), e);
} catch (final MalformedURLException e) {
throw new MojoExecutionException(e.getMessage(), e);
} catch (final DependencyResolutionRequiredException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
return realm;
}
Example 81
Project: openicf-master File: DocBookResourceMojo.java View source code |
private File generateArchive(File docbkxFiles, String jarFileName) throws ArchiverException, IOException { File docbkxJar = new File(buildDirectory, jarFileName); if (docbkxJar.exists()) { docbkxJar.delete(); } MavenArchiver archiver = new MavenArchiver(); archiver.setArchiver(jarArchiver); archiver.setOutputFile(docbkxJar); if (!docbkxFiles.exists()) { getLog().warn("JAR will be empty - no content was marked for inclusion!"); } else { archiver.getArchiver().addDirectory(docbkxFiles); } List<Resource> resources = project.getBuild().getResources(); for (Resource r : resources) { if (r.getDirectory().endsWith("maven-shared-archive-resources")) { archiver.getArchiver().addDirectory(new File(r.getDirectory())); } } try { archive.setAddMavenDescriptor(false); archiver.createArchive(session, project, archive); } catch (ManifestException e) { throw new ArchiverException("ManifestException: " + e.getMessage(), e); } catch (DependencyResolutionRequiredException e) { throw new ArchiverException("DependencyResolutionRequiredException: " + e.getMessage(), e); } return docbkxJar; }
Example 82
Project: robovm-maven-plugin-master File: AbstractRoboVMMojo.java View source code |
protected Config.Builder configure(Config.Builder builder) throws MojoExecutionException {
builder.logger(getRoboVMLogger());
if (os != null) {
builder.os(OS.valueOf(os));
}
if (propertiesFile != null) {
if (!propertiesFile.exists()) {
throw new MojoExecutionException("Invalid 'propertiesFile' specified for RoboVM compile: " + propertiesFile);
}
try {
getLog().debug("Including properties file in RoboVM compiler config: " + propertiesFile.getAbsolutePath());
builder.addProperties(propertiesFile);
} catch (IOException e) {
throw new MojoExecutionException("Failed to add properties file to RoboVM config: " + propertiesFile);
}
} else {
try {
builder.readProjectProperties(project.getBasedir(), false);
} catch (IOException e) {
throw new MojoExecutionException("Failed to read RoboVM project properties file(s) in " + project.getBasedir().getAbsolutePath(), e);
}
}
if (configFile != null) {
if (!configFile.exists()) {
throw new MojoExecutionException("Invalid 'configFile' specified for RoboVM compile: " + configFile);
}
try {
getLog().debug("Loading config file for RoboVM compiler: " + configFile.getAbsolutePath());
builder.read(configFile);
} catch (Exception e) {
throw new MojoExecutionException("Failed to read RoboVM config file: " + configFile);
}
} else {
try {
builder.readProjectConfig(project.getBasedir(), false);
} catch (Exception e) {
throw new MojoExecutionException("Failed to read project RoboVM config file in " + project.getBasedir().getAbsolutePath(), e);
}
}
// Read embedded RoboVM <config> if there is one
Plugin plugin = project.getPlugin("org.robovm:robovm-maven-plugin");
MavenProject p = project;
while (p != null && plugin == null) {
plugin = p.getPluginManagement().getPluginsAsMap().get("org.robovm:robovm-maven-plugin");
if (plugin == null)
p = p.getParent();
}
if (plugin != null) {
getLog().debug("Reading RoboVM plugin configuration from " + p.getFile().getAbsolutePath());
Xpp3Dom configDom = (Xpp3Dom) plugin.getConfiguration();
if (configDom != null && configDom.getChild("config") != null) {
StringWriter sw = new StringWriter();
XMLWriter xmlWriter = new PrettyPrintXMLWriter(sw, "UTF-8", null);
Xpp3DomWriter.write(xmlWriter, configDom.getChild("config"));
try {
builder.read(new StringReader(sw.toString()), project.getBasedir());
} catch (Exception e) {
throw new MojoExecutionException("Failed to read RoboVM config embedded in POM", e);
}
}
}
File tmpDir = new File(project.getBuild().getDirectory(), "robovm.tmp");
try {
FileUtils.deleteDirectory(tmpDir);
} catch (IOException e) {
throw new MojoExecutionException("Failed to clean output dir " + tmpDir, e);
}
tmpDir.mkdirs();
Home home = null;
try {
home = Home.find();
} catch (Throwable t) {
}
if (home == null || !home.isDev()) {
home = new Config.Home(unpackRoboVMDist());
}
builder.home(home).tmpDir(tmpDir).skipInstall(true).installDir(installDir);
if (home.isDev()) {
builder.useDebugLibs(Boolean.getBoolean("robovm.useDebugLibs"));
builder.dumpIntermediates(true);
}
if (debug != null && !debug.equals("false")) {
builder.debug(true);
if (debugPort != -1) {
builder.addPluginArgument("debug:jdwpport=" + debugPort);
}
if ("clientmode".equals(debug)) {
builder.addPluginArgument("debug:clientmode=true");
}
}
if (skipSigning) {
builder.iosSkipSigning(true);
} else {
if (signIdentity != null) {
getLog().debug("Using explicit signing identity: " + signIdentity);
builder.iosSignIdentity(SigningIdentity.find(SigningIdentity.list(), signIdentity));
}
if (provisioningProfile != null) {
getLog().debug("Using explicit provisioning profile: " + provisioningProfile);
builder.iosProvisioningProfile(ProvisioningProfile.find(ProvisioningProfile.list(), provisioningProfile));
}
if (keychainPassword != null) {
builder.keychainPassword(keychainPassword);
} else if (keychainPasswordFile != null) {
builder.keychainPasswordFile(keychainPasswordFile);
}
}
if (cacheDir != null) {
builder.cacheDir(cacheDir);
}
builder.clearClasspathEntries();
try {
for (Object object : project.getRuntimeClasspathElements()) {
String path = (String) object;
if (getLog().isDebugEnabled()) {
getLog().debug("Including classpath element for RoboVM app: " + path);
}
builder.addClasspathEntry(new File(path));
}
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Error resolving application classpath for RoboVM build", e);
}
return builder;
}
Example 83
Project: sling-master File: JspcMojo.java View source code |
private void initClassLoader() throws IOException, DependencyResolutionRequiredException {
List artifacts = project.getCompileArtifacts();
URL[] path = new URL[artifacts.size() + 1];
int i = 0;
for (Iterator ai = artifacts.iterator(); ai.hasNext(); ) {
Artifact a = (Artifact) ai.next();
path[i++] = a.getFile().toURI().toURL();
}
final String targetDirectory = project.getBuild().getOutputDirectory();
path[path.length - 1] = new File(targetDirectory).toURI().toURL();
loader = new URLClassLoader(path, this.getClass().getClassLoader());
}
Example 84
Project: wro4j-master File: AbstractWro4jMojo.java View source code |
/**
* Update the classpath.
*/
protected final void extendPluginClasspath() throws MojoExecutionException {
// this code is inspired from http://teleal.org/weblog/Extending%20the%20Maven%20plugin%20classpath.html
final List<String> classpathElements = new ArrayList<String>();
try {
classpathElements.addAll(mavenProject.getRuntimeClasspathElements());
} catch (final DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Could not get compile classpath elements", e);
}
final ClassLoader classLoader = createClassLoader(classpathElements);
Thread.currentThread().setContextClassLoader(classLoader);
}
Example 85
Project: hbase-maven-plugin-master File: StartMojo.java View source code |
/**
* Gets the runtime classpath required to run the mini clusters.
*
* <p>The maven classloading scheme is nonstandard. They only put the "classworlds" jar
* on the classpath, and it takes care of ClassLoading the rest of the jars. This a
* problem if we are going to start a mini MapReduce cluster. The TaskTracker will
* start a child JVM with the same classpath as this process, and it won't have
* configured the classworlds class loader. To work around this, we will put all of
* our dependencies into the java.class.path system property, which will be read by
* the TaskRunner's child JVM launcher to build the child JVM classpath.</p>
*
* <p>Note that when we say "all of our dependencies" we mean both the dependencies of
* this plugin as well as the test classes and dependencies of the project that is
* running the plugin. We need to include the latter on the classpath because tests are
* still just .class files at integration-test-time. There will be no jars available
* yet to put on the distributed cache via job.setJarByClass(). Hence, all of the
* test-classes in the project running this plugin need to already be on the classpath
* of the MapReduce cluster.<p>
*/
private String getClassPath() throws MojoExecutionException {
// Maintain a set of classpath components added so we can de-dupe.
Set<String> alreadyAddedComponents = new HashSet<String>();
// Use this to build up the classpath string.
StringBuilder classpath = new StringBuilder();
// Add the existing classpath.
String existingClasspath = System.getProperty("java.class.path");
classpath.append(existingClasspath);
alreadyAddedComponents.addAll(Arrays.asList(existingClasspath.split(":")));
// Add the test classes and dependencies of the maven project running this plugin.
//
// Note: It is important that we add these classes and dependencies before we add this
// plugin's dependencies in case the maven project needs to override a jar version.
List<?> testClasspathComponents;
try {
testClasspathComponents = mMavenProject.getTestClasspathElements();
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Unable to retrieve project test classpath", e);
}
for (Object testClasspathComponent : testClasspathComponents) {
String dependency = testClasspathComponent.toString();
if (alreadyAddedComponents.contains(dependency)) {
continue;
}
classpath.append(":");
classpath.append(dependency);
alreadyAddedComponents.add(dependency);
}
// Add this plugin's dependencies.
for (Artifact artifact : mPluginDependencyArtifacts) {
String dependency = artifact.getFile().getPath();
if (alreadyAddedComponents.contains(dependency)) {
continue;
}
classpath.append(":");
classpath.append(dependency);
alreadyAddedComponents.add(dependency);
}
return classpath.toString();
}
Example 86
Project: infer-maven-plugin-master File: InferMojo.java View source code |
@Override
public void execute() throws MojoExecutionException {
if (inferDir == null) {
inferDir = new File(System.getProperty(USER_DIR), DEFAULT_MAVEN_BUILD_DIR_NAME).getAbsolutePath();
}
if (inferPath != null && !INFER_CMD_NAME.equals(inferPath)) {
getLog().info(String.format("Infer path set to: %s", inferPath));
}
// check if infer is on the PATH and if not, then download it.
if (inferPath == null && download) {
inferPath = downloadInfer(new File(inferDir, INFER_DOWNLOAD_DIRETORY_NAME));
} else if (inferPath == null) {
inferPath = inferCommand;
}
try {
// get source directory, if it doesn't exist then we're done
final File sourceDir = new File(project.getBuild().getSourceDirectory());
if (!sourceDir.exists()) {
return;
}
final File inferOutputDir = getInferOutputDir();
final SimpleSourceInclusionScanner scanner = new SimpleSourceInclusionScanner(Collections.singleton("**/*.java"), Collections.<String>emptySet());
scanner.addSourceMapping(new SuffixMapping(JAVA_SRC_EXTENSION, Collections.<String>emptySet()));
final Collection<File> sourceFiles = scanner.getIncludedSources(sourceDir, null);
final int numSourceFiles = sourceFiles.size();
fileCount += numSourceFiles;
final String classpath = getRuntimeAndCompileClasspath();
completeInferExecutions(classpath, inferOutputDir, sourceFiles, numSourceFiles);
reportResults(inferOutputDir, numSourceFiles);
} catch (final DependencyResolutionRequiredException e) {
getLog().error(e);
throw new MojoExecutionException("Unable to get required dependencies to perform Infer check!", e);
} catch (final InclusionScanException e) {
getLog().error(e);
throw new MojoExecutionException("Failed to get sources! Cannot complete Infer check", e);
}
}
Example 87
Project: license-maven-plugin-master File: AbstractLicenseMojo.java View source code |
@SuppressWarnings({ "unchecked" })
public final void execute(final Callback callback) throws MojoExecutionException, MojoFailureException {
if (!skip) {
if (header == null && (this.inlineHeader == null || this.inlineHeader.isEmpty())) {
warn("No header file specified to check for license");
return;
}
if (!strictCheck) {
warn("Property 'strictCheck' is not enabled. Please consider adding <strictCheck>true</strictCheck> in your pom.xml file.");
warn("See http://mycila.github.io/license-maven-plugin for more information.");
}
finder = new ResourceFinder(basedir);
try {
finder.setCompileClassPath(project.getCompileClasspathElements());
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
finder.setPluginClassPath(getClass().getClassLoader());
final HeaderSource headerSource = HeaderSource.of(this.inlineHeader, this.header, this.encoding, this.finder);
final Header h = new Header(headerSource, headerSections);
debug("Header: %s", h.getLocation());
if (this.validHeaders == null) {
this.validHeaders = new String[0];
}
final List<Header> validHeaders = new ArrayList<Header>(this.validHeaders.length);
for (String validHeader : this.validHeaders) {
final HeaderSource validHeaderSource = HeaderSource.of(null, validHeader, this.encoding, this.finder);
validHeaders.add(new Header(validHeaderSource, headerSections));
}
final List<PropertiesProvider> propertiesProviders = new LinkedList<PropertiesProvider>();
for (PropertiesProvider provider : ServiceLoader.load(PropertiesProvider.class, Thread.currentThread().getContextClassLoader())) {
propertiesProviders.add(provider);
}
final DocumentPropertiesLoader propertiesLoader = new DocumentPropertiesLoader() {
@Override
public Properties load(Document document) {
Properties props = new Properties();
for (Map.Entry<String, String> entry : mergeProperties(document).entrySet()) {
if (entry.getValue() != null) {
props.setProperty(entry.getKey(), entry.getValue());
} else {
props.remove(entry.getKey());
}
}
for (PropertiesProvider provider : propertiesProviders) {
try {
final Map<String, String> providerProperties = provider.getAdditionalProperties(AbstractLicenseMojo.this, props, document);
if (getLog().isDebugEnabled()) {
getLog().debug("provider: " + provider.getClass() + " brought new properties\n" + providerProperties);
}
for (Map.Entry<String, String> entry : providerProperties.entrySet()) {
if (entry.getValue() != null) {
props.setProperty(entry.getKey(), entry.getValue());
} else {
props.remove(entry.getKey());
}
}
} catch (Exception e) {
getLog().warn("failure occured while calling " + provider.getClass(), e);
}
}
return props;
}
};
final DocumentFactory documentFactory = new DocumentFactory(basedir, buildMapping(), buildHeaderDefinitions(), encoding, keywords, propertiesLoader);
int nThreads = (int) (Runtime.getRuntime().availableProcessors() * concurrencyFactor);
ExecutorService executorService = Executors.newFixedThreadPool(nThreads);
CompletionService completionService = new ExecutorCompletionService(executorService);
int count = 0;
debug("Number of execution threads: %s", nThreads);
try {
for (final String file : listSelectedFiles()) {
completionService.submit(new Runnable() {
@Override
public void run() {
Document document = documentFactory.createDocuments(file);
debug("Selected file: %s [header style: %s]", document.getFilePath(), document.getHeaderDefinition());
if (document.isNotSupported()) {
callback.onUnknownFile(document, h);
} else if (document.is(h)) {
debug("Skipping header file: %s", document.getFilePath());
} else if (document.hasHeader(h, strictCheck)) {
callback.onExistingHeader(document, h);
} else {
boolean headerFound = false;
for (Header validHeader : validHeaders) {
if (headerFound = document.hasHeader(validHeader, strictCheck)) {
callback.onExistingHeader(document, h);
break;
}
}
if (!headerFound) {
callback.onHeaderNotFound(document, h);
}
}
}
}, null);
count++;
}
while (count-- > 0) {
try {
completionService.take().get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof Error) {
throw (Error) cause;
}
if (cause instanceof MojoExecutionException) {
throw (MojoExecutionException) cause;
}
if (cause instanceof MojoFailureException) {
throw (MojoFailureException) cause;
}
if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
}
throw new RuntimeException(cause.getMessage(), cause);
}
}
} finally {
executorService.shutdownNow();
}
}
}
Example 88
Project: maven-duplicate-finder-plugin-master File: DuplicateFinderMojo.java View source code |
private void checkCompileClasspath() throws MojoExecutionException {
try {
LOG.info("Checking compile classpath");
final Set<Artifact> allArtifacts = project.getArtifacts();
final ImmutableSet.Builder<Artifact> inScopeBuilder = ImmutableSet.builder();
for (final Artifact artifact : allArtifacts) {
if (artifact.getArtifactHandler().isAddedToClasspath() && COMPILE_SCOPE.contains(artifact.getScope())) {
inScopeBuilder.add(artifact);
}
}
final Map<File, Artifact> artifactsByFile = createArtifactsByFileMap(inScopeBuilder.build());
addOutputDirectory(artifactsByFile);
checkClasspath(project.getCompileClasspathElements(), artifactsByFile);
} catch (final DependencyResolutionRequiredException ex) {
throw new MojoExecutionException("Could not resolve dependencies", ex);
}
}
Example 89
Project: maven-shared-master File: MavenArchiverTest.java View source code |
@Test
public void testDashesInClassPath_MSHARED_134() throws IOException, ManifestException, DependencyResolutionRequiredException {
File jarFile = new File("target/test/dummyWithDashes.jar");
JarArchiver jarArchiver = getCleanJarArchiver(jarFile);
MavenArchiver archiver = getMavenArchiver(jarArchiver);
MavenSession session = getDummySession();
MavenProject project = getDummyProject();
Set<Artifact> artifacts = getArtifacts(getMockArtifact1(), getArtifactWithDot(), getMockArtifact2(), getMockArtifact3());
project.setArtifacts(artifacts);
MavenArchiveConfiguration config = new MavenArchiveConfiguration();
config.setForced(false);
final ManifestConfiguration mftConfig = config.getManifest();
mftConfig.setMainClass("org.apache.maven.Foo");
mftConfig.setAddClasspath(true);
mftConfig.setAddExtensions(true);
mftConfig.setClasspathPrefix("./lib/");
archiver.createArchive(session, project, config);
assertTrue(jarFile.exists());
}
Example 90
Project: monticore-master File: GenerateMojo.java View source code |
/**
* @return the value of the "modelPaths" configuration parameter.
*/
protected Set<File> getModelPaths() {
ImmutableSet.Builder<File> modelPaths = ImmutableSet.builder();
// 1st: we take all modelpaths directly from the configuration
if (this.modelPaths != null) {
this.modelPaths.forEach( mP -> modelPaths.add(fromBasePath(mP)));
}
// 2nd: if specified we add any grammar directories (default)
if (addGrammarDirectoriesToModelPath()) {
for (File grammarFile : getGrammars()) {
if (grammarFile.isDirectory()) {
modelPaths.add(grammarFile);
}
}
}
// 3rd: if specified we add the project source directories (non default)
if (addSourceDirectoriesToModelPath()) {
getMavenProject().getCompileSourceRoots().forEach( csR -> modelPaths.add(new File(csR)));
}
// default)
if (addClassPathToModelPath()) {
try {
getMavenProject().getCompileClasspathElements().forEach( cpDir -> modelPaths.add(new File(cpDir)));
} catch (DependencyResolutionRequiredException e) {
Throwables.propagate(e);
}
}
for (Artifact artifact : getMavenProject().getArtifacts()) {
// 5th: we add any explicitly specified project dependencies
if (getModelPathDependencies().contains(getArtifactDescription(artifact.getGroupId(), artifact.getArtifactId()))) {
modelPaths.add(artifact.getFile());
} else // the install phase (e.g., mvn dependency:analyze)
if (getClassifiers().contains(artifact.getClassifier()) && (getScopes().isEmpty() || getScopes().contains(artifact.getScope()))) {
modelPaths.add(artifact.getFile());
}
}
return modelPaths.build();
}
Example 91
Project: nifi-maven-master File: NarMojo.java View source code |
public File createArchive() throws MojoExecutionException {
final File outputDirectory = projectBuildDirectory;
File narFile = getNarFile(outputDirectory, finalName, classifier);
MavenArchiver archiver = new MavenArchiver();
archiver.setArchiver(jarArchiver);
archiver.setOutputFile(narFile);
archive.setForced(forceCreation);
try {
File contentDirectory = getClassesDirectory();
if (!contentDirectory.exists()) {
getLog().warn("NAR will be empty - no content was marked for inclusion!");
} else {
archiver.getArchiver().addDirectory(contentDirectory, getIncludes(), getExcludes());
}
File existingManifest = defaultManifestFile;
if (useDefaultManifestFile && existingManifest.exists() && archive.getManifestFile() == null) {
getLog().info("Adding existing MANIFEST to archive. Found under: " + existingManifest.getPath());
archive.setManifestFile(existingManifest);
}
// automatically add the artifact id, group id, and version to the manifest
archive.addManifestEntry("Nar-Id", narId);
archive.addManifestEntry("Nar-Group", narGroup);
archive.addManifestEntry("Nar-Version", narVersion);
// look for a nar dependency
NarDependency narDependency = getNarDependency();
if (narDependency != null) {
final String narDependencyGroup = notEmpty(this.narDependencyGroup) ? this.narDependencyGroup : narDependency.getGroupId();
final String narDependencyId = notEmpty(this.narDependencyId) ? this.narDependencyId : narDependency.getArtifactId();
final String narDependencyVersion = notEmpty(this.narDependencyVersion) ? this.narDependencyVersion : narDependency.getVersion();
archive.addManifestEntry("Nar-Dependency-Group", narDependencyGroup);
archive.addManifestEntry("Nar-Dependency-Id", narDependencyId);
archive.addManifestEntry("Nar-Dependency-Version", narDependencyVersion);
}
if (notEmpty(buildTag)) {
archive.addManifestEntry("Build-Tag", buildTag);
}
if (notEmpty(buildBranch)) {
archive.addManifestEntry("Build-Branch", buildBranch);
}
if (notEmpty(buildRevision)) {
archive.addManifestEntry("Build-Revision", buildRevision);
}
SimpleDateFormat dateFormat = new SimpleDateFormat(BUILD_TIMESTAMP_FORMAT);
archive.addManifestEntry("Build-Timestamp", dateFormat.format(new Date()));
archive.addManifestEntry("Clone-During-Instance-Class-Loading", String.valueOf(cloneDuringInstanceClassLoading));
archiver.createArchive(session, project, archive);
return narFile;
} catch (ArchiverExceptionMojoExecutionException | ManifestException | IOException | DependencyResolutionRequiredException | e) {
throw new MojoExecutionException("Error assembling NAR", e);
}
}
Example 92
Project: richfaces-master File: ProcessMojo.java View source code |
protected URL[] getProjectClassPath() {
try {
List<String> classpath = new ArrayList<String>();
classpath.addAll(project.getCompileClasspathElements());
classpath.add(project.getBuild().getOutputDirectory());
URL[] urlClasspath = filter(transform(classpath, filePathToURL), notNull()).toArray(EMPTY_URL_ARRAY);
return urlClasspath;
} catch (DependencyResolutionRequiredException e) {
getLog().error("Dependencies not resolved ", e);
}
return new URL[0];
}
Example 93
Project: docbookx-tools-master File: AbstractTransformerMojo.java View source code |
protected void executeTasks(Target antTasks, MavenProject mavenProject) throws MojoExecutionException {
try {
ExpressionEvaluator exprEvaluator = (ExpressionEvaluator) antTasks.getProject().getReference("maven.expressionEvaluator");
Project antProject = antTasks.getProject();
PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(antProject);
propertyHelper.setNext(new AntPropertyHelper(exprEvaluator, getLog()));
DefaultLogger antLogger = new DefaultLogger();
antLogger.setOutputPrintStream(System.out);
antLogger.setErrorPrintStream(System.err);
antLogger.setMessageOutputLevel(2);
antProject.addBuildListener(antLogger);
antProject.setBaseDir(mavenProject.getBasedir());
Path p = new Path(antProject);
p.setPath(StringUtils.join(mavenProject.getArtifacts().iterator(), File.pathSeparator));
antProject.addReference("maven.dependency.classpath", p);
p = new Path(antProject);
p.setPath(StringUtils.join(mavenProject.getCompileClasspathElements().iterator(), File.pathSeparator));
antProject.addReference("maven.compile.classpath", p);
p = new Path(antProject);
p.setPath(StringUtils.join(mavenProject.getRuntimeClasspathElements().iterator(), File.pathSeparator));
antProject.addReference("maven.runtime.classpath", p);
p = new Path(antProject);
p.setPath(StringUtils.join(mavenProject.getTestClasspathElements().iterator(), File.pathSeparator));
antProject.addReference("maven.test.classpath", p);
List artifacts = getArtifacts();
List list = new ArrayList(artifacts.size());
File file;
for (Iterator i = artifacts.iterator(); i.hasNext(); list.add(file.getPath())) {
Artifact a = (Artifact) i.next();
file = a.getFile();
if (file == null)
throw new DependencyResolutionRequiredException(a);
}
p = new Path(antProject);
p.setPath(StringUtils.join(list.iterator(), File.pathSeparator));
antProject.addReference("maven.plugin.classpath", p);
getLog().info("Executing tasks");
antTasks.execute();
getLog().info("Executed tasks");
} catch (Exception e) {
throw new MojoExecutionException("Error executing ant tasks", e);
}
}
Example 94
Project: mobicents-master File: AbstractDuMojo.java View source code |
private void generateManagementAntScript(List includedFiles) throws MojoExecutionException, DependencyResolutionRequiredException {
getLog().info("Generating ant script for management without maven...");
File buildFile = new File(targetDirectory, "build.xml");
PrintWriter printWriter = null;
try {
// read header and footer
String header = "";
String footer = "";
LinkedList<String> deployElements = new LinkedList<String>();
LinkedList<String> undeployElements = new LinkedList<String>();
try {
BufferedReader in = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("build.header")));
String str = "";
while ((str = in.readLine()) != null) {
header += str + "\r\n";
}
in = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("build.footer")));
while ((str = in.readLine()) != null) {
footer += str + "\r\n";
}
} catch (IOException e) {
throw new MojoExecutionException("failed to read header and footer of build.xml file", e);
}
// first process deploy-config file
File deployConfigFile = new File(outputDirectory, "META-INF" + File.separator + "deploy-config.xml");
if (deployConfigFile.exists()) {
try {
getLog().info("Parsing deploy-config.xml without validation");
// parse doc into dom
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
Document document = parser.parse(deployConfigFile);
// parse dom into DeployConfig
DeployConfig deployConfig = DeployConfig.parse(document.getDocumentElement());
for (RAEntity raEntity : deployConfig.getRaEntities()) {
// let's start by processing properties
Properties properties = new Properties();
if (!raEntity.getPropertiesFile().equals("")) {
// we have a properties file in META-INF
File propertiesFile = new File(outputDirectory, "META-INF" + File.separator + raEntity.getPropertiesFile());
if (propertiesFile.exists()) {
properties.load(new FileInputStream(propertiesFile));
}
}
// put all properties defined in the deploy-config also
properties.putAll(raEntity.getProperties());
// ok, now we do the strings for the ant script
// the ant call to create and activate the ra entity
String xml = "\t\t<antcall target=\"activate-raentity\">\r\n" + "\t\t\t<param name=\"ra.entity\" value=\"" + raEntity.getEntityName() + "\" />\r\n" + "\t\t\t<param name=\"ra.id\" value=\"" + raEntity.getResourceAdaptorId() + "\" />\r\n";
if (!properties.isEmpty()) {
// generate file in target and add property to ant call
xml += "\t\t\t<param name=\"ra.entity.properties.filename\" value=\"" + raEntity.getEntityName() + ".properties\" />\r\n";
try {
File propertiesFile = new File(outputDirectory, ".." + File.separator + raEntity.getEntityName() + ".properties");
properties.store(new FileOutputStream(propertiesFile), null);
getLog().info("generated properties file " + raEntity.getEntityName() + ".properties");
} catch (IOException e) {
throw new MojoExecutionException("failed to write ra entity properties file into output dir", e);
}
}
xml += "\t\t</antcall>\r\n";
// add this to the deployElements tail
deployElements.addLast(xml);
// the ant call to deactivate and remove the ra entity
xml = "\t\t<antcall target=\"deactivate-raentity\">\r\n" + "\t\t\t<param name=\"ra.entity\" value=\"" + raEntity.getEntityName() + "\" />\r\n" + "\t\t\t<param name=\"ra.id\" value=\"" + raEntity.getResourceAdaptorId() + "\" />\r\n" + "\t\t</antcall>\r\n";
// add this to the undeployElements head
undeployElements.addFirst(xml);
// second we bind/unbind ra links
for (String raLink : raEntity.getRaLinks()) {
xml = "\t\t<antcall target=\"bind-ralink\">\r\n" + "\t\t\t<param name=\"ra.entity\" value=\"" + raEntity.getEntityName() + "\" />\r\n" + "\t\t\t<param name=\"ra.link\" value=\"" + raLink + "\" />\r\n" + "\t\t</antcall>\r\n";
// add this to the deployElements tail
deployElements.addLast(xml);
xml = "\t\t<antcall target=\"unbind-ralink\">\r\n" + "\t\t\t<param name=\"ra.entity\" value=\"" + raEntity.getEntityName() + "\" />\r\n" + "\t\t\t<param name=\"ra.link\" value=\"" + raLink + "\" />\r\n" + "\t\t</antcall>\r\n";
// add this to the undeployElements head
undeployElements.addFirst(xml);
}
}
} catch (Exception e) {
throw new MojoExecutionException("failed to parse resource META-INF/deploy-config.xml", e);
}
}
// now the services descriptors
for (Iterator i = includedFiles.iterator(); i.hasNext(); ) {
String fileName = (String) i.next();
if (fileName.startsWith("services" + File.separator)) {
File serviceDescriptorFile = new File(outputDirectory, fileName);
try {
// http://code.google.com/p/mobicents/issues/detail?id=104
getLog().info("Parsing " + fileName + " with validation");
// parse doc into dom
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
DocumentBuilder parser = factory.newDocumentBuilder();
parser.setEntityResolver(new EntityResolver() {
public InputSource resolveEntity(String publicID, String systemID) throws SAXException {
InputStream is = null;
BufferedReader br = null;
String line;
StringWriter stringWriter = null;
StringReader stringReader = null;
try {
URI uri = new URI(systemID);
getLog().info("Resolving " + systemID + " locally from " + uri);
String filename = uri.toString().substring(uri.toString().lastIndexOf("/") + 1, uri.toString().length());
getLog().info("Resolved filename " + filename);
stringWriter = new StringWriter();
is = getClass().getClassLoader().getResourceAsStream(filename);
br = new BufferedReader(new InputStreamReader(is));
while (null != (line = br.readLine())) {
stringWriter.write(line);
}
stringWriter.flush();
if (stringWriter != null) {
stringWriter.close();
}
stringReader = new StringReader(stringWriter.getBuffer().toString());
return new InputSource(stringReader);
} catch (URISyntaxException e) {
getLog().error(e);
} catch (IOException e) {
getLog().error(e);
} finally {
try {
if (br != null) {
br.close();
}
if (is != null) {
is.close();
}
} catch (IOException e) {
getLog().error(e);
}
}
// If no match, returning null makes process continue normally
return null;
}
});
parser.setErrorHandler(new ErrorHandler() {
public void warning(SAXParseException exception) throws SAXException {
getLog().warn(exception.getMessage());
}
public void fatalError(SAXParseException exception) throws SAXException {
getLog().warn(exception.getMessage());
}
public void error(SAXParseException exception) throws SAXException {
getLog().error(exception.getMessage());
}
});
Document document = parser.parse(serviceDescriptorFile);
// parse dom into service ids
ServiceIds serviceIds = ServiceIds.parse(document.getDocumentElement());
for (ServiceID serviceId : serviceIds.getIds()) {
String xml = "\r\n\t\t<antcall target=\"activate-service\">\r\n" + "\t\t\t<param name=\"service.id\" value=\"" + serviceId + "\" />\r\n" + "\t\t</antcall>\r\n";
// add this to the deployElements tail
deployElements.addLast(xml);
xml = "\r\n\t\t<antcall target=\"deactivate-service\">\r\n" + "\t\t\t<param name=\"service.id\" value=\"" + serviceId + "\" />\r\n" + "\t\t</antcall>\r\n";
// add this to the undeployElements head
undeployElements.addFirst(xml);
}
} catch (Exception e) {
throw new MojoExecutionException("failed to parse service descriptor " + fileName, e);
}
}
}
// now lets glue everything and write the build.xml script
String xml = header + "\r\n\t<property name=\"du.filename\" value=\"" + project.getBuild().getFinalName() + ".jar\" />\r\n" + "\r\n\t<target name=\"deploy-jmx\">\r\n" + "\r\n\t\t<antcall target=\"install-DU\" />\r\n";
for (String s : deployElements) {
xml += s;
}
xml += "\r\n\t</target>\r\n" + "\r\n\t<target name=\"undeploy-jmx\">\r\n";
for (String s : undeployElements) {
xml += s;
}
xml += footer;
printWriter = new PrintWriter(new FileWriter(buildFile));
printWriter.write(xml);
getLog().info("build.xml generated in target dir");
} catch (IOException e) {
throw new MojoExecutionException("Error preparing the build.xml: " + e.getMessage(), e);
} finally {
IOUtil.close(printWriter);
}
}
Example 95
Project: Mav-master File: MavenProject.java View source code |
public List<String> getCompileClasspathElements() throws DependencyResolutionRequiredException {
List<String> list = new ArrayList<>(getArtifacts().size() + 1);
String d = getBuild().getOutputDirectory();
if (d != null) {
list.add(d);
}
for (Artifact a : getArtifacts()) {
if (a.getArtifactHandler().isAddedToClasspath()) {
// TODO let the scope handler deal with this
if (Artifact.SCOPE_COMPILE.equals(a.getScope()) || Artifact.SCOPE_PROVIDED.equals(a.getScope()) || Artifact.SCOPE_SYSTEM.equals(a.getScope())) {
addArtifactPath(a, list);
}
}
}
return list;
}
Example 96
Project: maven-master File: MavenProject.java View source code |
public List<String> getCompileClasspathElements() throws DependencyResolutionRequiredException {
List<String> list = new ArrayList<>(getArtifacts().size() + 1);
String d = getBuild().getOutputDirectory();
if (d != null) {
list.add(d);
}
for (Artifact a : getArtifacts()) {
if (a.getArtifactHandler().isAddedToClasspath()) {
// TODO let the scope handler deal with this
if (Artifact.SCOPE_COMPILE.equals(a.getScope()) || Artifact.SCOPE_PROVIDED.equals(a.getScope()) || Artifact.SCOPE_SYSTEM.equals(a.getScope())) {
addArtifactPath(a, list);
}
}
}
return list;
}
Example 97
Project: oceano-master File: MavenProject.java View source code |
public List<String> getCompileClasspathElements() throws DependencyResolutionRequiredException {
List<String> list = new ArrayList<String>(getArtifacts().size() + 1);
String d = getBuild().getOutputDirectory();
if (d != null) {
list.add(d);
}
for (Artifact a : getArtifacts()) {
if (a.getArtifactHandler().isAddedToClasspath()) {
if (Artifact.SCOPE_COMPILE.equals(a.getScope()) || Artifact.SCOPE_PROVIDED.equals(a.getScope()) || Artifact.SCOPE_SYSTEM.equals(a.getScope())) {
addArtifactPath(a, list);
}
}
}
return list;
}
Example 98
Project: cloudtm-data-platform-master File: DmlPostProcessorMojo.java View source code |
@Override
protected List<String> getClasspathElements() {
try {
return getMavenProject().getCompileClasspathElements();
} catch (DependencyResolutionRequiredException e) {
getLog().error(e);
}
return null;
}
Example 99
Project: cxf-xjc-utils-master File: TestXSDToJavaMojo.java View source code |
protected List<String> getClasspathElements() throws DependencyResolutionRequiredException {
return project.getTestClasspathElements();
}
Example 100
Project: werval-master File: AbstractRunGoal.java View source code |
protected final URL[] runtimeClassPath() throws DependencyResolutionRequiredException, MalformedURLException {
Set<URL> classPathSet = new LinkedHashSet<>();
for (String runtimeClassPathElement : project.getRuntimeClasspathElements()) {
classPathSet.add(new File(runtimeClassPathElement).toURI().toURL());
}
return classPathSet.toArray(new URL[classPathSet.size()]);
}
Example 101
Project: grains-master File: GenerateMojo.java View source code |
@Override
List<String> getGeneratorClasspath() throws DependencyResolutionRequiredException {
return getProject().getRuntimeClasspathElements();
}