org.sonar.mojo.bootstrap.BootstrapMojo Maven / Gradle / Ivy
/*
* Sonar, open source software quality management tool.
* Copyright (C) 2009 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* Sonar is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Sonar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
package org.sonar.mojo.bootstrap;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.project.MavenProject;
import org.sonar.commons.ServerHttpClient;
import static org.sonar.mojo.bootstrap.MojoExecutor.plugin;
/**
* @goal sonar
* @aggregator
*/
public class BootstrapMojo extends AbstractMojo {
/**
* The current maven session
*
* @parameter expression="${session}"
* @readonly
*/
private MavenSession session;
/**
* The maven project running this plugin
*
* @parameter expression="${project}"
* @required
* @readonly
*/
protected MavenProject mavenProject;
/**
* Sonar host URL
*
* @parameter expression="${sonar.host.url}" default-value="http://localhost:9000" alias="sonar.host.url"
*/
private String sonarHostURL;
/**
* The Maven PluginManager Object
*
* @component
* @required
*/
protected PluginManager pluginManager;
/**
* @component
*/
private org.apache.maven.artifact.repository.ArtifactRepositoryFactory repoFactory;
public void execute() throws MojoExecutionException, MojoFailureException {
// TODO : remove this dependency
ServerHttpClient server = new ServerHttpClient(sonarHostURL);
server.checkUp();
try {
MavenProject internalProject = new BootstrapPomBuilder(server).build(repoFactory, mavenProject);
session.setCurrentProject(internalProject);
MojoExecutor.executeMojo(
plugin("org.codehaus.sonar.runtime", "sonar-core-maven-plugin", server.getId()),
"internal",
session, pluginManager);
} catch (Exception e) {
throw new MojoExecutionException("Can not start sonar-core-maven-plugin", e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy