diff options
author | Godin <mandrikov@gmail.com> | 2010-10-14 14:05:35 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-10-14 14:05:35 +0000 |
commit | 8d25f123f2be6e03920839bd12fe185e89681f05 (patch) | |
tree | f64042793b97ee74204451eba1c827df9257e9eb /subprojects | |
parent | 83d74b1e458a56676d11f7d13bd3866cac35f9bc (diff) | |
download | sonarqube-8d25f123f2be6e03920839bd12fe185e89681f05.tar.gz sonarqube-8d25f123f2be6e03920839bd12fe185e89681f05.zip |
SONAR-1858: Do not package sonar-plugin dependencies
Diffstat (limited to 'subprojects')
5 files changed, 101 insertions, 4 deletions
diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/pom.xml index 1a7f33029d3..f1f85f33acc 100644 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/pom.xml +++ b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/pom.xml @@ -113,7 +113,7 @@ </goals> <settingsFile>src/it/settings.xml</settingsFile> <filterProperties> - <sonar.version>2.2</sonar.version> + <sonar.version>2.3-SNAPSHOT</sonar.version> </filterProperties> <!--<debug>true</debug>--> </configuration> diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageSonarPlugins/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageSonarPlugins/pom.xml new file mode 100644 index 00000000000..6551681e312 --- /dev/null +++ b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageSonarPlugins/pom.xml @@ -0,0 +1,45 @@ +<?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/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.codehaus.sonar</groupId> + <artifactId>test</artifactId> + <version>1.0</version> + <packaging>sonar-plugin</packaging> + + <name>Do not package sonar-plugin dependencies</name> + + <dependencies> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-plugin-api</artifactId> + <version>@sonar.version@</version> + </dependency> + <dependency> + <groupId>org.codehaus.sonar.plugins</groupId> + <artifactId>sonar-surefire-plugin</artifactId> + <version>@sonar.version@</version> + <type>sonar-plugin</type> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>@project.groupId@</groupId> + <artifactId>@project.artifactId@</artifactId> + <version>@project.version@</version> + <extensions>true</extensions> + <configuration> + <pluginClass>org.sonar.plugins.sample.SamplePlugin</pluginClass> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.1</version> + </plugin> + </plugins> + </build> +</project> diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageSonarPlugins/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageSonarPlugins/src/main/java/org/sonar/plugins/sample/SamplePlugin.java new file mode 100644 index 00000000000..31710c3a0e6 --- /dev/null +++ b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageSonarPlugins/src/main/java/org/sonar/plugins/sample/SamplePlugin.java @@ -0,0 +1,30 @@ +package org.sonar.plugins.sample; + +import org.sonar.api.Extension; +import org.sonar.api.Plugin; + +import java.util.Collections; +import java.util.List; + +public class SamplePlugin implements Plugin { + public String getKey() { + return "sample"; + } + + public String getName() { + return "My first Sonar plugin"; + } + + public String getDescription() { + return "You shouldn't expect too much from this plugin."; + } + + public List<Class<? extends Extension>> getExtensions() { + return Collections.emptyList(); + } + + @Override + public String toString() { + return getKey(); + } +} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageSonarPlugins/verify.bsh b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageSonarPlugins/verify.bsh new file mode 100644 index 00000000000..5dff69c1fe2 --- /dev/null +++ b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageSonarPlugins/verify.bsh @@ -0,0 +1,16 @@ +import java.io.*; +import java.util.zip.*; + +File file = new File( basedir, "target/test-1.0.jar" ); +if (!file.isFile()) { + throw new FileNotFoundException( "Could not find generated JAR: " + file ); +} + +ZipFile zipFile = new ZipFile(file); +try { + if (zipFile.getEntry("META-INF/lib/")!=null) { + throw new FileNotFoundException("The dependency sonar-surefire-plugin must not be copied in the plugin"); + } +} finally { + zipFile.close(); +} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/java/org/sonar/updatecenter/mavenplugin/SonarPluginMojo.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/java/org/sonar/updatecenter/mavenplugin/SonarPluginMojo.java index 2e54d0d2de4..67fa2efa6fc 100644 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/java/org/sonar/updatecenter/mavenplugin/SonarPluginMojo.java +++ b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/java/org/sonar/updatecenter/mavenplugin/SonarPluginMojo.java @@ -272,14 +272,20 @@ public class SonarPluginMojo extends AbstractSonarPluginMojo { return artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getArtifactHandler().getExtension(); } - private Set<Artifact> getNotProvidedDependencies() throws DependencyTreeBuilderException { Set<Artifact> result = new HashSet<Artifact>(); Set<Artifact> providedArtifacts = getSonarProvidedArtifacts(); for (Artifact artifact : getIncludedArtifacts()) { - if (!Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !Artifact.SCOPE_TEST.equals(artifact.getScope()) && !containsArtifact(providedArtifacts, artifact)) { - result.add(artifact); + if ("sonar-plugin".equals(artifact.getType())) { + continue; + } + if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) || Artifact.SCOPE_TEST.equals(artifact.getScope())) { + continue; + } + if (containsArtifact(providedArtifacts, artifact)) { + continue; } + result.add(artifact); } return result; } |