Search in sources :

Example 1 with Project

use of org.apache.felix.scrplugin.Project in project felix by apache.

the class SCRDescriptorMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    final String projectType = project.getArtifact().getType();
    // ignore unsupported project types, useful when bundleplugin is configured in parent pom
    if (!supportedProjectTypes.contains(projectType)) {
        getLog().debug("Ignoring project type " + projectType + " - supportedProjectTypes = " + supportedProjectTypes);
        return;
    }
    // create the log for the generator
    final org.apache.felix.scrplugin.Log scrLog = new MavenLog(getLog(), buildContext);
    // create project
    final MavenProjectScanner scanner = new MavenProjectScanner(this.buildContext, this.project, this.sourceIncludes, this.sourceExcludes, this.scanClasses, scrLog);
    final Project project = new Project();
    // create the class loader
    project.setClassLoader(new URLClassLoader(getClassPath(), this.getClass().getClassLoader()));
    project.setDependencies(scanner.getDependencies());
    project.setSources(scanner.getSources());
    project.setClassesDirectory(this.project.getBuild().getOutputDirectory());
    // create options
    final Options options = new Options();
    options.setOutputDirectory(outputDirectory);
    options.setGenerateAccessors(generateAccessors);
    options.setStrictMode(strictMode);
    options.setProperties(properties);
    options.setSpecVersion(SpecVersion.fromName(specVersion));
    options.setIncremental(this.buildContext.isIncremental());
    options.setSkipVolatileCheck(this.skipVolatileCheck);
    if (specVersion != null && options.getSpecVersion() == null) {
        throw new MojoExecutionException("Unknown spec version specified: " + specVersion);
    }
    try {
        final SCRDescriptorGenerator generator = new SCRDescriptorGenerator(scrLog);
        // setup from plugin configuration
        generator.setOptions(options);
        generator.setProject(project);
        this.removePossiblyStaleFiles(scanner.getSources(), options);
        final Result result = generator.execute();
        this.setServiceComponentHeader(options);
        if (!this.updateProjectResources()) {
            this.setIncludeResourceHeader(options);
        }
        this.cleanUpDeletedSources(scanner.getDeletedSources(), options);
        this.refreshMessages(result.getProcessedSourceFiles());
        this.updateBuildContext(result);
    } catch (final SCRDescriptorException sde) {
        throw new MojoExecutionException(sde.getSourceLocation() + " : " + sde.getMessage(), sde);
    } catch (final SCRDescriptorFailureException sdfe) {
        throw (MojoFailureException) new MojoFailureException(sdfe.getMessage()).initCause(sdfe);
    }
}
Also used : Options(org.apache.felix.scrplugin.Options) SCRDescriptorFailureException(org.apache.felix.scrplugin.SCRDescriptorFailureException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) SCRDescriptorGenerator(org.apache.felix.scrplugin.SCRDescriptorGenerator) Result(org.apache.felix.scrplugin.Result) Project(org.apache.felix.scrplugin.Project) MavenProject(org.apache.maven.project.MavenProject) URLClassLoader(java.net.URLClassLoader) SCRDescriptorException(org.apache.felix.scrplugin.SCRDescriptorException)

Aggregations

URLClassLoader (java.net.URLClassLoader)1 Options (org.apache.felix.scrplugin.Options)1 Project (org.apache.felix.scrplugin.Project)1 Result (org.apache.felix.scrplugin.Result)1 SCRDescriptorException (org.apache.felix.scrplugin.SCRDescriptorException)1 SCRDescriptorFailureException (org.apache.felix.scrplugin.SCRDescriptorFailureException)1 SCRDescriptorGenerator (org.apache.felix.scrplugin.SCRDescriptorGenerator)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 MavenProject (org.apache.maven.project.MavenProject)1