@@ -1,51 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>org.sonarsource.sonarqube</groupId> | |||
<artifactId>sonarqube</artifactId> | |||
<version>5.3-SNAPSHOT</version> | |||
<relativePath>../..</relativePath> | |||
</parent> | |||
<artifactId>sonar-batch-maven-plugin</artifactId> | |||
<name>SonarQube :: Batch Maven Plugin</name> | |||
<packaging>sonar-plugin</packaging> | |||
<description>Inject MavenProject in each module.</description> | |||
<dependencies> | |||
<dependency> | |||
<groupId>com.google.code.findbugs</groupId> | |||
<artifactId>jsr305</artifactId> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>sonar-plugin-api</artifactId> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-core</artifactId> | |||
<version>3.0</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
</dependencies> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId> | |||
<artifactId>sonar-packaging-maven-plugin</artifactId> | |||
<configuration> | |||
<pluginKey>mavenbatch</pluginKey> | |||
<pluginName>Maven Batch</pluginName> | |||
<pluginClass>org.sonar.plugins.batch.maven.MavenBatchPlugin</pluginClass> | |||
<pluginDescription> | |||
<![CDATA[Inject MavenProject in each module.]]></pluginDescription> | |||
</configuration> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</project> |
@@ -1,34 +0,0 @@ | |||
/* | |||
* 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.sonar.plugins.batch.maven; | |||
import org.sonar.api.SonarPlugin; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
public class MavenBatchPlugin extends SonarPlugin { | |||
@Override | |||
public List getExtensions() { | |||
return Arrays.asList(MavenProjectBuilder.class); | |||
} | |||
} |
@@ -1,64 +0,0 @@ | |||
/* | |||
* 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.sonar.plugins.batch.maven; | |||
import org.apache.maven.execution.MavenSession; | |||
import org.apache.maven.project.MavenProject; | |||
import org.sonar.api.batch.SupportedEnvironment; | |||
import org.sonar.api.batch.bootstrap.ProjectBuilder; | |||
import org.sonar.api.batch.bootstrap.ProjectDefinition; | |||
import org.sonar.api.batch.bootstrap.ProjectReactor; | |||
import java.util.List; | |||
/** | |||
* Class that inject MavenProject in each module container | |||
*/ | |||
@SupportedEnvironment("maven") | |||
public class MavenProjectBuilder extends ProjectBuilder { | |||
private final MavenSession mavenSession; | |||
public MavenProjectBuilder(MavenSession mavenSession) { | |||
this.mavenSession = mavenSession; | |||
} | |||
@Override | |||
public void build(Context context) { | |||
ProjectReactor reactor = context.projectReactor(); | |||
for (ProjectDefinition moduleDef : reactor.getProjects()) { | |||
setMavenProjectIfApplicable(moduleDef); | |||
} | |||
} | |||
private void setMavenProjectIfApplicable(ProjectDefinition definition) { | |||
if (mavenSession != null) { | |||
String moduleKey = definition.getKey(); | |||
for (MavenProject mavenModule : (List<MavenProject>) mavenSession.getProjects()) { | |||
// FIXME assumption that moduleKey was not modified by user and follow convention <groupId>:<artifactId> | |||
String mavenModuleKey = mavenModule.getGroupId() + ":" + mavenModule.getArtifactId(); | |||
if (mavenModuleKey.equals(moduleKey) && !definition.getContainerExtensions().contains(mavenModule)) { | |||
definition.addContainerExtension(mavenModule); | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -28,7 +28,6 @@ | |||
<module>sonar-ws</module> | |||
<module>sonar-testing-harness</module> | |||
<module>plugins/sonar-xoo-plugin</module> | |||
<module>plugins/sonar-batch-maven-plugin</module> | |||
</modules> | |||
<organization> | |||
@@ -831,16 +830,6 @@ | |||
</exclusion> | |||
</exclusions> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-artifact</artifactId> | |||
<version>2.0.7</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.maven</groupId> | |||
<artifactId>maven-core</artifactId> | |||
<version>2.0.7</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.ibm.icu</groupId> | |||
<artifactId>icu4j</artifactId> |
@@ -112,7 +112,6 @@ public class ModuleScanContainer extends ComponentContainer { | |||
SensorsExecutor.class, | |||
InitializersExecutor.class, | |||
ProjectInitializer.class, | |||
moduleDefinition.getContainerExtensions(), | |||
// file system | |||
ModuleInputFileCache.class, |
@@ -83,7 +83,6 @@ public class ProjectDefinition { | |||
private Map<String, String> properties = new HashMap<>(); | |||
private ProjectDefinition parent = null; | |||
private List<ProjectDefinition> subProjects = new ArrayList<>(); | |||
private List<Object> containerExtensions = new ArrayList<>(); | |||
private ProjectDefinition(Properties p) { | |||
for (Entry<Object, Object> entry : p.entrySet()) { | |||
@@ -124,7 +123,7 @@ public class ProjectDefinition { | |||
return workDir; | |||
} | |||
public ProjectDefinition setBuildDir( File d) { | |||
public ProjectDefinition setBuildDir(File d) { | |||
this.buildDir = d; | |||
return this; | |||
} | |||
@@ -553,23 +552,6 @@ public class ProjectDefinition { | |||
appendProperty(LIBRARIES_PROPERTY, path); | |||
} | |||
/** | |||
* Adds an extension, which would be available in PicoContainer during analysis of this project. | |||
* | |||
* @since 2.8 | |||
*/ | |||
public ProjectDefinition addContainerExtension(Object extension) { | |||
containerExtensions.add(extension); | |||
return this; | |||
} | |||
/** | |||
* @since 2.8 | |||
*/ | |||
public List<Object> getContainerExtensions() { | |||
return containerExtensions; | |||
} | |||
/** | |||
* @since 2.8 | |||
*/ |