Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* SonarQube, open source software quality management tool.
* Copyright (C) 2008-2014 SonarSource
* mailto:contact AT sonarsource DOT com
*
* SonarQube 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.
*
* SonarQube 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 this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.codehaus.mojo.sonar.bootstrap;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.model.CiManagement;
import org.apache.maven.model.IssueManagement;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.Reporting;
import org.apache.maven.model.Scm;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.mojo.sonar.DependencyCollector;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.sonar.runner.api.RunnerProperties;
import org.sonar.runner.api.ScanProperties;
public class MavenProjectConverter
{
private final Log log;
private static final char SEPARATOR = ',';
private static final String UNABLE_TO_DETERMINE_PROJECT_STRUCTURE_EXCEPTION_MESSAGE =
"Unable to determine structure of project."
+ " Probably you use Maven Advanced Reactor Options with a broken tree of modules.";
private static final String MODULE_KEY = "sonar.moduleKey";
private static final String PROPERTY_PROJECT_BUILDDIR = "sonar.projectBuildDir";
private static final String JAVA_SOURCE_PROPERTY = "sonar.java.source";
private static final String JAVA_TARGET_PROPERTY = "sonar.java.target";
private static final String LINKS_HOME_PAGE = "sonar.links.homepage";
private static final String LINKS_CI = "sonar.links.ci";
private static final String LINKS_ISSUE_TRACKER = "sonar.links.issue";
private static final String LINKS_SOURCES = "sonar.links.scm";
private static final String LINKS_SOURCES_DEV = "sonar.links.scm_dev";
private static final String MAVEN_PACKAGING_POM = "pom";
private static final String MAVEN_PACKAGING_WAR = "war";
public static final String ARTIFACT_MAVEN_WAR_PLUGIN = "org.apache.maven.plugins:maven-war-plugin";
public static final String ARTIFACT_MAVEN_SUREFIRE_PLUGIN = "org.apache.maven.plugins:maven-surefire-plugin";
public static final String ARTIFACT_FINDBUGS_MAVEN_PLUGIN = "org.codehaus.mojo:findbugs-maven-plugin";
public static final String FINDBUGS_EXCLUDE_FILTERS = "sonar.findbugs.excludeFilters";
private static final String JAVA_PROJECT_MAIN_BINARY_DIRS = "sonar.java.binaries";
private static final String JAVA_PROJECT_MAIN_LIBRARIES = "sonar.java.libraries";
private static final String JAVA_PROJECT_TEST_BINARY_DIRS = "sonar.java.test.binaries";
private static final String JAVA_PROJECT_TEST_LIBRARIES = "sonar.java.test.libraries";
private static final String SUREFIRE_REPORTS_PATH_PROPERTY = "sonar.junit.reportsPath";
/**
* Optional paths to binaries, for example to declare the directory of Java bytecode. Example : "binDir"
*/
private static final String PROJECT_BINARY_DIRS = "sonar.binaries";
/**
* Optional comma-separated list of paths to libraries. Example :
* path/to/library/*.jar,path/to/specific/library/myLibrary.jar,parent/*.jar
*/
private static final String PROJECT_LIBRARIES = "sonar.libraries";
private Properties userProperties;
private DependencyCollector dependencyCollector;
public MavenProjectConverter( Log log, DependencyCollector dependencyCollector )
{
this.log = log;
this.dependencyCollector = dependencyCollector;
}
public Properties configure( List mavenProjects, MavenProject root, Properties userProperties )
throws MojoExecutionException
{
this.userProperties = userProperties;
Map propsByModule = new HashMap();
try
{
configureModules( mavenProjects, propsByModule );
Properties props = new Properties();
props.setProperty( ScanProperties.PROJECT_KEY, getSonarKey( root ) );
rebuildModuleHierarchy( props, propsByModule, root, "" );
if ( !propsByModule.isEmpty() )
{
throw new IllegalStateException( UNABLE_TO_DETERMINE_PROJECT_STRUCTURE_EXCEPTION_MESSAGE + " \""
+ propsByModule.keySet().iterator().next().getName() + "\" is orphan" );
}
return props;
}
catch ( IOException e )
{
throw new IllegalStateException( "Cannot configure project", e );
}
}
private void rebuildModuleHierarchy( Properties properties, Map propsByModule,
MavenProject current, String prefix )
throws IOException
{
Properties currentProps = propsByModule.get( current );
if ( currentProps == null )
{
throw new IllegalStateException( UNABLE_TO_DETERMINE_PROJECT_STRUCTURE_EXCEPTION_MESSAGE );
}
for ( Map.Entry