From: Simon Brandhof Date: Wed, 5 Jan 2011 20:14:34 +0000 (+0100) Subject: move sonar-update-center to its own repository X-Git-Tag: 2.6~187 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=087912484909313036923f8cd76e9a2e0734e839;p=sonarqube.git move sonar-update-center to its own repository --- diff --git a/subprojects/sonar-update-center/pom.xml b/subprojects/sonar-update-center/pom.xml deleted file mode 100644 index e541740eee5..00000000000 --- a/subprojects/sonar-update-center/pom.xml +++ /dev/null @@ -1,347 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - sonar-update-center - 1.1-SNAPSHOT - pom - Sonar :: Update Center - http://www.sonarsource.org - 2010 - - - SonarSource - http://www.sonarsource.com - - - - - LGPL v.3 - http://www.gnu.org/licenses/lgpl.txt - repo - - - - - - simon.brandhof - Simon Brandhof - simon.brandhof@sonarsource.com - SonarSource - - developer - - +1 - - - godin - Evgeny Mandrikov - evgeny.mandrikov@sonarsource.com - SonarSource - - developer - - +3 - - - - - sonar-update-center-common - sonar-update-center-server - sonar-packaging-maven-plugin - - - - scm:svn:http://svn.codehaus.org/sonar/trunk/subprojects/sonar-update-center - scm:svn:https://svn.codehaus.org/sonar/trunk/subprojects/sonar-update-center - https://svn.codehaus.org/sonar/trunk/subprojects/sonar-update-center - - - - jira - http://jira.codehaus.org/browse/SONAR - - - - bamboo - http://ci.codehaus.org/browse/SONAR-UPD - - - - - codehaus.org - dav:https://dav.codehaus.org/repository/sonar - false - - - codehaus.org - dav:https://dav.codehaus.org/snapshots.repository/sonar - false - - - - - UTF-8 - 2.0 - 1.5 - - - - - - org.codehaus.sonar - sonar-update-center-common - ${project.version} - - - commons-io - commons-io - 1.4 - - - commons-lang - commons-lang - 2.5 - - - com.thoughtworks.xstream - xstream - 1.3.1 - - - xpp3 - xpp3_min - - - - - org.slf4j - slf4j-api - 1.5.6 - - - xpp3 - xpp3 - 1.1.3.3 - - - junit - junit - 4.8.2 - - - org.hamcrest - hamcrest-all - 1.1 - - - - - - - - - - org.apache.maven.plugins - maven-clean-plugin - 2.4.1 - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - - org.apache.maven.plugins - maven-dependency-plugin - 2.1 - - - org.apache.maven.plugins - maven-deploy-plugin - 2.5 - - - org.apache.maven.plugins - maven-enforcer-plugin - 1.0-beta-1 - - - org.codehaus.mojo - exec-maven-plugin - 1.1 - - - org.apache.maven.plugins - maven-install-plugin - 2.3.1 - - - org.apache.maven.plugins - maven-invoker-plugin - 1.5 - - - org.apache.maven.plugins - maven-jar-plugin - 2.3.1 - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.6.1 - - - org.apache.maven.plugins - maven-jxr-plugin - 2.1 - - - org.apache.maven.plugins - maven-plugin-plugin - 2.6 - - - org.apache.maven.plugin-tools - maven-plugin-tools-ant - 2.5.1 - - - - - org.apache.maven.plugins - maven-release-plugin - 2.0 - - - org.apache.maven.plugins - maven-resources-plugin - 2.4.3 - - - org.apache.maven.plugins - maven-site-plugin - 2.0-beta-7 - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - org.apache.maven.plugins - maven-surefire-plugin - 2.6 - - - org.codehaus.mojo - wagon-maven-plugin - 1.0-beta-3 - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce - - enforce - - - - - To build this project Maven ${maven.min.version} (or upper) is required. Please install it. - - ${maven.min.version} - - - To build this project JDK ${jdk.min.version} (or upper) is required. Please install it. - - ${jdk.min.version} - - - - Build reproducibility : always define plugin versions - true - true - clean,deploy - - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${jdk.min.version} - ${jdk.min.version} - ${project.build.sourceEncoding} - - - - - org.codehaus.mojo - animal-sniffer-maven-plugin - 1.6 - - - check-java-version - verify - - check - - - - org.codehaus.mojo.signature - java15 - 1.0 - - - - - - - - org.apache.maven.plugins - maven-release-plugin - - https://svn.codehaus.org/sonar/tags - true - - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - verify - - jar - - - - - - - - \ No newline at end of file diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/pom.xml deleted file mode 100644 index c67d4007c4d..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/pom.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - 4.0.0 - - - org.codehaus.sonar - sonar-update-center - 1.1-SNAPSHOT - - sonar-packaging-maven-plugin - maven-plugin - Sonar :: Update Center :: Maven Plugin - - - 2.0.9 - - - - - org.codehaus.sonar - sonar-update-center-common - - - - - org.apache.maven - maven-archiver - 2.4.1 - - - org.apache.maven - maven-artifact - ${mavenVersion} - - - org.apache.maven - maven-project - ${mavenVersion} - - - org.apache.maven - maven-model - ${mavenVersion} - - - org.apache.maven - maven-plugin-api - ${mavenVersion} - - - org.apache.maven.shared - maven-dependency-tree - 1.2 - - - - - org.codehaus.plexus - plexus-utils - 2.0.5 - - - - - junit - junit - test - - - org.hamcrest - hamcrest-all - test - - - - - - - org.apache.maven.plugins - maven-plugin-plugin - - - generated-helpmojo - - helpmojo - - - - - - - - - - run-its - - - - org.apache.maven.plugins - maven-invoker-plugin - - src/it - ${project.build.directory}/it - - */pom.xml - - verify - ${project.build.directory}/local-repo - - clean - install - - src/it/settings.xml - - 2.4 - - - - - - integration-test - - install - run - - - - - - - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/invoker.properties b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/invoker.properties deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/pom.xml deleted file mode 100644 index 6de43833c2a..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - test - 1.0 - sonar-plugin - - Basic - Plugin description. - http://sonar-plugins.codehaus.org - - SonarSource - http://www.sonarsource.com - - - - @sonar.version@ - - - test - - Test Plugin - Test - org.sonar.plugins.sample.SamplePlugin - - - - - org.codehaus.sonar - sonar-plugin-api - ${sonar.version} - - - - - org.codehaus.sonar - sonar-testing-harness - ${sonar.version} - test - - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - true - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/src/main/java/org/sonar/plugins/sample/SampleMetrics.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/src/main/java/org/sonar/plugins/sample/SampleMetrics.java deleted file mode 100644 index f5481527763..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/src/main/java/org/sonar/plugins/sample/SampleMetrics.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.sonar.plugins.sample; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.measures.Metric; -import org.sonar.api.measures.Metrics; - -import java.util.Arrays; -import java.util.List; - -public class SampleMetrics implements Metrics { - - public static final Metric MESSAGE = new Metric("message_key", "Message", - "This is a metric to store a well known message", Metric.ValueType.STRING, -1, false, - CoreMetrics.DOMAIN_GENERAL); - - - public static final Metric RANDOM = new Metric("random", "Random", - "Random value", Metric.ValueType.FLOAT, Metric.DIRECTION_BETTER, false, - CoreMetrics.DOMAIN_GENERAL); - - // getMetrics() method is defined in the Metrics interface and is used by - // Sonar to retrieve the list of new Metric - public List getMetrics() { - return Arrays.asList(MESSAGE, RANDOM); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/src/main/java/org/sonar/plugins/sample/SamplePlugin.java deleted file mode 100644 index adabe49c0bf..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/src/main/java/org/sonar/plugins/sample/SamplePlugin.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.sonar.plugins.sample; - -import org.sonar.api.Extension; -import org.sonar.api.Plugin; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class is the container for all others extensions - */ -public class SamplePlugin implements Plugin { - - // The key which uniquely identifies your plugin among all others Sonar plugins - - public String getKey() { - return "sample"; - } - - public String getName() { - return "My first Sonar plugin"; - } - - // This description will be displayed in the Configuration > Settings web page - - public String getDescription() { - return "You shouldn't expect too much from this plugin except displaying the Hello World message."; - } - - // This is where you're going to declare all your Sonar extensions - - public List> getExtensions() { - List> list = new ArrayList>(); - - list.add(SampleMetrics.class); - list.add(SampleSensor.class); - - return list; - } - - @Override - public String toString() { - return getKey(); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/src/main/java/org/sonar/plugins/sample/SampleSensor.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/src/main/java/org/sonar/plugins/sample/SampleSensor.java deleted file mode 100644 index 6e0deb74656..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/src/main/java/org/sonar/plugins/sample/SampleSensor.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.sonar.plugins.sample; - -import org.apache.commons.lang.math.RandomUtils; -import org.sonar.api.batch.Sensor; -import org.sonar.api.batch.SensorContext; -import org.sonar.api.measures.Measure; -import org.sonar.api.resources.Project; - -public class SampleSensor implements Sensor { - - public boolean shouldExecuteOnProject(Project project) { - // this sensor is executed on any type of project - return true; - } - - public void analyse(Project project, SensorContext sensorContext) { - saveLabelMeasure(sensorContext); - saveNumericMeasure(sensorContext); - } - - private void saveNumericMeasure(SensorContext context) { - // Sonar API includes many libraries like commons-lang and google-collections - context.saveMeasure(SampleMetrics.RANDOM, RandomUtils.nextDouble()); - } - - private void saveLabelMeasure(SensorContext context) { - Measure measure = new Measure(SampleMetrics.MESSAGE, "Hello World!"); - context.saveMeasure(measure); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/verify.bsh b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/verify.bsh deleted file mode 100644 index 6e3cd1b3f83..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/basic/verify.bsh +++ /dev/null @@ -1,7 +0,0 @@ -import java.io.*; - -File file = new File( basedir, "target/test-1.0.jar" ); -if ( !file.isFile() ) -{ - throw new FileNotFoundException( "Could not find generated JAR: " + file ); -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotAddMavenDescriptor/invoker.properties b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotAddMavenDescriptor/invoker.properties deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotAddMavenDescriptor/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotAddMavenDescriptor/pom.xml deleted file mode 100644 index 85b4cc9e2a0..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotAddMavenDescriptor/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - test - 1.0 - sonar-plugin - - Do Not Add Maven Description - - - @sonar.version@ - test - org.sonar.plugins.sample.SamplePlugin - - - - - org.codehaus.sonar - sonar-plugin-api - ${sonar.version} - provided - - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - true - - false - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotAddMavenDescriptor/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotAddMavenDescriptor/src/main/java/org/sonar/plugins/sample/SamplePlugin.java deleted file mode 100644 index 31710c3a0e6..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotAddMavenDescriptor/src/main/java/org/sonar/plugins/sample/SamplePlugin.java +++ /dev/null @@ -1,30 +0,0 @@ -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> getExtensions() { - return Collections.emptyList(); - } - - @Override - public String toString() { - return getKey(); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotAddMavenDescriptor/verify.bsh b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotAddMavenDescriptor/verify.bsh deleted file mode 100644 index 2b40c0dc268..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotAddMavenDescriptor/verify.bsh +++ /dev/null @@ -1,22 +0,0 @@ -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/MANIFEST.MF")==null) { - throw new FileNotFoundException("Could not find manifest"); - } - if (zipFile.getEntry("META-INF/maven/org.codehaus.sonar/test/pom.xml")!=null) { - throw new FileNotFoundException("The maven descriptor (pom.xml) has not been removed"); - } - if (zipFile.getEntry("META-INF/maven/org.codehaus.sonar/test/pom.properties")!=null) { - throw new FileNotFoundException("The maven descriptor (pom.properties) has not been removed"); - } -} finally { - zipFile.close(); -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageDepsProvidedBySonar/invoker.properties b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageDepsProvidedBySonar/invoker.properties deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageDepsProvidedBySonar/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageDepsProvidedBySonar/pom.xml deleted file mode 100644 index d5bc5d26660..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageDepsProvidedBySonar/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - test - 1.0 - sonar-plugin - - Do not package dependencies provided by Sonar - - - - org.codehaus.sonar - sonar-plugin-api - @sonar.version@ - - - commons-lang - commons-lang - 2.5 - - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - true - - org.sonar.plugins.sample.SamplePlugin - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageDepsProvidedBySonar/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageDepsProvidedBySonar/src/main/java/org/sonar/plugins/sample/SamplePlugin.java deleted file mode 100644 index 31710c3a0e6..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageDepsProvidedBySonar/src/main/java/org/sonar/plugins/sample/SamplePlugin.java +++ /dev/null @@ -1,30 +0,0 @@ -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> getExtensions() { - return Collections.emptyList(); - } - - @Override - public String toString() { - return getKey(); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageDepsProvidedBySonar/verify.bsh b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageDepsProvidedBySonar/verify.bsh deleted file mode 100644 index f451481ac5f..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageDepsProvidedBySonar/verify.bsh +++ /dev/null @@ -1,16 +0,0 @@ -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/commons-lang-2.5.jar")!=null) { - throw new FileNotFoundException("The dependency commons-lang must not be copied in the plugin"); - } -} finally { - zipFile.close(); -} 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 deleted file mode 100644 index 6551681e312..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageSonarPlugins/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - test - 1.0 - sonar-plugin - - Do not package sonar-plugin dependencies - - - - org.codehaus.sonar - sonar-plugin-api - @sonar.version@ - - - org.codehaus.sonar.plugins - sonar-surefire-plugin - @sonar.version@ - sonar-plugin - - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - true - - org.sonar.plugins.sample.SamplePlugin - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - - 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 deleted file mode 100644 index 31710c3a0e6..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageSonarPlugins/src/main/java/org/sonar/plugins/sample/SamplePlugin.java +++ /dev/null @@ -1,30 +0,0 @@ -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> 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 deleted file mode 100644 index 5dff69c1fe2..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/doNotPackageSonarPlugins/verify.bsh +++ /dev/null @@ -1,16 +0,0 @@ -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/it/extractPluginKeyFromArtifactId/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/pom.xml deleted file mode 100644 index 1ea50bd814c..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - sonar-it-extract-plugin-key-plugin - 1.0 - sonar-plugin - Package dependencies - - - - org.codehaus.sonar - sonar-plugin-api - @sonar.version@ - - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - true - - org.sonar.plugins.sample.SamplePlugin - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/src/main/java/org/sonar/plugins/sample/SamplePlugin.java deleted file mode 100644 index 31710c3a0e6..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/src/main/java/org/sonar/plugins/sample/SamplePlugin.java +++ /dev/null @@ -1,30 +0,0 @@ -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> getExtensions() { - return Collections.emptyList(); - } - - @Override - public String toString() { - return getKey(); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/verify.bsh b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/verify.bsh deleted file mode 100644 index 683a784d2c7..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/extractPluginKeyFromArtifactId/verify.bsh +++ /dev/null @@ -1,23 +0,0 @@ -import java.io.*; -import java.util.zip.*; -import java.util.jar.Manifest; - -File file = new File( basedir, "target/sonar-it-extract-plugin-key-plugin-1.0.jar" ); -if ( !file.isFile() ) -{ - throw new FileNotFoundException( "Could not find generated JAR: " + file ); -} - -ZipFile zipFile = new ZipFile(file); -InputStream input = null; -try { - input = zipFile.getInputStream(zipFile.getEntry("META-INF/MANIFEST.MF")); - Manifest manifest = new Manifest(input); - String key = manifest.getMainAttributes().getValue("Plugin-Key"); - if (!key.equals("itextractpluginkey")) { - throw new Exception("Plugin key is not valid: " + key); - } -} finally { - zipFile.close(); - input.close(); -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/failIfBadlyFormattedPluginKey/invoker.properties b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/failIfBadlyFormattedPluginKey/invoker.properties deleted file mode 100644 index c21e972fc6b..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/failIfBadlyFormattedPluginKey/invoker.properties +++ /dev/null @@ -1 +0,0 @@ -invoker.buildResult = failure diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/failIfBadlyFormattedPluginKey/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/failIfBadlyFormattedPluginKey/pom.xml deleted file mode 100644 index 23055892a53..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/failIfBadlyFormattedPluginKey/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - test - 1.0 - sonar-plugin - Package dependencies - - - - org.codehaus.sonar - sonar-plugin-api - @sonar.version@ - - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - true - - key-with.bad%characters - org.sonar.plugins.sample.SamplePlugin - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/failIfBadlyFormattedPluginKey/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/failIfBadlyFormattedPluginKey/src/main/java/org/sonar/plugins/sample/SamplePlugin.java deleted file mode 100644 index 31710c3a0e6..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/failIfBadlyFormattedPluginKey/src/main/java/org/sonar/plugins/sample/SamplePlugin.java +++ /dev/null @@ -1,30 +0,0 @@ -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> getExtensions() { - return Collections.emptyList(); - } - - @Override - public String toString() { - return getKey(); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/overridenPluginKey/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/overridenPluginKey/pom.xml deleted file mode 100644 index 71741bbcaac..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/overridenPluginKey/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - test - 1.0 - sonar-plugin - Package dependencies - - - - org.codehaus.sonar - sonar-plugin-api - @sonar.version@ - - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - true - - newkey - org.sonar.plugins.sample.SamplePlugin - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/overridenPluginKey/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/overridenPluginKey/src/main/java/org/sonar/plugins/sample/SamplePlugin.java deleted file mode 100644 index 31710c3a0e6..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/overridenPluginKey/src/main/java/org/sonar/plugins/sample/SamplePlugin.java +++ /dev/null @@ -1,30 +0,0 @@ -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> getExtensions() { - return Collections.emptyList(); - } - - @Override - public String toString() { - return getKey(); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/overridenPluginKey/verify.bsh b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/overridenPluginKey/verify.bsh deleted file mode 100644 index 416c8e1f5de..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/overridenPluginKey/verify.bsh +++ /dev/null @@ -1,23 +0,0 @@ -import java.io.*; -import java.util.zip.*; -import java.util.jar.Manifest; - -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); -InputStream input = null; -try { - input = zipFile.getInputStream(zipFile.getEntry("META-INF/MANIFEST.MF")); - Manifest manifest = new Manifest(input); - String key = manifest.getMainAttributes().getValue("Plugin-Key"); - if (!key.equals("newkey")) { - throw new Exception("Plugin key is not valid: " + key); - } -} finally { - zipFile.close(); - input.close(); -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDependencies/invoker.properties b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDependencies/invoker.properties deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDependencies/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDependencies/pom.xml deleted file mode 100644 index 58577712ce8..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDependencies/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - test - 1.0 - sonar-plugin - Package dependencies - - - - org.codehaus.sonar - sonar-plugin-api - @sonar.version@ - - - - - org.apache.commons - commons-email - 1.2 - - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - true - - org.sonar.plugins.sample.SamplePlugin - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDependencies/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDependencies/src/main/java/org/sonar/plugins/sample/SamplePlugin.java deleted file mode 100644 index 31710c3a0e6..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDependencies/src/main/java/org/sonar/plugins/sample/SamplePlugin.java +++ /dev/null @@ -1,30 +0,0 @@ -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> getExtensions() { - return Collections.emptyList(); - } - - @Override - public String toString() { - return getKey(); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDependencies/verify.bsh b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDependencies/verify.bsh deleted file mode 100644 index 5715c00b23a..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDependencies/verify.bsh +++ /dev/null @@ -1,17 +0,0 @@ -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/commons-email-1.2.jar")==null) { - throw new FileNotFoundException("The dependency commons-email must be copied in JAR"); - } -} finally { - zipFile.close(); -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDepsExcludedFromApi/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDepsExcludedFromApi/pom.xml deleted file mode 100644 index 3e530f4e52b..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDepsExcludedFromApi/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - test - 1.0 - sonar-plugin - Package dependencies - - - - org.codehaus.sonar - sonar-plugin-api - @sonar.version@ - - - org.codehaus.plexus - plexus-utils - - - - - - - org.codehaus.plexus - plexus-utils - 1.5.6 - - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - true - - org.sonar.plugins.sample.SamplePlugin - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDepsExcludedFromApi/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDepsExcludedFromApi/src/main/java/org/sonar/plugins/sample/SamplePlugin.java deleted file mode 100644 index 31710c3a0e6..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDepsExcludedFromApi/src/main/java/org/sonar/plugins/sample/SamplePlugin.java +++ /dev/null @@ -1,30 +0,0 @@ -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> getExtensions() { - return Collections.emptyList(); - } - - @Override - public String toString() { - return getKey(); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDepsExcludedFromApi/verify.bsh b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDepsExcludedFromApi/verify.bsh deleted file mode 100644 index 013d05fa6d5..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/packageDepsExcludedFromApi/verify.bsh +++ /dev/null @@ -1,17 +0,0 @@ -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/plexus-utils-1.5.6.jar")==null) { - throw new FileNotFoundException("The dependency plexus-utils must be copied in JAR"); - } -} finally { - zipFile.close(); -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/invoker.properties b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/invoker.properties deleted file mode 100644 index c21e972fc6b..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/invoker.properties +++ /dev/null @@ -1 +0,0 @@ -invoker.buildResult = failure diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/pom.xml deleted file mode 100644 index c2cdd2de188..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - test - 1.0 - sonar-plugin - - PluginClass not defined - - - - org.codehaus.sonar - sonar-plugin-api - @sonar.version@ - provided - - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - true - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/src/main/java/org/sonar/plugins/sample/SampleMetrics.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/src/main/java/org/sonar/plugins/sample/SampleMetrics.java deleted file mode 100644 index f5481527763..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/src/main/java/org/sonar/plugins/sample/SampleMetrics.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.sonar.plugins.sample; - -import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.measures.Metric; -import org.sonar.api.measures.Metrics; - -import java.util.Arrays; -import java.util.List; - -public class SampleMetrics implements Metrics { - - public static final Metric MESSAGE = new Metric("message_key", "Message", - "This is a metric to store a well known message", Metric.ValueType.STRING, -1, false, - CoreMetrics.DOMAIN_GENERAL); - - - public static final Metric RANDOM = new Metric("random", "Random", - "Random value", Metric.ValueType.FLOAT, Metric.DIRECTION_BETTER, false, - CoreMetrics.DOMAIN_GENERAL); - - // getMetrics() method is defined in the Metrics interface and is used by - // Sonar to retrieve the list of new Metric - public List getMetrics() { - return Arrays.asList(MESSAGE, RANDOM); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/src/main/java/org/sonar/plugins/sample/SamplePlugin.java deleted file mode 100644 index adabe49c0bf..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/src/main/java/org/sonar/plugins/sample/SamplePlugin.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.sonar.plugins.sample; - -import org.sonar.api.Extension; -import org.sonar.api.Plugin; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class is the container for all others extensions - */ -public class SamplePlugin implements Plugin { - - // The key which uniquely identifies your plugin among all others Sonar plugins - - public String getKey() { - return "sample"; - } - - public String getName() { - return "My first Sonar plugin"; - } - - // This description will be displayed in the Configuration > Settings web page - - public String getDescription() { - return "You shouldn't expect too much from this plugin except displaying the Hello World message."; - } - - // This is where you're going to declare all your Sonar extensions - - public List> getExtensions() { - List> list = new ArrayList>(); - - list.add(SampleMetrics.class); - list.add(SampleSensor.class); - - return list; - } - - @Override - public String toString() { - return getKey(); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/src/main/java/org/sonar/plugins/sample/SampleSensor.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/src/main/java/org/sonar/plugins/sample/SampleSensor.java deleted file mode 100644 index 6e0deb74656..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotDefined/src/main/java/org/sonar/plugins/sample/SampleSensor.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.sonar.plugins.sample; - -import org.apache.commons.lang.math.RandomUtils; -import org.sonar.api.batch.Sensor; -import org.sonar.api.batch.SensorContext; -import org.sonar.api.measures.Measure; -import org.sonar.api.resources.Project; - -public class SampleSensor implements Sensor { - - public boolean shouldExecuteOnProject(Project project) { - // this sensor is executed on any type of project - return true; - } - - public void analyse(Project project, SensorContext sensorContext) { - saveLabelMeasure(sensorContext); - saveNumericMeasure(sensorContext); - } - - private void saveNumericMeasure(SensorContext context) { - // Sonar API includes many libraries like commons-lang and google-collections - context.saveMeasure(SampleMetrics.RANDOM, RandomUtils.nextDouble()); - } - - private void saveLabelMeasure(SensorContext context) { - Measure measure = new Measure(SampleMetrics.MESSAGE, "Hello World!"); - context.saveMeasure(measure); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotFound/invoker.properties b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotFound/invoker.properties deleted file mode 100644 index c21e972fc6b..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotFound/invoker.properties +++ /dev/null @@ -1 +0,0 @@ -invoker.buildResult = failure diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotFound/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotFound/pom.xml deleted file mode 100644 index 7f8bcbdc85a..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/pluginClassNotFound/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - test - 1.0 - sonar-plugin - - PluginClass not found - - - - org.codehaus.sonar - sonar-plugin-api - @sonar.version@ - provided - - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - true - - org.sonar.plugins.sample.SamplePlugin - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/settings.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/settings.xml deleted file mode 100644 index 8890c85392c..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/settings.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - it-repo - - true - - - - local.central - @localRepositoryUrl@ - - true - - - true - - - - - - local.central - @localRepositoryUrl@ - - true - - - true - - - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/sonarPluginApiNotFound/invoker.properties b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/sonarPluginApiNotFound/invoker.properties deleted file mode 100644 index c21e972fc6b..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/sonarPluginApiNotFound/invoker.properties +++ /dev/null @@ -1 +0,0 @@ -invoker.buildResult = failure diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/sonarPluginApiNotFound/pom.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/sonarPluginApiNotFound/pom.xml deleted file mode 100644 index 344847b58bf..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/sonarPluginApiNotFound/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - - org.codehaus.sonar - test - 1.0 - sonar-plugin - - sonar-plugin-api not found - - - - - - - - - @project.groupId@ - @project.artifactId@ - @project.version@ - true - - org.sonar.plugins.sample.SamplePlugin - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.1 - - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/sonarPluginApiNotFound/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/sonarPluginApiNotFound/src/main/java/org/sonar/plugins/sample/SamplePlugin.java deleted file mode 100644 index 31710c3a0e6..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/it/sonarPluginApiNotFound/src/main/java/org/sonar/plugins/sample/SamplePlugin.java +++ /dev/null @@ -1,30 +0,0 @@ -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> getExtensions() { - return Collections.emptyList(); - } - - @Override - public String toString() { - return getKey(); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/java/org/sonar/updatecenter/mavenplugin/AbstractSonarPluginMojo.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/java/org/sonar/updatecenter/mavenplugin/AbstractSonarPluginMojo.java deleted file mode 100644 index 1ccbd835643..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/java/org/sonar/updatecenter/mavenplugin/AbstractSonarPluginMojo.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * 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.updatecenter.mavenplugin; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectHelper; - -import java.io.File; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * Base class for Sonar-plugin-packaging related tasks. - * - * @author Evgeny Mandrikov - */ -public abstract class AbstractSonarPluginMojo extends AbstractMojo { - - public static final String SONAR_GROUPID = "org.codehaus.sonar"; - public static final String SONAR_PLUGIN_API_ARTIFACTID = "sonar-plugin-api"; - public static final String SONAR_PLUGIN_API_TYPE = "jar"; - - /** - * The Maven project. - * - * @parameter expression="${project}" - * @required - * @readonly - */ - private MavenProject project; - - /** - * Directory containing the generated JAR. - * - * @parameter expression="${project.build.directory}" - * @required - */ - private File outputDirectory; - - /** - * Directory containing the classes and resource files that should be packaged into the JAR. - * - * @parameter expression="${project.build.outputDirectory}" - * @required - */ - private File classesDirectory; - - /** - * The directory where the app is built. - * - * @parameter expression="${project.build.directory}/${project.build.finalName}" - * @required - */ - private File appDirectory; - - /** - * Name of the generated JAR. - * - * @parameter alias="jarName" expression="${jar.finalName}" default-value="${project.build.finalName}" - * @required - */ - private String finalName; - - /** - * Classifier to add to the artifact generated. If given, the artifact will be an attachment instead. - * - * @parameter - */ - private String classifier; - - /** - * @component - */ - protected MavenProjectHelper projectHelper; - - /** - * Plugin key. - * - * @parameter expression="${sonar.pluginKey}" - */ - protected String pluginKey; - - /** - * @parameter expression="${sonar.pluginTermsConditionsUrl}" - */ - private String pluginTermsConditionsUrl; - - /** - * Name of plugin class. - * - * @parameter expression="${sonar.pluginClass}" - * @required - */ - private String pluginClass; - - /** - * @parameter expression="${sonar.pluginName}" default-value="${project.name}" - */ - private String pluginName; - - /** - * @parameter default-value="${project.description}" - */ - private String pluginDescription; - - /** - * @parameter default-value="${project.url}" - */ - private String pluginUrl; - - /** - * @parameter default-value="${project.issueManagement.url}" - */ - private String pluginIssueTrackerUrl; - - /** - * @parameter - * @since 0.3 - */ - private boolean useChildFirstClassLoader = false; - - /** - * @parameter - */ - private String extendPlugin; - - /** - * @parameter expression="${sonar.skipDependenciesPackaging}" - */ - private boolean skipDependenciesPackaging = false; - - protected final MavenProject getProject() { - return project; - } - - protected final File getOutputDirectory() { - return outputDirectory; - } - - /** - * @return the main classes directory, so it's used as the root of the jar. - */ - protected final File getClassesDirectory() { - return classesDirectory; - } - - public File getAppDirectory() { - return appDirectory; - } - - protected final String getFinalName() { - return finalName; - } - - protected final String getClassifier() { - return classifier; - } - - public String getExplicitPluginKey() { - return pluginKey; - } - - protected final String getPluginClass() { - return pluginClass; - } - - protected final String getPluginName() { - return pluginName; - } - - protected final String getPluginDescription() { - return pluginDescription; - } - - protected final String getPluginUrl() { - return pluginUrl; - } - - protected String getPluginTermsConditionsUrl() { - return pluginTermsConditionsUrl; - } - - protected String getPluginIssueTrackerUrl() { - return pluginIssueTrackerUrl; - } - - public boolean isUseChildFirstClassLoader() { - return useChildFirstClassLoader; - } - - public String getExtendPlugin() { - return extendPlugin; - } - - protected boolean isSkipDependenciesPackaging() { - return skipDependenciesPackaging; - } - - @SuppressWarnings({ "unchecked" }) - protected Set getDependencyArtifacts() { - return getProject().getDependencyArtifacts(); - } - - protected Set getDependencyArtifacts(String scope) { - Set result = new HashSet(); - for (Artifact dep : getDependencyArtifacts()) { - if (scope.equals(dep.getScope())) { - result.add(dep); - } - } - return result; - } - - @SuppressWarnings({ "unchecked" }) - protected Set getIncludedArtifacts() { - Set result = new HashSet(); - Set artifacts = getProject().getArtifacts(); - ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME); - for (Artifact artifact : artifacts) { - if (filter.include(artifact)) { - result.add(artifact); - } - } - return result; - } - - protected final Artifact getSonarPluginApiArtifact() { - Set dependencies = getDependencyArtifacts(); - if (dependencies != null) { - for (Artifact dep : dependencies) { - if (SONAR_GROUPID.equals(dep.getGroupId()) && SONAR_PLUGIN_API_ARTIFACTID.equals(dep.getArtifactId()) - && SONAR_PLUGIN_API_TYPE.equals(dep.getType())) { - return dep; - } - } - } - return null; - } - - protected String getMessage(String title, List ids) { - StringBuilder message = new StringBuilder(); - message.append(title); - message.append("\n\n"); - for (String id : ids) { - message.append("\t").append(id).append("\n"); - } - return message.toString(); - } -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/java/org/sonar/updatecenter/mavenplugin/CheckDependenciesMojo.java b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/java/org/sonar/updatecenter/mavenplugin/CheckDependenciesMojo.java deleted file mode 100644 index 4ed7f1ab9bf..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/java/org/sonar/updatecenter/mavenplugin/CheckDependenciesMojo.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.updatecenter.mavenplugin; - -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Evgeny Mandrikov - * @goal check-dependencies - * @requiresDependencyResolution runtime - * @phase initialize - * @threadSafe - */ -public class CheckDependenciesMojo extends AbstractSonarPluginMojo { - - private static final String[] GWT_ARTIFACT_IDS = {"gwt-user", "gwt-dev", "sonar-gwt-api"}; - private static final String[] LOG_GROUP_IDS = {"log4j", "commons-logging"}; - - public void execute() throws MojoExecutionException, MojoFailureException { - if (!isSkipDependenciesPackaging()) { - checkApiDependency(); - checkLogDependencies(); - checkGwtDependencies(); - } - } - - private void checkApiDependency() throws MojoExecutionException { - Artifact sonarApi = getSonarPluginApiArtifact(); - - if (sonarApi == null) { - throw new MojoExecutionException( - SONAR_GROUPID + ":" + SONAR_PLUGIN_API_ARTIFACTID + " should be declared in dependencies" - ); - } - } - - private void checkLogDependencies() throws MojoExecutionException { - List ids = new ArrayList(); - for (Artifact dep : getIncludedArtifacts()) { - if (ArrayUtils.contains(LOG_GROUP_IDS, dep.getGroupId())) { - ids.add(dep.getDependencyConflictId()); - } - } - if (!ids.isEmpty()) { - StringBuilder message = new StringBuilder(); - message.append("Dependencies on the following log libraries should be excluded or declared with scope 'provided':") - .append("\n\t") - .append(StringUtils.join(ids, ", ")) - .append('\n'); - getLog().warn(message.toString()); - } - } - - private void checkGwtDependencies() { - List ids = new ArrayList(); - for (Artifact dep : getDependencyArtifacts(Artifact.SCOPE_COMPILE)) { - if (ArrayUtils.contains(GWT_ARTIFACT_IDS, dep.getArtifactId())) { - ids.add(dep.getDependencyConflictId()); - } - } - if (!ids.isEmpty()) { - getLog().warn(getMessage("GWT dependencies should be defined with scope 'provided':", ids)); - } - } -} 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 deleted file mode 100644 index 274c0d74b02..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/java/org/sonar/updatecenter/mavenplugin/SonarPluginMojo.java +++ /dev/null @@ -1,367 +0,0 @@ -/* - * 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.updatecenter.mavenplugin; - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiver.MavenArchiveConfiguration; -import org.apache.maven.archiver.MavenArchiver; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactCollector; -import org.apache.maven.artifact.resolver.filter.ArtifactFilter; -import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; -import org.apache.maven.model.License; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.shared.dependency.tree.DependencyNode; -import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; -import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; -import org.apache.maven.shared.dependency.tree.traversal.BuildingDependencyNodeVisitor; -import org.codehaus.plexus.archiver.jar.JarArchiver; -import org.codehaus.plexus.util.FileUtils; -import org.sonar.updatecenter.common.FormatUtils; -import org.sonar.updatecenter.common.PluginKeyUtils; -import org.sonar.updatecenter.common.PluginManifest; - -import java.io.File; -import java.io.IOException; -import java.util.*; - -/** - * Build a Sonar Plugin from the current project. - * - * @author Evgeny Mandrikov - * @goal sonar-plugin - * @phase package - * @requiresProject - * @requiresDependencyResolution runtime - * @threadSafe - */ -public class SonarPluginMojo extends AbstractSonarPluginMojo { - private static final String LIB_DIR = "META-INF/lib/"; - private static final String[] DEFAULT_EXCLUDES = new String[] { "**/package.html" }; - private static final String[] DEFAULT_INCLUDES = new String[] { "**/**" }; - - /** - * List of files to include. Specified as fileset patterns which are relative to the input directory whose contents - * is being packaged into the JAR. - * - * @parameter - */ - private String[] includes; - - /** - * List of files to exclude. Specified as fileset patterns which are relative to the input directory whose contents - * is being packaged into the JAR. - * - * @parameter - */ - private String[] excludes; - - /** - * The Jar archiver. - * - * @component role="org.codehaus.plexus.archiver.Archiver" role-hint="jar" - */ - protected JarArchiver jarArchiver; - - /** - * The archive configuration to use. - * See Maven Archiver Reference. - * - * @parameter - */ - private MavenArchiveConfiguration archive = new MavenArchiveConfiguration(); - - /** - * @component - * @required - * @readonly - */ - private DependencyTreeBuilder dependencyTreeBuilder; - - /** - * The artifact repository to use. - * - * @parameter expression="${localRepository}" - * @required - * @readonly - */ - private ArtifactRepository localRepository; - - /** - * The artifact factory to use. - * - * @component - * @required - * @readonly - */ - private ArtifactFactory artifactFactory; - - /** - * The artifact metadata source to use. - * - * @component - * @required - * @readonly - */ - private ArtifactMetadataSource artifactMetadataSource; - - /** - * The artifact collector to use. - * - * @component - * @required - * @readonly - */ - private ArtifactCollector artifactCollector; - - /** - * @parameter expression="${sonar.addMavenDescriptor}" - */ - private boolean addMavenDescriptor = true; - - public void execute() throws MojoExecutionException, MojoFailureException { - checkPluginKey(); - checkPluginClass(); - - File jarFile = createArchive(); - String classifier = getClassifier(); - if (classifier != null) { - projectHelper.attachArtifact(getProject(), "jar", classifier, jarFile); - } else { - getProject().getArtifact().setFile(jarFile); - } - } - - public File createArchive() throws MojoExecutionException { - File jarFile = getJarFile(getOutputDirectory(), getFinalName(), getClassifier()); - MavenArchiver archiver = new MavenArchiver(); - archiver.setArchiver(jarArchiver); - archiver.setOutputFile(jarFile); - - try { - archiver.getArchiver().addDirectory(getClassesDirectory(), getIncludes(), getExcludes()); - archive.setAddMavenDescriptor(addMavenDescriptor); - getLog().info("-------------------------------------------------------"); - getLog().info("Plugin definition in update center"); - addManifestProperty("Key", PluginManifest.KEY, getPluginKey()); - addManifestProperty("Name", PluginManifest.NAME, getPluginName()); - addManifestProperty("Description", PluginManifest.DESCRIPTION, getPluginDescription()); - addManifestProperty("Version", PluginManifest.VERSION, getProject().getVersion()); - addManifestProperty("Main class", PluginManifest.MAIN_CLASS, getPluginClass()); - addManifestProperty("Homepage", PluginManifest.HOMEPAGE, getPluginUrl()); - addManifestProperty("Sonar version", PluginManifest.SONAR_VERSION, getSonarPluginApiArtifact().getVersion()); - addManifestProperty("License", PluginManifest.LICENSE, getPluginLicense()); - addManifestProperty("Organization", PluginManifest.ORGANIZATION, getPluginOrganization()); - addManifestProperty("Organization URL", PluginManifest.ORGANIZATION_URL, getPluginOrganizationUrl()); - addManifestProperty("Terms & Conditions URL", PluginManifest.TERMS_CONDITIONS_URL, getPluginTermsConditionsUrl()); - addManifestProperty("Issue Tracker URL", PluginManifest.ISSUE_TRACKER_URL, getPluginIssueTrackerUrl()); - addManifestProperty("Build date", PluginManifest.BUILD_DATE, FormatUtils.toString(new Date(), true)); - getLog().info("-------------------------------------------------------"); - - if (isUseChildFirstClassLoader()) { - archive.addManifestEntry(PluginManifest.USE_CHILD_FIRST_CLASSLOADER, "true"); - } - - if (StringUtils.isNotBlank(getExtendPlugin())) { - archive.addManifestEntry(PluginManifest.EXTEND_PLUGIN, getExtendPlugin()); - } - - if (isSkipDependenciesPackaging()) { - getLog().info("Skip packaging of dependencies"); - - } else { - List libs = copyDependencies(); - if (!libs.isEmpty()) { - archiver.getArchiver().addDirectory(getAppDirectory(), getIncludes(), getExcludes()); - archive.addManifestEntry(PluginManifest.DEPENDENCIES, StringUtils.join(libs, " ")); - } - } - - archiver.createArchive(getProject(), archive); - return jarFile; - - } catch (Exception e) { - throw new MojoExecutionException("Error assembling Sonar-plugin: " + e.getMessage(), e); - } - } - - private void addManifestProperty(String label, String key, String value) { - getLog().info(" " + label + ": " + StringUtils.defaultString(value)); - archive.addManifestEntry(key, value); - } - - private String getPluginLicense() { - List licenses = new ArrayList(); - if (getProject().getLicenses() != null) { - for (Object license : getProject().getLicenses()) { - License l = (License) license; - if (l.getName() != null) { - licenses.add(l.getName()); - } - } - } - return StringUtils.join(licenses, " "); - } - - private String getPluginOrganization() { - if (getProject().getOrganization() != null) { - return getProject().getOrganization().getName(); - } - return null; - } - - private String getPluginOrganizationUrl() { - if (getProject().getOrganization() != null) { - return getProject().getOrganization().getUrl(); - } - return null; - } - - private void checkPluginKey() throws MojoExecutionException { - if (StringUtils.isNotBlank(getExplicitPluginKey()) && !PluginKeyUtils.isValid(getExplicitPluginKey())) { - throw new MojoExecutionException("Plugin key is badly formatted. Please use ascii letters and digits only. Value: " + getExplicitPluginKey()); - } - } - - private void checkPluginClass() throws MojoExecutionException { - if (!new File(getClassesDirectory(), getPluginClass().replace('.', '/') + ".class").exists()) { - throw new MojoExecutionException("Error assembling Sonar-plugin: Plugin-Class '" + getPluginClass() + "' not found"); - } - } - - private String getPluginKey() { - if (StringUtils.isNotBlank(getExplicitPluginKey())) { - return getExplicitPluginKey(); - } - return PluginKeyUtils.sanitize(getProject().getArtifactId()); - } - - protected static File getJarFile(File basedir, String finalName, String classifier) { - if (classifier == null) { - classifier = ""; - } else if (classifier.trim().length() > 0 && !classifier.startsWith("-")) { - classifier = "-" + classifier; - } - return new File(basedir, finalName + classifier + ".jar"); - } - - private List copyDependencies() throws IOException, DependencyTreeBuilderException { - List ids = new ArrayList(); - List libs = new ArrayList(); - File libDirectory = new File(getAppDirectory(), LIB_DIR); - Set artifacts = getNotProvidedDependencies(); - for (Artifact artifact : artifacts) { - String targetFileName = getDefaultFinalName(artifact); - FileUtils.copyFileIfModified(artifact.getFile(), new File(libDirectory, targetFileName)); - libs.add(LIB_DIR + targetFileName); - ids.add(artifact.getDependencyConflictId()); - } - - if (!ids.isEmpty()) { - getLog().info(getMessage("Following dependencies are packaged in the plugin:", ids)); - getLog().info(new StringBuilder() - .append("See following page for more details about plugin dependencies:\n") - .append("\n\thttp://docs.codehaus.org/display/SONAR/Coding+a+plugin\n") - .toString() - ); - } - return libs; - } - - private String getDefaultFinalName(Artifact artifact) { - return artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getArtifactHandler().getExtension(); - } - - private Set getNotProvidedDependencies() throws DependencyTreeBuilderException { - Set result = new HashSet(); - Set providedArtifacts = getSonarProvidedArtifacts(); - for (Artifact artifact : getIncludedArtifacts()) { - 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; - } - - private boolean containsArtifact(Set artifacts, Artifact artifact) { - for (Artifact a : artifacts) { - if (StringUtils.equals(a.getGroupId(), artifact.getGroupId()) && - StringUtils.equals(a.getArtifactId(), artifact.getArtifactId())) { - return true; - } - } - return false; - } - - private Set getSonarProvidedArtifacts() throws DependencyTreeBuilderException { - Set result = new HashSet(); - ArtifactFilter artifactFilter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME); - DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree(getProject(), localRepository, artifactFactory, - artifactMetadataSource, artifactFilter, artifactCollector); - rootNode.accept(new BuildingDependencyNodeVisitor()); - searchForSonarProvidedArtifacts(rootNode, result, false); - return result; - } - - private void searchForSonarProvidedArtifacts(DependencyNode dependency, Set sonarArtifacts, boolean isProvidedBySonar) { - if (dependency != null) { - // skip check on root node - see SONAR-1815 - if (dependency.getParent() != null) { - isProvidedBySonar = isProvidedBySonar || ("org.codehaus.sonar".equals(dependency.getArtifact().getGroupId()) && !Artifact.SCOPE_TEST.equals(dependency.getArtifact().getScope())); - } - - if (isProvidedBySonar) { - sonarArtifacts.add(dependency.getArtifact()); - } - - if (!Artifact.SCOPE_TEST.equals(dependency.getArtifact().getScope())) { - for (Object childDep : dependency.getChildren()) { - searchForSonarProvidedArtifacts((DependencyNode) childDep, sonarArtifacts, isProvidedBySonar); - } - } - } - } - - private String[] getIncludes() { - if (includes != null && includes.length > 0) { - return includes; - } - return DEFAULT_INCLUDES; - } - - private String[] getExcludes() { - if (excludes != null && excludes.length > 0) { - return excludes; - } - return DEFAULT_EXCLUDES; - } - -} diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/resources/META-INF/plexus/components.xml b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/resources/META-INF/plexus/components.xml deleted file mode 100644 index cd580be9914..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/resources/META-INF/plexus/components.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - org.apache.maven.lifecycle.mapping.LifecycleMapping - sonar-plugin - org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping - - - - default - - - org.codehaus.sonar:sonar-packaging-maven-plugin:check-dependencies - - org.apache.maven.plugins:maven-resources-plugin:resources - org.apache.maven.plugins:maven-compiler-plugin:compile - org.apache.maven.plugins:maven-resources-plugin:testResources - org.apache.maven.plugins:maven-compiler-plugin:testCompile - org.apache.maven.plugins:maven-surefire-plugin:test - - - org.codehaus.sonar:sonar-packaging-maven-plugin:sonar-plugin - - org.apache.maven.plugins:maven-install-plugin:install - org.apache.maven.plugins:maven-deploy-plugin:deploy - - - - - - - org.apache.maven.artifact.handler.ArtifactHandler - sonar-plugin - org.apache.maven.artifact.handler.DefaultArtifactHandler - - sonar-plugin - jar - java - true - - - - diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/resources/license/AL2.txt b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/resources/license/AL2.txt deleted file mode 100644 index 2550cc485b1..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/resources/license/AL2.txt +++ /dev/null @@ -1,14 +0,0 @@ -Copyright (C) ${year} ${name} -mailto: ${mail} - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/resources/license/LGPL3.txt b/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/resources/license/LGPL3.txt deleted file mode 100644 index e7f3cc3e5ad..00000000000 --- a/subprojects/sonar-update-center/sonar-packaging-maven-plugin/src/main/resources/license/LGPL3.txt +++ /dev/null @@ -1,17 +0,0 @@ -Sonar, open source software quality management tool. -Copyright (C) ${year} ${name} -mailto: ${mail} - -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 diff --git a/subprojects/sonar-update-center/sonar-update-center-common/pom.xml b/subprojects/sonar-update-center/sonar-update-center-common/pom.xml deleted file mode 100644 index 7d892a4876d..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - 4.0.0 - - - org.codehaus.sonar - sonar-update-center - 1.1-SNAPSHOT - - - sonar-update-center-common - Sonar :: Update Center :: Common - - - - commons-lang - commons-lang - - - commons-io - commons-io - - - - - junit - junit - test - - - org.hamcrest - hamcrest-all - test - - - diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Artifact.java b/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Artifact.java deleted file mode 100644 index 0043705db60..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Artifact.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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.updatecenter.common; - -import java.util.*; - -public abstract class Artifact implements Comparable { - - protected String key; - protected SortedSet releases = new TreeSet(); - - protected Artifact(String key) { - this.key = key; - } - - public final String getKey() { - return key; - } - - public final Artifact setKey(String key) { - this.key = key; - return this; - } - - public final Artifact setReleases(Collection releases) { - this.releases.clear(); - if (releases != null) { - for (Release release : releases) { - addRelease(release); - } - } - return this; - } - - public final Release addRelease(Release release) { - releases.add(release); - return release; - } - - public final Release addRelease(Version version) { - return addRelease(new Release(this, version)); - } - - public final Release getRelease(Version version) { - for (Release release : getReleases()) { - if (release.getVersion().equals(version)) { - return release; - } - } - return null; - } - - public final SortedSet getReleases() { - return releases; - } - - /** - * Shortcut for Ruby code - */ - public final SortedSet getReleasesGreaterThan(String version) { - return getReleasesGreaterThan(Version.create(version)); - } - - public final SortedSet getReleasesGreaterThan(Version version) { - TreeSet result = new TreeSet(); - for (Release release : releases) { - if (release.getVersion().compareTo(version)>0) { - result.add(release); - } - } - return result; - } - - public final SortedSet getVersions() { - SortedSet versions = new TreeSet(); - for (Release release : releases) { - versions.add(release.getVersion()); - } - return versions; - } - - public final Release getLastRelease() { - return releases.isEmpty() ? null : releases.last(); - } - - public final Release getLastCompatibleRelease(Version sonarVersion) { - Release result = null; - for (Release r : releases) { - if (r.supportSonarVersion(sonarVersion)) { - result = r; - } - } - return result; - } - - public final Release getLastCompatibleReleaseIfUpgrade(Version sonarVersion) { - Release result = null; - for (Release r : releases) { - if (r.getLastRequiredSonarVersion()!=null && r.getLastRequiredSonarVersion().compareTo(sonarVersion)>=0) { - result = r; - } - } - return result; - } - - @Override - public final boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof Artifact)) { - return false; - } - Artifact artifact = (Artifact) o; - return key.equals(artifact.key); - } - - @Override - public final int hashCode() { - return key.hashCode(); - } - - public final int compareTo(Artifact other) { - if (key == null) { - return -1; - } - return key.compareTo(other.key); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/FormatUtils.java b/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/FormatUtils.java deleted file mode 100644 index c22dfdb94f1..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/FormatUtils.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.apache.commons.lang.StringUtils; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -public final class FormatUtils { - public static final String DATE_PATTERN = "yyyy-MM-dd"; - public static final String DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ssZ"; - - private FormatUtils() { - // only static methods - } - - public static Date toDate(String s, boolean includeTime) { - String pattern = includeTime ? DATETIME_PATTERN : DATE_PATTERN; - try { - if (StringUtils.isNotBlank(s)) { - return new SimpleDateFormat(pattern).parse(s); - } - return null; - - } catch (ParseException e) { - throw new RuntimeException("The following value does not respect the date pattern " + pattern + ": " + s, e); - } - } - - public static String toString(Date d, boolean includeTime) { - if (d != null) { - return new SimpleDateFormat(includeTime ? DATETIME_PATTERN : DATE_PATTERN).format(d); - } - return null; - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Plugin.java b/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Plugin.java deleted file mode 100644 index d028b949ce2..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Plugin.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.apache.commons.lang.StringUtils; - -public final class Plugin extends Artifact { - - private String name; - private String description; - private String homepageUrl; - private String license; - private String organization; - private String organizationUrl; - private String termsConditionsUrl; - private String category; - private String issueTrackerUrl; - - public Plugin(String key) { - super(key); - } - - public String getName() { - return name; - } - - public Plugin setName(String name) { - this.name = name; - return this; - } - - public String getDescription() { - return description; - } - - public Plugin setDescription(String description) { - this.description = description; - return this; - } - - public String getHomepageUrl() { - return homepageUrl; - } - - public Plugin setHomepageUrl(String s) { - this.homepageUrl = s; - return this; - } - - public String getLicense() { - return license; - } - - public Plugin setLicense(String license) { - this.license = license; - return this; - } - - public String getOrganization() { - return organization; - } - - public Plugin setOrganization(String organization) { - this.organization = organization; - return this; - } - - public String getOrganizationUrl() { - return organizationUrl; - } - - public Plugin setOrganizationUrl(String url) { - this.organizationUrl = url; - return this; - } - - public String getCategory() { - return category; - } - - public Plugin setCategory(String category) { - this.category = category; - return this; - } - - public String getTermsConditionsUrl() { - return termsConditionsUrl; - } - - public Plugin setTermsConditionsUrl(String url) { - this.termsConditionsUrl = url; - return this; - } - - public String getIssueTrackerUrl() { - return issueTrackerUrl; - } - - public Plugin setIssueTrackerUrl(String url) { - this.issueTrackerUrl = url; - return this; - } - - public Plugin merge(PluginManifest manifest) { - if (StringUtils.equals(key, manifest.getKey())) { - name = manifest.getName(); - description = manifest.getDescription(); - organization = manifest.getOrganization(); - organizationUrl = manifest.getOrganizationUrl(); - issueTrackerUrl = manifest.getIssueTrackerUrl(); - license = manifest.getLicense(); - homepageUrl = manifest.getHomepage(); - termsConditionsUrl = manifest.getTermsConditionsUrl(); - } - return this; - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/PluginKeyUtils.java b/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/PluginKeyUtils.java deleted file mode 100644 index f39c54d7225..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/PluginKeyUtils.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.apache.commons.lang.StringUtils; - -/** - * @since 0.4 - */ -public final class PluginKeyUtils { - - private PluginKeyUtils() { - // only static methods - } - - public static String sanitize(String mavenArtifactId) { - if (mavenArtifactId == null) { - return null; - } - - String key = mavenArtifactId; - if (StringUtils.startsWith(mavenArtifactId, "sonar-") && StringUtils.endsWith(mavenArtifactId, "-plugin")) { - key = StringUtils.removeEnd(StringUtils.removeStart(mavenArtifactId, "sonar-"), "-plugin"); - } else if (StringUtils.endsWith(mavenArtifactId, "-sonar-plugin")) { - key = StringUtils.removeEnd(mavenArtifactId, "-sonar-plugin"); - } - return keepLettersAndDigits(key); - } - - private static String keepLettersAndDigits(String key) { - StringBuilder sb = new StringBuilder(); - for (int index = 0; index < key.length(); index++) { - char character = key.charAt(index); - if (Character.isLetter(character) || Character.isDigit(character)) { - sb.append(character); - } - } - return sb.toString(); - } - - public static boolean isValid(String pluginKey) { - return StringUtils.isNotBlank(pluginKey) && StringUtils.isAlphanumeric(pluginKey); - } - -} \ No newline at end of file diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/PluginManifest.java b/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/PluginManifest.java deleted file mode 100644 index c16ecace472..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/PluginManifest.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.builder.ReflectionToStringBuilder; - -import java.io.File; -import java.io.IOException; -import java.util.Date; -import java.util.jar.Attributes; -import java.util.jar.JarFile; -import java.util.jar.Manifest; - -import static org.sonar.updatecenter.common.FormatUtils.toDate; - -/** - * This class loads Sonar plugin metadata from JAR manifest. - */ -public final class PluginManifest { - - public static final String KEY = "Plugin-Key"; - public static final String MAIN_CLASS = "Plugin-Class"; - public static final String NAME = "Plugin-Name"; - public static final String DESCRIPTION = "Plugin-Description"; - public static final String ORGANIZATION = "Plugin-Organization"; - public static final String ORGANIZATION_URL = "Plugin-OrganizationUrl"; - public static final String LICENSE = "Plugin-License"; - public static final String VERSION = "Plugin-Version"; - public static final String SONAR_VERSION = "Sonar-Version"; - public static final String DEPENDENCIES = "Plugin-Dependencies"; - public static final String HOMEPAGE = "Plugin-Homepage"; - public static final String TERMS_CONDITIONS_URL = "Plugin-TermsConditionsUrl"; - public static final String BUILD_DATE = "Plugin-BuildDate"; - public static final String ISSUE_TRACKER_URL = "Plugin-IssueTrackerUrl"; - - /** - * @since 0.3 - */ - public static final String USE_CHILD_FIRST_CLASSLOADER = "Plugin-ChildFirstClassLoader"; - - /** - * @since 1.1 - */ - public static final String EXTEND_PLUGIN = "Extend-Plugin"; - - private String key; - private String name; - private String mainClass; - private String description; - private String organization; - private String organizationUrl; - private String license; - private String version; - private String sonarVersion; - private String[] dependencies = new String[0]; - private String homepage; - private String termsConditionsUrl; - private Date buildDate; - private String issueTrackerUrl; - private boolean useChildFirstClassLoader = false; - private String extendPlugin; - - /** - * Load the manifest from a JAR file. - */ - public PluginManifest(File file) throws IOException { - JarFile jar = null; - try { - jar = new JarFile(file); - if (jar.getManifest() != null) { - loadManifest(jar.getManifest()); - } - } catch (Exception e) { - throw new RuntimeException("Unable to read plugin manifest from jar : " + file.getAbsolutePath(), e); - } finally { - if (jar != null) { - jar.close(); - } - } - } - - /** - * @param manifest can not be null - */ - public PluginManifest(Manifest manifest) { - loadManifest(manifest); - } - - public PluginManifest() { - } - - private void loadManifest(Manifest manifest) { - Attributes attributes = manifest.getMainAttributes(); - this.key = PluginKeyUtils.sanitize(attributes.getValue(KEY)); - this.mainClass = attributes.getValue(MAIN_CLASS); - this.name = attributes.getValue(NAME); - this.description = attributes.getValue(DESCRIPTION); - this.license = attributes.getValue(LICENSE); - this.organization = attributes.getValue(ORGANIZATION); - this.organizationUrl = attributes.getValue(ORGANIZATION_URL); - this.version = attributes.getValue(VERSION); - this.homepage = attributes.getValue(HOMEPAGE); - this.termsConditionsUrl = attributes.getValue(TERMS_CONDITIONS_URL); - this.sonarVersion = attributes.getValue(SONAR_VERSION); - this.issueTrackerUrl = attributes.getValue(ISSUE_TRACKER_URL); - this.buildDate = toDate(attributes.getValue(BUILD_DATE), true); - this.useChildFirstClassLoader = StringUtils.equalsIgnoreCase(attributes.getValue(USE_CHILD_FIRST_CLASSLOADER), "true"); - this.extendPlugin = attributes.getValue(EXTEND_PLUGIN); - - String deps = attributes.getValue(DEPENDENCIES); - this.dependencies = StringUtils.split(StringUtils.defaultString(deps), ' '); - } - - public String getKey() { - return key; - } - - public PluginManifest setKey(String key) { - this.key = key; - return this; - } - - public String getName() { - return name; - } - - public PluginManifest setName(String name) { - this.name = name; - return this; - } - - public String getDescription() { - return description; - } - - public PluginManifest setDescription(String description) { - this.description = description; - return this; - } - - public String getOrganization() { - return organization; - } - - public PluginManifest setOrganization(String organization) { - this.organization = organization; - return this; - } - - public String getOrganizationUrl() { - return organizationUrl; - } - - public PluginManifest setOrganizationUrl(String url) { - this.organizationUrl = url; - return this; - } - - public String getLicense() { - return license; - } - - public PluginManifest setLicense(String license) { - this.license = license; - return this; - } - - public String getVersion() { - return version; - } - - public PluginManifest setVersion(String version) { - this.version = version; - return this; - } - - public String getSonarVersion() { - return sonarVersion; - } - - public PluginManifest setSonarVersion(String sonarVersion) { - this.sonarVersion = sonarVersion; - return this; - } - - public String getMainClass() { - return mainClass; - } - - public PluginManifest setMainClass(String mainClass) { - this.mainClass = mainClass; - return this; - } - - public String[] getDependencies() { - return dependencies; - } - - public PluginManifest setDependencies(String[] dependencies) { - this.dependencies = dependencies; - return this; - } - - public Date getBuildDate() { - return buildDate; - } - - public PluginManifest setBuildDate(Date buildDate) { - this.buildDate = buildDate; - return this; - } - - public String getHomepage() { - return homepage; - } - - public PluginManifest setHomepage(String homepage) { - this.homepage = homepage; - return this; - } - - public String getTermsConditionsUrl() { - return termsConditionsUrl; - } - - public PluginManifest setTermsConditionsUrl(String termsConditionsUrl) { - this.termsConditionsUrl = termsConditionsUrl; - return this; - } - - public String getIssueTrackerUrl() { - return issueTrackerUrl; - } - - public PluginManifest setIssueTrackerUrl(String issueTrackerUrl) { - this.issueTrackerUrl = issueTrackerUrl; - return this; - } - - /** - * @since 0.3 - */ - public boolean isUseChildFirstClassLoader() { - return useChildFirstClassLoader; - } - - /** - * @since 0.3 - */ - public PluginManifest setUseChildFirstClassLoader(boolean useChildFirstClassLoader) { - this.useChildFirstClassLoader = useChildFirstClassLoader; - return this; - } - - /** - * @since 1.1 - */ - public String getExtendPlugin() { - return extendPlugin; - } - - /** - * @since 1.1 - */ - public PluginManifest setExtendPlugin(String extendPlugin) { - this.extendPlugin = extendPlugin; - return this; - } - - @Override - public String toString() { - return new ReflectionToStringBuilder(this).toString(); - } - - public boolean isValid() { - return StringUtils.isNotBlank(key) && StringUtils.isNotBlank(version); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Release.java b/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Release.java deleted file mode 100644 index a719d4c0655..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Release.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.builder.ToStringBuilder; - -import java.util.Arrays; -import java.util.Date; -import java.util.SortedSet; -import java.util.TreeSet; - -public final class Release implements Comparable { - - private Artifact artifact; - private Version version; - private String description; - private String downloadUrl; - private String changelogUrl; - - /** from oldest to newest sonar versions */ - private SortedSet requiredSonarVersions = new TreeSet(); - private Date date; - - public Release(Artifact artifact, Version version) { - this.artifact = artifact; - this.version = version; - } - - public Release(Artifact artifact, String version) { - this.artifact = artifact; - this.version = Version.create(version); - } - - public Artifact getArtifact() { - return artifact; - } - - public Version getVersion() { - return version; - } - - public Release setVersion(Version version) { - this.version = version; - return this; - } - - public String getDownloadUrl() { - return downloadUrl; - } - - public Release setDownloadUrl(String s) { - this.downloadUrl = s; - return this; - } - - public String getFilename() { - return StringUtils.substringAfterLast(downloadUrl, "/"); - } - - public SortedSet getRequiredSonarVersions() { - return requiredSonarVersions; - } - - public boolean supportSonarVersion(Version version) { - return requiredSonarVersions.contains(version); - } - - public Release addRequiredSonarVersions(Version... versions) { - if (versions!=null) { - requiredSonarVersions.addAll(Arrays.asList(versions)); - } - return this; - } - - public Release addRequiredSonarVersions(String... versions) { - if (versions!=null) { - for (String v : versions) { - requiredSonarVersions.add(Version.create(v)); - } - } - return this; - } - - public Version getLastRequiredSonarVersion() { - if (requiredSonarVersions!=null && !requiredSonarVersions.isEmpty()) { - return requiredSonarVersions.last(); - } - return null; - } - - public Date getDate() { - return date; - } - - public Release setDate(Date date) { - this.date = date; - return this; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getChangelogUrl() { - return changelogUrl; - } - - public void setChangelogUrl(String changelogUrl) { - this.changelogUrl = changelogUrl; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Release that = (Release) o; - return version.equals(that.version); - - } - - @Override - public int hashCode() { - return version.hashCode(); - } - - @Override - public String toString() { - return new ToStringBuilder(this) - .append("version", version) - .append("downloadUrl", downloadUrl) - .append("changelogUrl", changelogUrl) - .append("description", description) - .toString(); - } - - public int compareTo(Release o) { - return getVersion().compareTo(o.getVersion()); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Sonar.java b/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Sonar.java deleted file mode 100644 index de1acf44ca9..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Sonar.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.updatecenter.common; - -public final class Sonar extends Artifact { - - public Sonar() { - super("sonar"); - } - - /** - * shortcut only for sonar, no need to have other fields than version - */ - public Sonar setReleases(String[] versions) { - for (String version : versions) { - addRelease(new Release(this, Version.create(version))); - } - return this; - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/UpdateCenter.java b/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/UpdateCenter.java deleted file mode 100644 index 32bb11cc19b..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/UpdateCenter.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.apache.commons.lang.StringUtils; - -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -public final class UpdateCenter { - - private Sonar sonar = new Sonar(); - private Set plugins = new HashSet(); - private Date date; - - public UpdateCenter() { - this(new Date()); - } - - public UpdateCenter(Date date) { - this.date = date; - } - - public Set getPlugins() { - return plugins; - } - - public Plugin getPlugin(String key) { - for (Plugin plugin : plugins) { - if (StringUtils.equals(key, plugin.getKey())) { - return plugin; - } - } - return null; - } - - public UpdateCenter setPlugins(Collection plugins) { - this.plugins.clear(); - this.plugins.addAll(plugins); - return this; - } - - public UpdateCenter addPlugin(Plugin plugin) { - this.plugins.add(plugin); - return this; - } - - public Sonar getSonar() { - return sonar; - } - - public UpdateCenter setSonar(Sonar sonar) { - this.sonar = sonar; - return this; - } - - public Date getDate() { - return date; - } - - public UpdateCenter setDate(Date date) { - this.date = date; - return this; - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/UpdateCenterDeserializer.java b/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/UpdateCenterDeserializer.java deleted file mode 100644 index a388b6ce5b7..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/UpdateCenterDeserializer.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Date; -import java.util.Properties; - -import static org.sonar.updatecenter.common.FormatUtils.toDate; - -public final class UpdateCenterDeserializer { - - private UpdateCenterDeserializer() { - // only static methods - } - - public static UpdateCenter fromProperties(File file) throws IOException { - FileInputStream in = FileUtils.openInputStream(file); - try { - Properties props = new Properties(); - props.load(in); - UpdateCenter center = fromProperties(props); - center.setDate(new Date(file.lastModified())); - return center; - - } finally { - IOUtils.closeQuietly(in); - } - } - - public static UpdateCenter fromProperties(Properties p) { - UpdateCenter center = new UpdateCenter(); - center.setDate(FormatUtils.toDate(p.getProperty("date"), true)); - String[] sonarVersions = getArray(p, "sonar.versions"); - for (String sonarVersion : sonarVersions) { - Release release = new Release(center.getSonar(), sonarVersion); - release.setChangelogUrl(get(p, "sonar." + sonarVersion + ".changelogUrl")); - release.setDescription(get(p, "sonar." + sonarVersion + ".description")); - release.setDownloadUrl(get(p, "sonar." + sonarVersion + ".downloadUrl")); - release.setDate(FormatUtils.toDate(get(p, "sonar." + sonarVersion + ".date"), false)); - center.getSonar().addRelease(release); - } - - String[] pluginKeys = getArray(p, "plugins"); - for (String pluginKey : pluginKeys) { - Plugin plugin = new Plugin(pluginKey); - center.addPlugin(plugin); - plugin.setName(get(p, pluginKey, "name")); - plugin.setDescription(get(p, pluginKey, "description")); - plugin.setCategory(get(p, pluginKey, "category")); - plugin.setHomepageUrl(get(p, pluginKey, "homepageUrl")); - plugin.setLicense(get(p, pluginKey, "license")); - plugin.setOrganization(get(p, pluginKey, "organization")); - plugin.setOrganizationUrl(get(p, pluginKey, "organizationUrl")); - plugin.setTermsConditionsUrl(get(p, pluginKey, "termsConditionsUrl")); - plugin.setIssueTrackerUrl(get(p, pluginKey, "issueTrackerUrl")); - - String[] pluginReleases = StringUtils.split(StringUtils.defaultIfEmpty(get(p, pluginKey, "versions"), ""), ","); - for (String pluginVersion : pluginReleases) { - Release release = new Release(plugin, pluginVersion); - plugin.addRelease(release); - release.setDownloadUrl(get(p, pluginKey, pluginVersion + ".downloadUrl")); - release.setChangelogUrl(get(p, pluginKey, pluginVersion + ".changelogUrl")); - release.setDescription(get(p, pluginKey, pluginVersion + ".description")); - release.setDate(toDate(get(p, pluginKey, pluginVersion + ".date"), false)); - String[] requiredSonarVersions = StringUtils.split(StringUtils.defaultIfEmpty(get(p, pluginKey, pluginVersion + ".requiredSonarVersions"), ""), ","); - for (String requiredSonarVersion : requiredSonarVersions) { - release.addRequiredSonarVersions(Version.create(requiredSonarVersion)); - } - } - } - - return center; - } - - private static String get(Properties props, String key) { - return StringUtils.defaultIfEmpty(props.getProperty(key), null); - } - - private static String[] getArray(Properties props, String key) { - return StringUtils.split(StringUtils.defaultIfEmpty(props.getProperty(key), ""), ","); - } - - private static String get(Properties p, String pluginKey, String field) { - return get(p, pluginKey + "." + field); - } - -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/UpdateCenterSerializer.java b/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/UpdateCenterSerializer.java deleted file mode 100644 index 15793c4dea8..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/UpdateCenterSerializer.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Properties; - -public final class UpdateCenterSerializer { - - private static void set(Properties props, String key, String value) { - if (StringUtils.isNotBlank(value)) { - props.setProperty(key, value); - } - } - - private static void set(Properties props, String key, Collection values) { - if (values != null && !values.isEmpty()) { - props.setProperty(key, StringUtils.join(values, ",")); - } - } - - private static void set(Properties props, Plugin plugin, String key, String value) { - if (StringUtils.isNotBlank(value)) { - props.setProperty(plugin.getKey() + "." + key, value); - } - } - - private static void set(Properties props, Plugin plugin, String key, Collection values) { - if (values != null && !values.isEmpty()) { - props.setProperty(plugin.getKey() + "." + key, StringUtils.join(values, ",")); - } - } - - public static Properties toProperties(UpdateCenter center) { - Properties p = new Properties(); - set(p, "date", FormatUtils.toString(center.getDate(), true)); - set(p, "sonar.versions", center.getSonar().getVersions()); - for (Release sonarRelease : center.getSonar().getReleases()) { - set(p, "sonar." + sonarRelease.getVersion() + ".downloadUrl", sonarRelease.getDownloadUrl()); - set(p, "sonar." + sonarRelease.getVersion() + ".changelogUrl", sonarRelease.getChangelogUrl()); - set(p, "sonar." + sonarRelease.getVersion() + ".description", sonarRelease.getDescription()); - set(p, "sonar." + sonarRelease.getVersion() + ".date", FormatUtils.toString(sonarRelease.getDate(), false)); - } - - List pluginKeys = new ArrayList(); - for (Plugin plugin : center.getPlugins()) { - pluginKeys.add(plugin.getKey()); - set(p, plugin, "name", plugin.getName()); - set(p, plugin, "description", plugin.getDescription()); - set(p, plugin, "category", plugin.getCategory()); - set(p, plugin, "homepageUrl", plugin.getHomepageUrl()); - set(p, plugin, "license", plugin.getLicense()); - set(p, plugin, "organization", plugin.getOrganization()); - set(p, plugin, "organizationUrl", plugin.getOrganizationUrl()); - set(p, plugin, "termsConditionsUrl", plugin.getTermsConditionsUrl()); - set(p, plugin, "issueTrackerUrl", plugin.getIssueTrackerUrl()); - - List releaseKeys = new ArrayList(); - for (Release release : plugin.getReleases()) { - releaseKeys.add(release.getVersion().toString()); - set(p, plugin, release.getVersion() + ".requiredSonarVersions", StringUtils.join(release.getRequiredSonarVersions(), ",")); - set(p, plugin, release.getVersion() + ".downloadUrl", release.getDownloadUrl()); - set(p, plugin, release.getVersion() + ".changelogUrl", release.getChangelogUrl()); - set(p, plugin, release.getVersion() + ".description", release.getDescription()); - set(p, plugin, release.getVersion() + ".date", FormatUtils.toString(release.getDate(), false)); - } - set(p, plugin, "versions", releaseKeys); - } - set(p, "plugins", pluginKeys); - return p; - } - - public static void toProperties(UpdateCenter sonar, File toFile) { - FileOutputStream output = null; - try { - output = FileUtils.openOutputStream(toFile); - toProperties(sonar).store(output, "Generated file"); - - } catch (IOException e) { - throw new RuntimeException("Fail to store Sonar properties to: " + toFile.getAbsolutePath(), e); - - } finally { - IOUtils.closeQuietly(output); - } - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Version.java b/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Version.java deleted file mode 100644 index f80d797cc6f..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/main/java/org/sonar/updatecenter/common/Version.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.apache.commons.lang.StringUtils; - -public class Version implements Comparable { - - private String normalizedMajor = normalizePart("0"); - private String normalizedMinor = normalizePart("0"); - private String normalizedPatch = normalizePart("0"); - private String normalizedPatch2 = normalizePart("0"); - private String major = "0"; - private String minor = "0"; - private String patch = "0"; - private String patch2 = "0"; - private String name; - - private Version(String version) { - this.name = StringUtils.trimToEmpty(version); - this.name = StringUtils.substringBefore(this.name, "-"); // we don't care about snapshots and RCs for now - String[] split = StringUtils.split(name, '.'); - if (split.length >= 1) { - major = split[0]; - normalizedMajor = normalizePart(major); - } - if (split.length >= 2) { - minor = split[1]; - normalizedMinor = normalizePart(minor); - } - if (split.length >= 3) { - patch = split[2]; - normalizedPatch = normalizePart(patch); - } - if (split.length >= 4) { - patch2 = split[3]; - normalizedPatch2 = normalizePart(patch2); - } - } - - private static String normalizePart(String part) { - return StringUtils.leftPad(part, 4, '0'); - } - - public String getMajor() { - return major; - } - - public String getMinor() { - return minor; - } - - public String getPatch() { - return patch; - } - - public String getPatch2() { - return patch2; - } - - public String getName() { - return name; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - Version version = (Version) o; - if ( !normalizedMajor.equals(version.normalizedMajor)) { - return false; - } - if ( !normalizedMinor.equals(version.normalizedMinor)) { - return false; - } - if ( !normalizedPatch.equals(version.normalizedPatch)) { - return false; - } - if ( !normalizedPatch2.equals(version.normalizedPatch2)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int result = normalizedMajor.hashCode(); - result = 31 * result + normalizedMinor.hashCode(); - result = 31 * result + normalizedPatch.hashCode(); - result = 31 * result + normalizedPatch2.hashCode(); - return result; - } - - public int compareTo(Version other) { - // TODO : manage RC, alpha, ... - int c = normalizedMajor.compareTo(other.normalizedMajor); - if (c == 0) { - c = normalizedMinor.compareTo(other.normalizedMinor); - if (c == 0) { - c = normalizedPatch.compareTo(other.normalizedPatch); - if (c == 0) { - c = normalizedPatch2.compareTo(other.normalizedPatch2); - } - } - } - return c; - } - - @Override - public String toString() { - return name; - } - - public static Version create(String version) { - return new Version(version); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/ArtifactTest.java b/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/ArtifactTest.java deleted file mode 100644 index 7f31a2c500c..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/ArtifactTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.junit.Test; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -public class ArtifactTest { - - @Test - public void compare() { - Artifact a = new FakeArtifact("a"); - Artifact b = new FakeArtifact("b"); - Artifact c = new Plugin("c"); - - List list = Arrays.asList(b, a, c); - Collections.sort(list); - assertThat(list.get(0), is(a)); - assertThat(list.get(1), is(b)); - assertThat(list.get(2), is(c)); - } - - @Test - public void sortReleases() { - FakeArtifact artifact = new FakeArtifact("fake"); - artifact.addRelease(Version.create("2.0")); - artifact.addRelease(Version.create("1.1")); - artifact.addRelease(Version.create("1.5")); - - Iterator it = artifact.getReleases().iterator(); - assertThat(it.next().getVersion().getName(), is("1.1")); - assertThat(it.next().getVersion().getName(), is("1.5")); - assertThat(it.next().getVersion().getName(), is("2.0")); - } - - @Test - public void equals() { - FakeArtifact foo = new FakeArtifact("foo"); - assertTrue(foo.equals(new FakeArtifact("foo"))); - assertTrue(foo.equals(foo)); - assertFalse(foo.equals(new FakeArtifact("bar"))); - } -} - -class FakeArtifact extends Artifact { - - protected FakeArtifact(String key) { - super(key); - } -} \ No newline at end of file diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/FormatUtilsTest.java b/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/FormatUtilsTest.java deleted file mode 100644 index ea477a061d7..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/FormatUtilsTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.junit.Test; - -import java.text.ParseException; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; - -public class FormatUtilsTest { - - @Test - public void testToDate() throws ParseException { - assertThat(FormatUtils.toDate("2010-05-18", false).getDate(), is(18)); - } - - @Test - public void ignoreNullDate() { - assertNull(FormatUtils.toDate(null, true)); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/PluginKeyUtilsTest.java b/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/PluginKeyUtilsTest.java deleted file mode 100644 index ca3bbc492c0..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/PluginKeyUtilsTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.updatecenter.common; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -import org.junit.Test; - -public class PluginKeyUtilsTest { - - @Test - public void shouldSanitizeMavenArtifactId() { - assertThat(PluginKeyUtils.sanitize("sonar-test-plugin"), is("test")); - assertThat(PluginKeyUtils.sanitize("test-sonar-plugin"), is("test")); - assertThat(PluginKeyUtils.sanitize("test"), is("test")); - - assertThat(PluginKeyUtils.sanitize("sonar-test-foo-plugin"), is("testfoo")); - assertThat(PluginKeyUtils.sanitize("test-foo-sonar-plugin"), is("testfoo")); - assertThat(PluginKeyUtils.sanitize("test-foo"), is("testfoo")); - assertThat(PluginKeyUtils.sanitize("keep.only-digits%12345&and*letters"), is("keeponlydigits12345andletters")); - assertThat(PluginKeyUtils.sanitize(" remove whitespaces "), is("removewhitespaces")); - } - - @Test - public void shouldBeValid() { - assertThat(PluginKeyUtils.isValid("foo"), is(true)); - assertThat(PluginKeyUtils.isValid("sonarfooplugin"), is(true)); - assertThat(PluginKeyUtils.isValid("foo6"), is(true)); - assertThat(PluginKeyUtils.isValid("FOO6"), is(true)); - } - - @Test - public void shouldNotBeValid() { - assertThat(PluginKeyUtils.isValid(null), is(false)); - assertThat(PluginKeyUtils.isValid(""), is(false)); - assertThat(PluginKeyUtils.isValid("sonar-foo-plugin"), is(false)); - assertThat(PluginKeyUtils.isValid("foo.bar"), is(false)); - assertThat(PluginKeyUtils.isValid(" nowhitespaces "), is(false)); - assertThat(PluginKeyUtils.isValid("no whitespaces"), is(false)); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/PluginManifestTest.java b/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/PluginManifestTest.java deleted file mode 100644 index 6be112ae20c..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/PluginManifestTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.junit.Test; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; - -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.nullValue; -import static org.hamcrest.number.OrderingComparisons.greaterThan; -import static org.junit.Assert.assertThat; - -public class PluginManifestTest { - - @Test(expected = RuntimeException.class) - public void test() throws Exception { - new PluginManifest(new File("fake.jar")); - } - - @Test - public void testCreateManifest() throws URISyntaxException, IOException { - URL jar = getClass().getResource("/org/sonar/updatecenter/common/PluginManifestTest/checkstyle-plugin.jar"); - PluginManifest manifest = new PluginManifest(new File(jar.toURI())); - - assertThat(manifest.getKey(), is("checkstyle")); - assertThat(manifest.getName(), is("Checkstyle")); - assertThat(manifest.getMainClass(), is("org.sonar.plugins.checkstyle.CheckstylePlugin")); - assertThat(manifest.getVersion().length(), greaterThan(1)); - assertThat(manifest.isUseChildFirstClassLoader(), is(false)); - assertThat(manifest.getDependencies().length, is(4)); - assertThat(manifest.getDependencies()[0], is("META-INF/lib/antlr-2.7.6.jar")); - } - - @Test - public void doNotFailWhenNoOldPluginManifest() throws URISyntaxException, IOException { - URL jar = getClass().getResource("/org/sonar/updatecenter/common/PluginManifestTest/old-plugin.jar"); - PluginManifest manifest = new PluginManifest(new File(jar.toURI())); - - assertThat(manifest.getKey(), nullValue()); - assertThat(manifest.getName(), nullValue()); - assertThat(manifest.getMainClass(), is("org.sonar.plugins.checkstyle.CheckstylePlugin")); - assertThat(manifest.isUseChildFirstClassLoader(), is(false)); - assertThat(manifest.getDependencies().length, is(0)); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/ReleaseTest.java b/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/ReleaseTest.java deleted file mode 100644 index e5a6d9228e6..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/ReleaseTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.junit.Test; - -import static junit.framework.Assert.assertNull; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -public class ReleaseTest { - - @Test - public void getFilename() { - Release release = new Release(new Plugin("fake"), Version.create("1.2")); - assertNull(release.getFilename()); - - release.setDownloadUrl("http://dist.sonarsource.org/foo-1.2.jar"); - assertThat(release.getFilename(), is("foo-1.2.jar")); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/UpdateCenterDeserializerTest.java b/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/UpdateCenterDeserializerTest.java deleted file mode 100644 index 3ad836d75a6..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/UpdateCenterDeserializerTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.apache.commons.io.IOUtils; -import org.junit.Test; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.internal.matchers.IsCollectionContaining.hasItems; - -public class UpdateCenterDeserializerTest { - - @Test - public void fromProperties() throws IOException { - InputStream input = getClass().getResourceAsStream("/org/sonar/updatecenter/common/UpdateCenterDeserializerTest/updates.properties"); - try { - Properties props = new Properties(); - props.load(input); - UpdateCenter center = UpdateCenterDeserializer.fromProperties(props); - - assertThat(center.getSonar().getVersions(), hasItems(Version.create("2.2"), Version.create("2.3"))); - assertThat(center.getSonar().getRelease(Version.create("2.2")).getDownloadUrl(), is("http://dist.sonar.codehaus.org/sonar-2.2.zip")); - - Plugin clirr = center.getPlugin("clirr"); - assertThat(clirr.getName(), is("Clirr")); - assertThat(clirr.getDescription(), is("Clirr Plugin")); - assertThat(clirr.getVersions(),hasItems(Version.create("1.0"), Version.create("1.1"))); - assertThat(clirr.getRelease(Version.create("1.0")).getDownloadUrl(), is("http://dist.sonar-plugins.codehaus.org/clirr-1.0.jar")); - - } finally { - IOUtils.closeQuietly(input); - } - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/UpdateCenterSerializerTest.java b/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/UpdateCenterSerializerTest.java deleted file mode 100644 index 8924e638582..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/UpdateCenterSerializerTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.junit.Test; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Properties; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -public class UpdateCenterSerializerTest { - - @Test - public void testToProperties() throws IOException, URISyntaxException { - UpdateCenter center = new UpdateCenter(); - - center.getSonar().addRelease(Version.create("2.0")); - center.getSonar().addRelease(Version.create("2.1")); - center.addPlugin(new Plugin("foo").setName("Foo").setOrganizationUrl("http://www.sonarsource.org")); - Plugin barPlugin = new Plugin("bar"); - center.addPlugin(barPlugin); - barPlugin.addRelease( - new Release(barPlugin, Version.create("1.2")) - .addRequiredSonarVersions(Version.create("2.0")) - .addRequiredSonarVersions(Version.create("2.1"))); - - Properties properties = UpdateCenterSerializer.toProperties(center); - properties.store(System.out, null); - - assertProperty(properties, "sonar.versions", "2.0,2.1"); - assertProperty(properties, "plugins", "foo,bar"); - assertProperty(properties, "foo.name", "Foo"); - assertProperty(properties, "foo.organizationUrl", "http://www.sonarsource.org"); - assertProperty(properties, "bar.versions", "1.2"); - assertProperty(properties, "bar.1.2.requiredSonarVersions", "2.0,2.1"); - } - - private void assertProperty(Properties props, String key, String value) { - assertThat(props.getProperty(key), is(value)); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/UpdateCenterTest.java b/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/UpdateCenterTest.java deleted file mode 100644 index a624c884cdc..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/UpdateCenterTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.updatecenter.common; - -import org.junit.Test; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNull; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -public class UpdateCenterTest { - - @Test - public void getAndSetPlugins() { - Plugin foo = new Plugin("foo"); - Plugin bar = new Plugin("bar"); - - UpdateCenter center = new UpdateCenter(); - center.addPlugin(foo); - center.addPlugin(bar); - - assertEquals(foo, center.getPlugin("foo")); - assertNull(center.getPlugin("unknown")); - assertThat(center.getPlugins().size(), is(2)); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/VersionTest.java b/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/VersionTest.java deleted file mode 100644 index 9a78aecf5e8..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/test/java/org/sonar/updatecenter/common/VersionTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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.updatecenter.common; - -import static junit.framework.Assert.assertTrue; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.number.OrderingComparisons.greaterThan; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; - -import org.junit.Ignore; -import org.junit.Test; - -public class VersionTest { - - @Test - public void testCompare() { - Version version12 = Version.create("1.2"); - Version version121 = Version.create("1.2.1"); - - assertThat(version12.toString(), is("1.2")); - assertThat(version12.compareTo(version12), is(0)); - assertThat(version121.compareTo(version121), is(0)); - - assertTrue(version121.compareTo(version12) > 0); - assertTrue(version12.compareTo(version121) < 0); - } - - @Test - @Ignore("TODO : support alpha, beta, snapshot versions") - public void testCompareReleaseAndSnapshot() { - Version version12 = Version.create("1.2"); - Version version12SNAPSHOT = Version.create("1.2-SNAPSHOT"); - - assertThat(version12.compareTo(version12SNAPSHOT), greaterThan(0)); - } - - @Test - public void snapshotEqualToRelease() { - Version version12 = Version.create("1.2"); - Version version12SNAPSHOT = Version.create("1.2-SNAPSHOT"); - - assertThat(version12.compareTo(version12SNAPSHOT), is(0)); - } - - @Test - public void releaseCandidateEqualToRelease() { - Version version12 = Version.create("1.2"); - Version version12RC = Version.create("1.2-RC1"); - - assertThat(version12.compareTo(version12RC), is(0)); - } - - @Test - public void testTrim() { - Version version12 = Version.create(" 1.2 "); - - assertThat(version12.getName(), is("1.2")); - assertTrue(version12.equals(Version.create("1.2"))); - } - - @Test - public void testDefaultNumberIsZero() { - Version version12 = Version.create("1.2"); - Version version120 = Version.create("1.2.0"); - - assertTrue(version12.equals(version120)); - assertTrue(version120.equals(version12)); - } - - @Test - public void testCompareOnTwoDigits() { - Version version1dot10 = Version.create("1.10"); - Version version1dot1 = Version.create("1.1"); - Version version1dot9 = Version.create("1.9"); - - assertTrue(version1dot10.compareTo(version1dot1) > 0); - assertTrue(version1dot10.compareTo(version1dot9) > 0); - } - - @Test - public void testFields() { - Version version = Version.create("1.10.2"); - - assertThat(version.getName(), is("1.10.2")); - assertThat(version.toString(), is("1.10.2")); - assertThat(version.getMajor(), is("1")); - assertThat(version.getMinor(), is("10")); - assertThat(version.getPatch(), is("2")); - assertThat(version.getPatch2(), is("0")); - } - - @Test - public void testPatchFields() { - Version version = Version.create("1.2.3.4"); - - assertThat(version.getPatch(), is("3")); - assertThat(version.getPatch2(), is("4")); - - assertTrue(version.equals(version)); - assertTrue(version.equals(Version.create("1.2.3.4"))); - assertFalse(version.equals(Version.create("1.2.3.5"))); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/test/resources/org/sonar/updatecenter/common/PluginManifestTest/checkstyle-plugin.jar b/subprojects/sonar-update-center/sonar-update-center-common/src/test/resources/org/sonar/updatecenter/common/PluginManifestTest/checkstyle-plugin.jar deleted file mode 100644 index ef5994d4f70..00000000000 Binary files a/subprojects/sonar-update-center/sonar-update-center-common/src/test/resources/org/sonar/updatecenter/common/PluginManifestTest/checkstyle-plugin.jar and /dev/null differ diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/test/resources/org/sonar/updatecenter/common/PluginManifestTest/old-plugin.jar b/subprojects/sonar-update-center/sonar-update-center-common/src/test/resources/org/sonar/updatecenter/common/PluginManifestTest/old-plugin.jar deleted file mode 100644 index 571c3a953d5..00000000000 Binary files a/subprojects/sonar-update-center/sonar-update-center-common/src/test/resources/org/sonar/updatecenter/common/PluginManifestTest/old-plugin.jar and /dev/null differ diff --git a/subprojects/sonar-update-center/sonar-update-center-common/src/test/resources/org/sonar/updatecenter/common/UpdateCenterDeserializerTest/updates.properties b/subprojects/sonar-update-center/sonar-update-center-common/src/test/resources/org/sonar/updatecenter/common/UpdateCenterDeserializerTest/updates.properties deleted file mode 100644 index 29360aeb23c..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-common/src/test/resources/org/sonar/updatecenter/common/UpdateCenterDeserializerTest/updates.properties +++ /dev/null @@ -1,17 +0,0 @@ -sonar.versions=2.2,2.3 -sonar.2.2.downloadUrl=http://dist.sonar.codehaus.org/sonar-2.2.zip -sonar.2.3.downloadUrl=http://dist.sonar.codehaus.org/sonar-2.3.zip -sonar.2.3.description=sonar 2.3 - -plugins=clirr,motionchart - -clirr.name=Clirr -clirr.description=Clirr Plugin -clirr.license=LGPL -clirr.versions=1.0,1.1 -clirr.1.0.downloadUrl=http://dist.sonar-plugins.codehaus.org/clirr-1.0.jar -clirr.1.1.downloadUrl=http://dist.sonar-plugins.codehaus.org/clirr-1.1.jar -clirr.1.1.description=clirr 1.1 - -motionchart.name=Motion Chart -motionchart.description=Motion Chart Plugin \ No newline at end of file diff --git a/subprojects/sonar-update-center/sonar-update-center-server/pom.xml b/subprojects/sonar-update-center/sonar-update-center-server/pom.xml deleted file mode 100644 index 0fc50b825d6..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/pom.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - 4.0.0 - - - org.codehaus.sonar - sonar-update-center - 1.1-SNAPSHOT - - sonar-update-center-server - Sonar :: Update Center :: Server - - - 3.0-beta-1 - - - - - org.codehaus.sonar - sonar-update-center-common - - - - com.thoughtworks.xstream - xstream - - - xpp3 - xpp3 - - - - org.slf4j - slf4j-log4j12 - 1.5.6 - - - - ch.qos.logback - logback-classic - 0.9.15 - - - - org.apache.maven - maven-compat - ${maven.version} - - - - org.apache.maven.wagon - wagon-http - 1.0-beta-5 - - - - com.googlecode.json-simple - json-simple - 1.1 - - - - commons-io - commons-io - 1.4 - - - commons-lang - commons-lang - 2.5 - - - - args4j - args4j - 2.0.8 - - - - - - org.apache.httpcomponents - httpclient - 4.0.1 - - - - - - junit - junit - test - - - org.hamcrest - hamcrest-all - test - - - xmlunit - xmlunit - 1.2 - test - - - - - - - org.codehaus.mojo - exec-maven-plugin - - org.sonar.updatecenter.deprecated.UpdateCenter - - -d - ${project.basedir}/target/site - - - - - - org.codehaus.mojo - wagon-maven-plugin - - sonar-plugins - ${project.basedir}/target/site - ** - dav:https://dav.codehaus.org/dist/sonar-plugins/update-center - - - - - - diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/History.java b/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/History.java deleted file mode 100644 index f9b4de9e11d..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/History.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.updatecenter.deprecated; - -import org.apache.maven.artifact.versioning.ArtifactVersion; - -import java.util.Set; -import java.util.TreeMap; - -/** - * Information about release history, discovered from Maven repository. - * - * @author Evgeny Mandrikov - */ -public class History { - - private TreeMap artifacts = new TreeMap(); - - public History() { - } - - public Set getAllVersions() { - return artifacts.keySet(); - } - - /** - * @return latest version of plugin - */ - public M latest() { - if (artifacts.size() == 0) { - return null; - } - return artifacts.get(artifacts.lastKey()); - } - - public void addArtifact(ArtifactVersion version, M artifact) { - artifacts.put(version, artifact); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/Plugin.java b/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/Plugin.java deleted file mode 100644 index 7dbf87a5374..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/Plugin.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * 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.updatecenter.deprecated; - -import org.apache.maven.model.Developer; -import org.json.simple.JSONObject; - -import java.io.File; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; -import java.util.jar.Attributes; -import java.util.jar.JarFile; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; - -/** - * Information about Sonar Plugin. - * - * @author Evgeny Mandrikov - */ -public class Plugin implements Versioned { - private String key; - private String name; - private String description; - private String version; - private String downloadUrl; - private String requiredSonarVersion; - private String homepage; - private long timestamp; - - private String pluginClass; - private String issueTracker; - private String sources; - private String license; - - private List developers; - - public Plugin(String pluginKey) { - this.key = pluginKey; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - /** - * @return name - */ - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - /** - * @return version - */ - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getReleaseDate() { - return (new SimpleDateFormat("d MMM yyyy")).format(new Date(timestamp)); - } - - private void setDate(long timestamp) { - this.timestamp = timestamp; - } - - /** - * @return URL for downloading - */ - public String getDownloadUrl() { - return downloadUrl; - } - - public void setDownloadUrl(String downloadUrl) { - this.downloadUrl = downloadUrl; - } - - /** - * @return minimal Sonar version to run this plugin - */ - public String getRequiredSonarVersion() { - // TODO Sonar-Version from MANIFEST.MF - return requiredSonarVersion; - } - - public void setRequiredSonarVersion(String sonarVersion) { - this.requiredSonarVersion = sonarVersion; - } - - /** - * @return homepage - */ - public String getHomepage() { - // TODO Plugin-Homepage from MANIFEST.MF - return homepage; - } - - public void setHomepage(String homepage) { - this.homepage = homepage; - } - - public String getIssueTracker() { - return issueTracker; - } - - public void setIssueTracker(String url) { - this.issueTracker = url; - } - - public String getSources() { - return sources; - } - - public void setSources(String sources) { - this.sources = sources; - } - - public String getLicense() { - return license; - } - - public void setLicense(String license) { - this.license = license; - } - - public List getDevelopers() { - return developers; - } - - public void setDevelopers(List developers) { - this.developers = developers; - } - - public JSONObject toJsonObject() { - JSONObject obj = new JSONObject(); - obj.put("id", getKey()); - obj.put("name", getName()); - obj.put("version", getVersion()); - obj.put("sonarVersion", getRequiredSonarVersion()); - if (getDownloadUrl() != null) { - obj.put("downloadUrl", getDownloadUrl()); - } - if (getHomepage() != null) { - obj.put("homepage", getHomepage()); - } - return obj; - } - - public static Plugin extractMetadata(File file) throws IOException { - JarFile jar = new JarFile(file); - ZipEntry entry = jar.getEntry("META-INF/MANIFEST.MF"); - long timestamp = entry.getTime(); - Manifest manifest = jar.getManifest(); - jar.close(); - - Attributes attributes = manifest.getMainAttributes(); - String pluginKey = attributes.getValue("Plugin-Key"); - Plugin plugin = new Plugin(pluginKey); - plugin.setName(attributes.getValue("Plugin-Name")); - plugin.setVersion(attributes.getValue("Plugin-Version")); - plugin.setRequiredSonarVersion(attributes.getValue("Sonar-Version")); - plugin.setHomepage(attributes.getValue("Plugin-Homepage")); - plugin.setDate(timestamp); - return plugin; - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/Sonar.java b/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/Sonar.java deleted file mode 100644 index cb652459af1..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/Sonar.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.updatecenter.deprecated; - -import org.json.simple.JSONObject; - -/** - * Information about Sonar. - * - * @author Evgeny Mandrikov - */ -public class Sonar implements Versioned { - - private final String version; - - public Sonar(String version) { - this.version = version; - } - - /** - * @return Sonar version - */ - public String getVersion() { - return version; - } - - /** - * @return URL for downloading - */ - public String getDownloadUrl() { - return "http://dist.sonar.codehaus.org/sonar-" + getVersion() + ".zip"; - } - - public JSONObject toJsonObject() { - JSONObject obj = new JSONObject(); - obj.put("version", getVersion()); - obj.put("downloadUrl", getDownloadUrl()); - return obj; - } - -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/UpdateCenter.java b/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/UpdateCenter.java deleted file mode 100644 index 7e95d397679..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/UpdateCenter.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * 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.updatecenter.deprecated; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.metadata.ArtifactMetadataSource; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; -import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; -import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; -import org.apache.maven.artifact.resolver.ArtifactResolver; -import org.apache.maven.artifact.versioning.ArtifactVersion; -import org.apache.maven.model.Dependency; -import org.apache.maven.model.Developer; -import org.apache.maven.project.MavenProject; -import org.apache.maven.project.MavenProjectBuilder; -import org.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.DefaultContainerConfiguration; -import org.codehaus.plexus.DefaultPlexusContainer; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.kohsuke.args4j.CmdLineParser; -import org.kohsuke.args4j.Option; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * @author Evgeny Mandrikov - */ -public class UpdateCenter { - // FIXME value set only for debug purposes - @Option(name = "-d") - public File outputDirectory = new File("/tmp/site"); - - private static final String ARTIFACT_JAR_TYPE = "jar"; - private static final String ARTIFACT_POM_TYPE = "pom"; - - private List remoteRepositories; - private ArtifactRepository localRepository; - - private ArtifactFactory artifactFactory; - private ArtifactResolver artifactResolver; - private ArtifactMetadataSource metadataSource; - private MavenProjectBuilder mavenProjectBuilder; - - private void run() throws Exception { - // Init plexus - ClassWorld classWorld = new ClassWorld("plexus.core", UpdateCenter.class.getClassLoader()); - ContainerConfiguration configuration = new DefaultContainerConfiguration().setClassWorld(classWorld); - PlexusContainer plexus = new DefaultPlexusContainer(configuration); - // Init components - artifactFactory = plexus.lookup(ArtifactFactory.class); - artifactResolver = plexus.lookup(ArtifactResolver.class); - metadataSource = plexus.lookup(ArtifactMetadataSource.class); - mavenProjectBuilder = plexus.lookup(MavenProjectBuilder.class); - ArtifactRepositoryFactory artifactRepositoryFactory = plexus.lookup(ArtifactRepositoryFactory.class); - // Init repositories - ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( - true, - ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY, - ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN - ); - remoteRepositories = Collections.singletonList( // TODO add SonarSource repository with commercial plugins - artifactRepositoryFactory.createArtifactRepository( - "codehaus", - "http://repository.codehaus.org/", - new DefaultRepositoryLayout(), - policy, - policy - ) - ); - File localRepo = new File(new File(System.getProperty("user.home")), ".m2/repository"); - localRepository = artifactRepositoryFactory.createArtifactRepository( - "local", - localRepo.toURI().toURL().toExternalForm(), - new DefaultRepositoryLayout(), - policy, - policy - ); - // Do work - JSONObject obj = new JSONObject(); - - obj.put("version", "1"); // We can bump this version, when we make incompatible changes - obj.put("plugins", resolvePlugins()); - obj.put("sonar", resolveSonar()); - - if (outputDirectory != null) { - FileUtils.writeStringToFile(new File(outputDirectory, "update-center.json"), obj.toJSONString()); - } - } - - private JSONArray resolvePlugins() throws Exception { - List plugins = FileUtils.readLines(FileUtils.toFile(getClass().getResource("/plugins.txt"))); - - String pluginInfoWidgetTemplate = FileUtils.readFileToString( - FileUtils.toFile(getClass().getResource("/plugin-info-widget-template.html")) - ); - if (outputDirectory != null) { - FileUtils.copyURLToFile(getClass().getResource("/style.css"), new File(outputDirectory, "plugins/style.css")); - } - - JSONArray json = new JSONArray(); - for (String plugin : plugins) { - if (plugin.startsWith("#")) { - // Skip comments - continue; - } - History history = resolvePluginHistory(plugin); - if (history.latest() == null) { - System.out.println("WTF? " + plugin); - continue; - } - json.add(history.latest().toJsonObject()); - - Plugin latest = history.latest(); - - if (outputDirectory != null) { - String pluginInfoWidget = StringUtils.replaceEach( - pluginInfoWidgetTemplate, - new String[]{"%name%", "%version%", "%date%", "%downloadUrl%", "%sonarVersion%", "%issueTracker%", "%sources%", "%license%", "%developers%"}, - new String[]{ - latest.getName(), - latest.getVersion(), - latest.getReleaseDate(), - latest.getDownloadUrl(), - latest.getRequiredSonarVersion(), - formatLink(latest.getIssueTracker()), - formatLink(latest.getSources()), - latest.getLicense() == null ? "Unknown" : latest.getLicense(), - formatDevelopers(latest.getDevelopers()) - } - ); - FileUtils.writeStringToFile(new File(outputDirectory, "plugins/" + latest.getKey() + ".html"), pluginInfoWidget); - } - - // TODO use logger - System.out.println(latest.getName() + " : " + history.getAllVersions() + ", latest " + latest.getVersion()); - } - - return json; - } - - private String formatDevelopers(List developers) { - if (developers == null) { - return "Unknown"; - } - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < developers.size(); i++) { - if (i > 0) { - sb.append(", "); - } - sb.append(developers.get(i).getName()); - } - return sb.toString(); - } - - private String formatLink(String url) { - return StringUtils.isBlank(url) ? "Unknown" : "" + url + ""; - } - - private JSONObject resolveSonar() throws Exception { - Artifact artifact = artifactFactory.createArtifact( - "org.codehaus.sonar", - "sonar-plugin-api", - Artifact.LATEST_VERSION, - Artifact.SCOPE_COMPILE, - ARTIFACT_JAR_TYPE - ); - - List versions = filterSnapshots( - metadataSource.retrieveAvailableVersions(artifact, localRepository, remoteRepositories) - ); - History history = new History(); - for (ArtifactVersion version : versions) { - history.addArtifact(version, new Sonar(version.toString())); - } - - return history.latest().toJsonObject(); - } - - private String getDownloadUrl(String groupId, String artifactId, String version) { - // FIXME dirty hack - return "http://repository.codehaus.org/" - + StringUtils.replace(groupId, ".", "/") + "/" - + artifactId + "/" - + version + "/" - + artifactId + "-" + version + "." + ARTIFACT_JAR_TYPE; - } - - private History resolvePluginHistory(String id) throws Exception { - String groupId = StringUtils.substringBefore(id, ":"); - String artifactId = StringUtils.substringAfter(id, ":"); - - Artifact artifact = artifactFactory.createArtifact( - groupId, artifactId, Artifact.LATEST_VERSION, Artifact.SCOPE_COMPILE, ARTIFACT_JAR_TYPE - ); - - List versions = filterSnapshots( - metadataSource.retrieveAvailableVersions(artifact, localRepository, remoteRepositories) - ); - - History history = new History(); - for (ArtifactVersion version : versions) { - Plugin plugin = org.sonar.updatecenter.deprecated.Plugin.extractMetadata(resolve(artifact.getGroupId(), artifact.getArtifactId(), version.toString())); - history.addArtifact(version, plugin); - - MavenProject project = mavenProjectBuilder.buildFromRepository( - artifactFactory.createArtifact(groupId, artifactId, version.toString(), Artifact.SCOPE_COMPILE, ARTIFACT_POM_TYPE), - remoteRepositories, - localRepository - ); - - if (plugin.getVersion() == null) { - // Legacy plugin - set default values - plugin.setKey(project.getArtifactId()); - plugin.setName(project.getName()); - plugin.setVersion(project.getVersion()); - - String sonarVersion = "1.10"; // TODO Is it minimal version for all extension points ? - for (Dependency dependency : project.getDependencies()) { - if ("sonar-plugin-api".equals(dependency.getArtifactId())) { // TODO dirty hack - sonarVersion = dependency.getVersion(); - } - } - - plugin.setRequiredSonarVersion(sonarVersion); - plugin.setHomepage(project.getUrl()); - } - plugin.setDownloadUrl(getDownloadUrl(groupId, artifactId, plugin.getVersion())); - // There is no equivalent for following properties in MANIFEST.MF - if (project.getIssueManagement() != null) { - plugin.setIssueTracker(project.getIssueManagement().getUrl()); - } else { - System.out.println("Unknown Issue Management for " + plugin.getKey() + ":" + plugin.getVersion()); - } - if (project.getScm() != null) { - String scmUrl = project.getScm().getUrl(); - if (StringUtils.startsWith(scmUrl, "scm:")) { - scmUrl = StringUtils.substringAfter(StringUtils.substringAfter(scmUrl, ":"), ":"); - } - plugin.setSources(scmUrl); - } else { - System.out.println("Unknown SCM for " + plugin.getKey() + ":" + plugin.getVersion()); - } - if (project.getLicenses() != null && project.getLicenses().size() > 0) { - plugin.setLicense(project.getLicenses().get(0).getName()); - } else { - System.out.println("Unknown License for " + plugin.getKey() + ":" + plugin.getVersion()); - } - if (project.getDevelopers().size() > 0) { - plugin.setDevelopers(project.getDevelopers()); - } else { - System.out.println("Unknown Developers for " + plugin.getKey() + ":" + plugin.getVersion()); - } - } - return history; - } - - private List filterSnapshots(List versions) { - List result = new ArrayList(); - for (ArtifactVersion version : versions) { - // Ignore snapshots - if (!"SNAPSHOT".equalsIgnoreCase(version.getQualifier())) { - result.add(version); - } - } - return result; - } - - private File resolve(String groupId, String artifactId, String version) throws Exception { - return resolve(groupId, artifactId, version, ARTIFACT_JAR_TYPE); - } - - private File resolve(String groupId, String artifactId, String version, String type) throws Exception { - Artifact artifact = artifactFactory.createArtifact(groupId, artifactId, version, Artifact.SCOPE_COMPILE, type); - ArtifactResolutionRequest request = new ArtifactResolutionRequest() - .setArtifact(artifact) - .setResolveTransitively(false) - .setLocalRepository(localRepository) - .setRemoteRepositories(remoteRepositories); - artifactResolver.resolve(request); - return artifact.getFile(); - } - - public static void main(String[] args) throws Exception { - UpdateCenter updateCenter = new UpdateCenter(); - CmdLineParser p = new CmdLineParser(updateCenter); - p.parseArgument(args); - - updateCenter.run(); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/UpdateInfo.java b/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/UpdateInfo.java deleted file mode 100644 index bf65ee8a861..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/UpdateInfo.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.sonar.updatecenter.deprecated; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.annotations.XStreamAlias; -import com.thoughtworks.xstream.annotations.XStreamImplicit; - -import java.util.Arrays; -import java.util.List; - -/** - * Information about updates. - * - * @author Evgeny Mandrikov - */ -@XStreamAlias("updateInfo") -public class UpdateInfo { - - public Sonar sonar; - - @XStreamImplicit(itemFieldName = "plugin") - public List plugins; - - public UpdateInfo(Sonar sonar, List plugins) { - this.sonar = sonar; - this.plugins = plugins; - } - - public static void main(String[] args) { - XStream xstream = new XStream(); - xstream.autodetectAnnotations(true); - - Plugin plugin = new Plugin("sonar-test-plugin"); - plugin.setVersion("0.1"); - plugin.setName("Sonar Test Plugin"); - plugin.setDescription("Test"); - plugin.setHomepage("http://homepage"); - plugin.setDownloadUrl("http://download"); - plugin.setRequiredSonarVersion("2.0"); - - System.out.println(xstream.toXML(new UpdateInfo(new Sonar("2.0"), Arrays.asList(plugin)))); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/Versioned.java b/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/Versioned.java deleted file mode 100644 index fc50234c990..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/deprecated/Versioned.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.updatecenter.deprecated; - -/** - * @author Evgeny Mandrikov - */ -public interface Versioned { - String getVersion(); -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/server/Configuration.java b/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/server/Configuration.java deleted file mode 100644 index 165b7883562..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/server/Configuration.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.updatecenter.server; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.util.Properties; - -public class Configuration { - - public static final String WORKING_DIR = "workingDir"; - public static final String OUTPUT_FILE = "outputFile"; - public static final String SOURCE_PATH = "path"; - public static final String SOURCE_LOGIN = "login"; - public static final String SOURCE_PASSWORD = "password"; - - private static Logger LOG = LoggerFactory.getLogger(Configuration.class); - private Properties props; - private File workingDir = null; - - public Configuration(Properties props) { - this.props = props; - } - - public void log() { - LOG.info("-------------------------------"); - LOG.info(WORKING_DIR + ": " + getWorkingDir().getPath()); - LOG.info(OUTPUT_FILE + ": " + getOutputFile().getPath()); - LOG.info(SOURCE_PATH + ": " + getSourcePath()); - LOG.info(SOURCE_LOGIN + ": " + getSourceLogin()); - LOG.info(SOURCE_PASSWORD + ": " + getSourcePassword()); - LOG.info("-------------------------------"); - } - - public File getWorkingDir() { - if (workingDir == null) { - String path = props.getProperty(WORKING_DIR); - if (StringUtils.isBlank(path)) { - workingDir = new File(System.getProperty("user.home"), ".sonar-update-center"); - } else { - workingDir = new File(path); - } - try { - FileUtils.forceMkdir(workingDir); - - } catch (IOException e) { - throw new RuntimeException("Fail to create the working directory: " + workingDir.getAbsolutePath(), e); - } - } - return workingDir; - } - - public File getOutputFile() { - String path = props.getProperty(OUTPUT_FILE); - if (StringUtils.isNotBlank(path)) { - return new File(path); - } - return new File(getWorkingDir(), "generated-sonar-updates.properties"); - } - - public String getSourcePath() { - return props.getProperty(SOURCE_PATH); - } - - public String getSourceLogin() { - return props.getProperty(SOURCE_LOGIN); - } - - public String getSourcePassword() { - return props.getProperty(SOURCE_PASSWORD); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/server/HttpDownloader.java b/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/server/HttpDownloader.java deleted file mode 100644 index 59026bb1b5c..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/server/HttpDownloader.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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.updatecenter.server; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.http.client.ResponseHandler; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.util.EntityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - -public class HttpDownloader { - private static Logger LOG = LoggerFactory.getLogger(HttpDownloader.class); - - private File outputDir; - - public HttpDownloader(File outputDir) { - this.outputDir = outputDir; - } - - public File download(String url, boolean force) throws IOException, URISyntaxException { - return download(url, force, null, null); - } - public File download(String url, boolean force, String login, String password) throws IOException, URISyntaxException { - FileUtils.forceMkdir(outputDir); - - String filename = StringUtils.substringAfterLast(url, "/"); - File output = new File(outputDir, filename); - if (force || !output.exists() || output.length() <= 0) { - downloadFile(new URI(url), output, login, password); - } else { - LOG.info("Already downloaded: " + url); - } - return output; - } - - File downloadFile(URI fileURI, File toFile, String login, String password) { - LOG.info("Download " + fileURI + " in " + toFile); - DefaultHttpClient client = new DefaultHttpClient(); - try { - if (StringUtils.isNotBlank(login)) { - client.getCredentialsProvider().setCredentials( - new AuthScope(fileURI.getHost(), fileURI.getPort()), - new UsernamePasswordCredentials(login, password)); - } - HttpGet httpget = new HttpGet(fileURI); - byte[] data = client.execute(httpget, new ByteResponseHandler()); - if (data != null) { - FileUtils.writeByteArrayToFile(toFile, data); - } - - } catch (Exception e) { - LOG.error("Fail to download " + fileURI + " to " + toFile, e); - FileUtils.deleteQuietly(toFile); - - } finally { - client.getConnectionManager().shutdown(); - } - return toFile; - } - - static class ByteResponseHandler implements ResponseHandler { - public byte[] handleResponse(HttpResponse response) throws IOException { - HttpEntity entity = response.getEntity(); - if (response.getStatusLine().getStatusCode()!=200) { - throw new RuntimeException("Unvalid HTTP response: " + response.getStatusLine()); - } - if (entity != null) { - return EntityUtils.toByteArray(entity); - } - return null; - } - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/server/MetadataFile.java b/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/server/MetadataFile.java deleted file mode 100644 index a0207021726..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/server/MetadataFile.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.updatecenter.server; - -import org.sonar.updatecenter.common.UpdateCenter; -import org.sonar.updatecenter.common.UpdateCenterDeserializer; - -import java.io.File; -import java.io.IOException; - -public final class MetadataFile { - - private Configuration conf; - private HttpDownloader downloader; - - public MetadataFile(Configuration conf, HttpDownloader downloader) { - this.conf = conf; - this.downloader = downloader; - } - - public File getFile() { - try { - File file; - if (isRemote()) { - file = downloader.download(conf.getSourcePath(), true, conf.getSourceLogin(), conf.getSourcePassword()); - } else { - file = new File(conf.getSourcePath()); - } - if (!file.exists()) { - throw new RuntimeException("The metadata file does not exist: " + file.getPath()); - } - return file; - - } catch (RuntimeException e) { - throw e; - - } catch (Exception e) { - throw new RuntimeException("Can not open the metadata file: " + conf.getSourcePath(), e); - } - } - - public UpdateCenter getUpdateCenter() { - File file = getFile(); - try { - return UpdateCenterDeserializer.fromProperties(file); - - } catch (IOException e) { - throw new RuntimeException("Can not read properties from: " + file.getPath(), e); - } - } - - private boolean isRemote() { - return conf.getSourcePath().startsWith("http"); - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/server/Server.java b/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/server/Server.java deleted file mode 100644 index 4288ba2e8a1..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/java/org/sonar/updatecenter/server/Server.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.updatecenter.server; - -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.sonar.updatecenter.common.*; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; - -public final class Server { - private static Logger LOG = LoggerFactory.getLogger(Server.class); - - public void start() throws IOException, URISyntaxException { - Configuration conf = new Configuration(System.getProperties()); - conf.log(); - HttpDownloader downloader = new HttpDownloader(conf.getWorkingDir()); - UpdateCenter center = buildFromPartialMetadata(conf, downloader); - downloadReleases(downloader, center); - generateMetadata(conf, center); - } - - private UpdateCenter buildFromPartialMetadata(Configuration conf, HttpDownloader downloader) { - return new MetadataFile(conf, downloader).getUpdateCenter(); - } - - private void downloadReleases(HttpDownloader downloader, UpdateCenter center) throws IOException, URISyntaxException { - for (Plugin plugin : center.getPlugins()) { - LOG.info("Load plugin: " + plugin.getKey()); - - File masterJar = null; - for (Release release : plugin.getReleases()) { - if (StringUtils.isNotBlank(release.getDownloadUrl())) { - File jar = downloader.download(release.getDownloadUrl(), false); - if (jar!= null && jar.exists()) { - masterJar = jar; - } else { - release.setDownloadUrl(null); - LOG.warn("Ignored because of wrong downloadUrl: plugin " + plugin.getKey() + ", version " + release.getVersion()); - } - - } else { - LOG.warn("Ignored because of missing downloadUrl: plugin " + plugin.getKey() + ", version " + release.getVersion()); - } - } - - // the last release is the master version for loading metadata included in manifest - if (masterJar != null) { - plugin.merge(new PluginManifest(masterJar)); - } - } - } - - private void generateMetadata(Configuration conf, UpdateCenter center) { - LOG.info("Generate output: " + conf.getOutputFile()); - UpdateCenterSerializer.toProperties(center, conf.getOutputFile()); - } - - public static void main(String[] args) throws IOException, URISyntaxException { - new Server().start(); - } - -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/resources/log4j.properties b/subprojects/sonar-update-center/sonar-update-center-server/src/main/resources/log4j.properties deleted file mode 100644 index be19b35722a..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/resources/log4j.properties +++ /dev/null @@ -1,6 +0,0 @@ -log4j.rootCategory=INFO, stdout - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout - -log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/resources/plugin-info-widget-template.html b/subprojects/sonar-update-center/sonar-update-center-server/src/main/resources/plugin-info-widget-template.html deleted file mode 100644 index ef9b7df47ce..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/resources/plugin-info-widget-template.html +++ /dev/null @@ -1,49 +0,0 @@ - - - %name% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name%name%
Latest version%version% ( %date% )
Requires Sonar version - %sonarVersion% or higher - ( check version compatibility ) -
Download%downloadUrl%
License%license%
Developers%developers%
Issue tracker%issueTracker%
Sources%sources%
- - diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/resources/plugins.txt b/subprojects/sonar-update-center/sonar-update-center-server/src/main/resources/plugins.txt deleted file mode 100644 index 017fbc23e66..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/resources/plugins.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# Open-source plugins -# -org.codehaus.sonar-plugins:sonar-artifact-size-plugin -org.codehaus.sonar-plugins:sonar-build-breaker-plugin -org.codehaus.sonar-plugins:sonar-build-stability-plugin -org.codehaus.sonar-plugins:sonar-c-rules-plugin -org.codehaus.sonar-plugins:sonar-clirr-plugin -org.codehaus.sonar-plugins:sonar-cutoff-plugin -org.codehaus.sonar-plugins:sonar-crowd-plugin -org.codehaus.sonar-plugins:sonar-emma-plugin -org.codehaus.sonar-plugins:sonar-flex-plugin -org.codehaus.sonar-plugins:sonar-greenpepper-plugin -org.codehaus.sonar-plugins:sonar-jacoco-plugin -org.codehaus.sonar-plugins:sonar-jira-plugin -org.codehaus.sonar-plugins:sonar-ldap-plugin -org.codehaus.sonar-plugins:sonar-motion-chart-plugin -org.codehaus.sonar-plugins.pdf-report:sonar-pdfreport-plugin -org.codehaus.sonar-plugins:sonar-php-plugin -org.codehaus.sonar-plugins:sonar-piwik-plugin -org.codehaus.sonar-plugins:sonar-plugin-taglist -org.codehaus.sonar-plugins:sonar-quality-index-plugin -org.codehaus.sonar-plugins:sonar-radiator-plugin -org.codehaus.sonar-plugins:sonar-rulesmeter-plugin -org.codehaus.sonar-plugins:sonar-security-rules-plugin -org.codehaus.sonar-plugins:sonar-sigmm-plugin -org.codehaus.sonar-plugins:sonar-sonarj-plugin -org.codehaus.sonar-plugins:sonar-taglist-plugin -org.codehaus.sonar-plugins:sonar-technicaldebt-plugin -org.codehaus.sonar-plugins:sonar-timeline-plugin -org.codehaus.sonar-plugins:sonar-total-quality-plugin -org.codehaus.sonar-plugins:sonar-trac-plugin -org.codehaus.sonar-plugins:sonar-twitter-plugin -org.codehaus.sonar-plugins.scm-activity:sonar-scm-activity-plugin -org.codehaus.sonar-plugins:sonar-groovy-plugin -org.codehaus.sonar-plugins:sonar-web-plugin -org.codehaus.sonar-plugins:sonar-useless-code-tracker-plugin diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/main/resources/style.css b/subprojects/sonar-update-center/sonar-update-center-server/src/main/resources/style.css deleted file mode 100644 index a3215e49890..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/main/resources/style.css +++ /dev/null @@ -1,29 +0,0 @@ -body { - font-family: Verdana,arial,sans-serif; - font-size: 9pt; -} -a { - color: #036; -} -table { - border-collapse: collapse; - width: 100%; -} -table td { - border: 1px #CCC solid; - padding: 3px; - font-size: 9pt; -} -th { - text-align: left; -} -.button { - background: #3C78B5; - text-align: center; - border-radius: 3px; - display: block; - padding: 5px; - cursor: pointer; - margin: 5px; - color: white; -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/test/java/org/sonar/updatecenter/deprecated/HistoryTest.java b/subprojects/sonar-update-center/sonar-update-center-server/src/test/java/org/sonar/updatecenter/deprecated/HistoryTest.java deleted file mode 100644 index f0563ee42f1..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/test/java/org/sonar/updatecenter/deprecated/HistoryTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.updatecenter.deprecated; - -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * @author Evgeny Mandrikov - */ -public class HistoryTest { - @Test - public void testLatest() { - History history = new History(); - - history.addArtifact(new DefaultArtifactVersion("0.1"), newPlugin("0.1")); - assertEquals(1, history.getAllVersions().size()); - assertEquals("0.1", history.latest().getVersion()); - - history.addArtifact(new DefaultArtifactVersion("1.0"), newPlugin("1.0")); - assertEquals(2, history.getAllVersions().size()); - assertEquals("1.0", history.latest().getVersion()); - - history.addArtifact(new DefaultArtifactVersion("0.2"), newPlugin("0.2")); - assertEquals(3, history.getAllVersions().size()); - assertEquals("1.0", history.latest().getVersion()); - } - - private Plugin newPlugin(String version) { - Plugin plugin = new Plugin(version); - plugin.setVersion(version); - return plugin; - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/test/java/org/sonar/updatecenter/deprecated/PluginTest.java b/subprojects/sonar-update-center/sonar-update-center-server/src/test/java/org/sonar/updatecenter/deprecated/PluginTest.java deleted file mode 100644 index 95914a870e3..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/test/java/org/sonar/updatecenter/deprecated/PluginTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.updatecenter.deprecated; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * @author Evgeny Mandrikov - */ -public class PluginTest { - @Test - public void testToJsonObject() { - /* - Plugin plugin = new Plugin("org.sonar.plugins.test.Test"); - plugin.setVersion("0.1"); - plugin.setName("Sonar Test Plugin"); - plugin.setRequiredSonarVersion("2.0"); - assertEquals( - "{\"sonarVersion\":\"2.0\"" + - ",\"id\":\"org.sonar.plugins.test.Test\"" + - ",\"name\":\"Sonar Test Plugin\"" + - ",\"version\":\"0.1\"" + - "}", - plugin.toJsonObject().toJSONString() - ); - - plugin.setDownloadUrl("http://download"); - plugin.setHomepage("http://homepage"); - assertEquals( - "{\"sonarVersion\":\"2.0\"" + - ",\"id\":\"org.sonar.plugins.test.Test\"" + - ",\"name\":\"Sonar Test Plugin\"" + - ",\"downloadUrl\":\"http:\\/\\/download\"" + - ",\"homepage\":\"http:\\/\\/homepage\"" + - ",\"version\":\"0.1\"" + - "}", - plugin.toJsonObject().toJSONString() - ); - */ - } -} diff --git a/subprojects/sonar-update-center/sonar-update-center-server/src/test/java/org/sonar/updatecenter/deprecated/SonarTest.java b/subprojects/sonar-update-center/sonar-update-center-server/src/test/java/org/sonar/updatecenter/deprecated/SonarTest.java deleted file mode 100644 index efcae7fe7f8..00000000000 --- a/subprojects/sonar-update-center/sonar-update-center-server/src/test/java/org/sonar/updatecenter/deprecated/SonarTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.updatecenter.deprecated; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * @author Evgeny Mandrikov - */ -public class SonarTest { - @Test - public void testToJsonObject() throws Exception { - /* - assertEquals( - "{\"downloadUrl\":\"http:\\/\\/dist.sonar.codehaus.org\\/sonar-2.0.zip\"" + - ",\"version\":\"2.0\"" + - "}", - new Sonar("2.0").toJsonObject().toJSONString() - ); - */ - } -}