Java Code Examples for org.apache.maven.artifact.DependencyResolutionRequiredException#getLocalizedMessage()

The following examples show how to use org.apache.maven.artifact.DependencyResolutionRequiredException#getLocalizedMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractDocumentationMojo.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Replies the current classpath.
 *
 * @return the current classpath.
 * @throws IOException on failure.
 */
protected List<File> getClassPath() throws IOException {
	final Set<String> classPath = new LinkedHashSet<>();
	final MavenProject curProj = this.session.getCurrentProject();
	classPath.add(curProj.getBuild().getSourceDirectory());
	try {
		classPath.addAll(curProj.getCompileClasspathElements());
	} catch (DependencyResolutionRequiredException e) {
		throw new IOException(e.getLocalizedMessage(), e);
	}
	for (final Artifact dep : curProj.getArtifacts()) {
		classPath.add(dep.getFile().getAbsolutePath());
	}
	classPath.remove(curProj.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 2
Source File: AbstractSarlBatchCompilerMojo.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Replies the classpath for the test code.
 *
 * @return the current classpath.
 * @throws MojoExecutionException on failure.
 * @since 0.8
 * @see #getClassPath()
 */
protected List<File> getTestClassPath() throws MojoExecutionException {
	final Set<String> classPath = new LinkedHashSet<>();
	final MavenProject project = getProject();
	classPath.add(project.getBuild().getTestSourceDirectory());
	try {
		classPath.addAll(project.getTestClasspathElements());
	} catch (DependencyResolutionRequiredException e) {
		throw new MojoExecutionException(e.getLocalizedMessage(), e);
	}
	for (final Artifact dep : project.getArtifacts()) {
		classPath.add(dep.getFile().getAbsolutePath());
	}
	final List<File> files = new ArrayList<>();
	for (final String filename : classPath) {
		final File file = new File(filename);
		if (file.exists()) {
			files.add(file);
		} else {
			getLog().warn(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_10, filename));
		}
	}
	return files;
}
 
Example 3
Source File: AbstractSarlBatchCompilerMojo.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Replies the classpath for the standard code.
 *
 * @return the current classpath.
 * @throws MojoExecutionException on failure.
 * @see #getTestClassPath()
 */
protected List<File> getClassPath() throws MojoExecutionException {
	if (this.bufferedClasspath == null) {
		final Set<String> classPath = new LinkedHashSet<>();
		final MavenProject project = getProject();
		classPath.add(project.getBuild().getSourceDirectory());
		try {
			classPath.addAll(project.getCompileClasspathElements());
		} catch (DependencyResolutionRequiredException e) {
			throw new MojoExecutionException(e.getLocalizedMessage(), e);
		}
		for (final Artifact dep : project.getArtifacts()) {
			classPath.add(dep.getFile().getAbsolutePath());
		}
		classPath.remove(project.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);
			} else {
				getLog().warn(MessageFormat.format(Messages.AbstractSarlBatchCompilerMojo_10, filename));
			}
		}
		this.bufferedClasspath = files;
	}
	return this.bufferedClasspath;
}