aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/sonar-dev-maven-plugin
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-09-06 14:08:06 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-09-06 14:08:06 +0000
commitaeadc1f9129274949daaa57738c7c4550bdfbc7b (patch)
tree08dadf5ef7474fc41d1d48f74648f1ba8b55f34d /subprojects/sonar-dev-maven-plugin
downloadsonarqube-aeadc1f9129274949daaa57738c7c4550bdfbc7b.tar.gz
sonarqube-aeadc1f9129274949daaa57738c7c4550bdfbc7b.zip
SONAR-236 remove deprecated code from checkstyle plugin + display default value of rule parameters in Q profile console
Diffstat (limited to 'subprojects/sonar-dev-maven-plugin')
-rw-r--r--subprojects/sonar-dev-maven-plugin/RELEASE_NOTES.txt13
-rw-r--r--subprojects/sonar-dev-maven-plugin/pom.xml426
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/java/org/sonar/dev/TrimMojo.java157
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/create-db.sql0
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/create-user.sql0
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/drop-db.sql0
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/drop-user.sql0
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/create-db.sql3
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/create-user.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/drop-db.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/drop-user.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/create-db.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/create-user.sql3
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/drop-db.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/drop-user.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/create-db.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/create-user.sql5
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/drop-db.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/drop-user.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/create-db.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/create-user.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/drop-db.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/drop-user.sql1
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/license/AL2.txt14
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/license/LGPL3.txt17
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/server/sonar.properties103
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/resources/server/wrapper.conf121
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/scripts/start-stop.build.xml451
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/main/scripts/start-stop.mojos.xml362
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/test/java/org/sonar/dev/TrimMojoTest.java106
-rw-r--r--subprojects/sonar-dev-maven-plugin/src/test/resources/org/sonar/dev/TrimMojoTest/whitespace-indented.txt9
31 files changed, 1803 insertions, 0 deletions
diff --git a/subprojects/sonar-dev-maven-plugin/RELEASE_NOTES.txt b/subprojects/sonar-dev-maven-plugin/RELEASE_NOTES.txt
new file mode 100644
index 00000000000..5f15a84a3d0
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/RELEASE_NOTES.txt
@@ -0,0 +1,13 @@
+Temporary release notes - waiting for a dedicated project/component in JIRA
+
+-------------------------------------------------------------------------------
+Upgrade from sonar-dev-mojo 2.2-SNAPSHOT to sonar-dev-maven-plugin 1.0-SNAPSHOT
+-------------------------------------------------------------------------------
+* Remove the parameter 'environment'
+* The goal 'stop' requires the parameter 'sonar.runtimeVersion'
+* The goals 'start' and 'stop' now use the standalone mode (Jetty)
+* Add the goals 'start-war' and 'stop-war' to use the WAR mode (Tomcat)
+* Increase allocated memory (needed for Derby tests)
+* Add predefined database profiles. For example selecting database=mysql sets default url and driver for MySQL.
+* Add the goal "analyze" with required parameter "sonar.projectsDir". It replaces the parameters "mavenProjectsDir" and "analyzeProjects"
+
diff --git a/subprojects/sonar-dev-maven-plugin/pom.xml b/subprojects/sonar-dev-maven-plugin/pom.xml
new file mode 100644
index 00000000000..c3352e46636
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/pom.xml
@@ -0,0 +1,426 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-dev-maven-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>maven-plugin</packaging>
+ <name>Sonar :: Development Maven Plugin</name>
+ <description>Maven plugin for Sonar development environment</description>
+
+ <repositories>
+ <repository>
+ <id>sonar</id>
+ <url>http://repository.sonarsource.org/content/repositories/sonar</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <inceptionYear>2010</inceptionYear>
+ <organization>
+ <name>SonarSource</name>
+ <url>http://www.sonarsource.com</url>
+ </organization>
+ <licenses>
+ <license>
+ <name>GNU Lesser General Public License (LGPL), v.3</name>
+ <url>http://www.gnu.org/licenses/lgpl.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <developers>
+ <developer>
+ <id>simon.brandhof</id>
+ <name>Simon Brandhof</name>
+ <email>simon.brandhof@sonarsource.com</email>
+ <organization>SonarSource</organization>
+ <roles>
+ <role>developer</role>
+ </roles>
+ <timezone>+1</timezone>
+ </developer>
+ <developer>
+ <id>godin</id>
+ <name>Evgeny Mandrikov</name>
+ <email>mandrikov@gmail.com</email>
+ <roles>
+ <role>developer</role>
+ </roles>
+ <timezone>+3</timezone>
+ </developer>
+ </developers>
+
+ <scm>
+ <connection>scm:svn:http://svn.codehaus.org/sonar/trunk/subprojects/sonar-dev-maven-plugin</connection>
+ <developerConnection>scm:svn:https://svn.codehaus.org/sonar/trunk/subprojects/sonar-dev-maven-plugin</developerConnection>
+ <url>https://svn.codehaus.org/sonar/trunk/subprojects/sonar-dev-maven-plugin</url>
+ </scm>
+
+ <issueManagement>
+ <system>jira</system>
+ <url>http://jira.codehaus.org/browse/SONAR</url>
+ </issueManagement>
+ <ciManagement>
+ <system>bamboo</system>
+ <url>http://bamboo.ci.codehaus.org/browse/SONAR</url>
+ </ciManagement>
+ <distributionManagement>
+ <repository>
+ <id>codehaus.org</id>
+ <url>dav:https://dav.codehaus.org/repository/sonar</url>
+ <uniqueVersion>false</uniqueVersion>
+ </repository>
+ <snapshotRepository>
+ <id>codehaus.org</id>
+ <url>dav:https://dav.codehaus.org/snapshots.repository/sonar</url>
+ <uniqueVersion>false</uniqueVersion>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.min.version>2.0</maven.min.version>
+ <jdk.min.version>1.5</jdk.min.version>
+ <mavenVersion>2.0.9</mavenVersion>
+ </properties>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <!-- Plugins ordered by shortname (archetype, assembly ...) -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.5</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.0-beta-1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>2.3</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>1.5</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.3</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.6.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>2.6</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-ant</artifactId>
+ <version>2.6</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.4.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>2.0-beta-7</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.1.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.5</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>enforce</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireMavenVersion>
+ <message>To build this project Maven ${maven.min.version} (or upper) is required. Please install it.
+ </message>
+ <version>${maven.min.version}</version>
+ </requireMavenVersion>
+ <requireJavaVersion>
+ <message>To build this project JDK ${jdk.min.version} (or upper) is required. Please install it.
+ </message>
+ <version>${jdk.min.version}</version>
+ </requireJavaVersion>
+ <requirePluginVersions>
+ <!-- TODO
+ This rule produces warning under maven-3.0-beta-1 :
+ "This rule is not compatible with the current version of Maven."
+ -->
+ <message>Build reproducibility : always define plugin versions</message>
+ <banLatest>true</banLatest>
+ <banRelease>true</banRelease>
+ <phases>clean,deploy</phases>
+ </requirePluginVersions>
+ <!--bannedDependencies>
+ <message>Don't use banned dependencies</message>
+ <searchTransitive>true</searchTransitive>
+ <excludes>
+ <exclude>commons-logging:commons-logging</exclude>
+ </excludes>
+ </bannedDependencies-->
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${jdk.min.version}</source>
+ <target>${jdk.min.version}</target>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <version>1.6</version>
+ <executions>
+ <execution>
+ <id>check-java-version</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <configuration>
+ <signature>
+ <groupId>org.codehaus.mojo.signature</groupId>
+ <artifactId>java15</artifactId>
+ <version>1.0</version>
+ </signature>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <tagBase>https://svn.codehaus.org/sonar/tags</tagBase>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>fikin</groupId>
+ <artifactId>fikin-ant</artifactId>
+ <version>1.7.3</version>
+ </dependency>
+ <dependency>
+ <groupId>ant-contrib</groupId>
+ <artifactId>ant-contrib</artifactId>
+ <version>1.0b3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- maven -->
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-archiver</artifactId>
+ <version>2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${mavenVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-script-ant</artifactId>
+ <version>2.0.10</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.5.6</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-ant</artifactId>
+ <version>1.0-beta-2</version>
+ <exclusions>
+ <exclusion>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- JDBC drivers are used when the database is created (property dropDatabase is true) -->
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derbyclient</artifactId>
+ <version>10.4.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>8.3-603.jdbc3</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.jtds</groupId>
+ <artifactId>jtds</artifactId>
+ <version>1.2.2</version>
+ </dependency>
+
+ <!-- fikin dependencies -->
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.9.1</version>
+ </dependency>
+
+ <!-- unit tests -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-all</artifactId>
+ <version>1.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/java/org/sonar/dev/TrimMojo.java b/subprojects/sonar-dev-maven-plugin/src/main/java/org/sonar/dev/TrimMojo.java
new file mode 100644
index 00000000000..abe8e8df8bb
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/java/org/sonar/dev/TrimMojo.java
@@ -0,0 +1,157 @@
+/*
+ * 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.dev;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.LineIterator;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @goal trim
+ */
+public class TrimMojo extends AbstractMojo {
+
+ /**
+ * @parameter
+ * @required
+ */
+ private File directory;
+
+ /**
+ * List of ant-style patterns. If
+ * this is not specified, allfiles in the project source directories are included.
+ *
+ * @parameter
+ */
+ private String[] includes;
+
+ /**
+ * @parameter
+ */
+ private String[] excludes;
+
+
+ /**
+ * Specifies the encoding of the source files.
+ *
+ * @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
+ */
+ private String sourceEncoding;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ if (shouldExecute()) {
+ trimDirectory();
+ }
+ }
+
+ private void trimDirectory() throws MojoExecutionException {
+ File[] files = scanFiles();
+ for (File file : files) {
+ StringBuilder sb = new StringBuilder();
+ try {
+ LineIterator lines = FileUtils.lineIterator(file, sourceEncoding);
+ while (lines.hasNext()) {
+ String line = lines.nextLine();
+ if (StringUtils.isNotBlank(line)) {
+ sb.append(StringUtils.trim(line));
+ sb.append(IOUtils.LINE_SEPARATOR);
+ }
+ }
+ FileUtils.writeStringToFile(file, sb.toString(), sourceEncoding);
+
+ } catch (IOException e) {
+ throw new MojoExecutionException("Can not trim the file " + file, e);
+ }
+ }
+ getLog().info("Trimmed files: " + files.length);
+ }
+
+ private boolean shouldExecute() {
+ return directory != null && directory.exists();
+ }
+
+ /**
+ * gets a list of all files in the source directory.
+ *
+ * @return the list of all files in the source directory;
+ */
+ private File[] scanFiles() {
+ String[] defaultIncludes = {"**\\*"};
+ DirectoryScanner ds = new DirectoryScanner();
+ if (includes == null) {
+ ds.setIncludes(defaultIncludes);
+ } else {
+ ds.setIncludes(includes);
+ }
+ ds.addDefaultExcludes(); // .svn, ...
+ if (excludes != null) {
+ ds.setExcludes(excludes);
+ }
+ ds.setBasedir(directory);
+ getLog().info("Scanning directory " + directory);
+ ds.scan();
+ int maxFiles = ds.getIncludedFiles().length;
+ File[] result = new File[maxFiles];
+ for (int i = 0; i < maxFiles; i++) {
+ result[i] = new File(directory, ds.getIncludedFiles()[i]);
+ }
+ return result;
+ }
+
+ public File getDirectory() {
+ return directory;
+ }
+
+ public void setDirectory(File directory) {
+ this.directory = directory;
+ }
+
+ public String[] getIncludes() {
+ return includes;
+ }
+
+ public void setIncludes(String[] includes) {
+ this.includes = includes;
+ }
+
+ public String[] getExcludes() {
+ return excludes;
+ }
+
+ public void setExcludes(String[] excludes) {
+ this.excludes = excludes;
+ }
+
+ public String getSourceEncoding() {
+ return sourceEncoding;
+ }
+
+ public void setSourceEncoding(String sourceEncoding) {
+ this.sourceEncoding = sourceEncoding;
+ }
+}
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/create-db.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/create-db.sql
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/create-db.sql
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/create-user.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/create-user.sql
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/create-user.sql
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/drop-db.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/drop-db.sql
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/drop-db.sql
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/drop-user.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/drop-user.sql
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/derby/drop-user.sql
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/create-db.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/create-db.sql
new file mode 100644
index 00000000000..fc12f2a622e
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/create-db.sql
@@ -0,0 +1,3 @@
+create database ${sonar.jdbc.username};
+USE ${sonar.jdbc.username};
+sp_addalias ${sonar.jdbc.username}, dbo;
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/create-user.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/create-user.sql
new file mode 100644
index 00000000000..66a82965dc4
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/create-user.sql
@@ -0,0 +1 @@
+CREATE LOGIN ${sonar.jdbc.username} WITH PASSWORD = '${sonar.jdbc.password}', CHECK_POLICY=OFF;
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/drop-db.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/drop-db.sql
new file mode 100644
index 00000000000..ad92da2ded4
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/drop-db.sql
@@ -0,0 +1 @@
+drop database ${sonar.jdbc.username}; \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/drop-user.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/drop-user.sql
new file mode 100644
index 00000000000..e5fa30a9a26
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mssql/drop-user.sql
@@ -0,0 +1 @@
+drop login ${sonar.jdbc.username}; \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/create-db.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/create-db.sql
new file mode 100644
index 00000000000..e3a1eca1e38
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/create-db.sql
@@ -0,0 +1 @@
+create database ${sonar.jdbc.username} character set utf8; \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/create-user.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/create-user.sql
new file mode 100644
index 00000000000..de353c36070
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/create-user.sql
@@ -0,0 +1,3 @@
+create user '${sonar.jdbc.username}' IDENTIFIED BY '${sonar.jdbc.password}';
+GRANT ALL ON ${sonar.jdbc.username}.* TO '${sonar.jdbc.username}'@'%' IDENTIFIED BY '${sonar.jdbc.password}';
+GRANT ALL ON ${sonar.jdbc.username}.* TO '${sonar.jdbc.username}'@'localhost' IDENTIFIED BY '${sonar.jdbc.password}'; \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/drop-db.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/drop-db.sql
new file mode 100644
index 00000000000..9f97c9ae458
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/drop-db.sql
@@ -0,0 +1 @@
+drop database IF EXISTS ${sonar.jdbc.username}; \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/drop-user.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/drop-user.sql
new file mode 100644
index 00000000000..aaf18e4eaad
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/mysql/drop-user.sql
@@ -0,0 +1 @@
+drop user '${sonar.jdbc.username}'@'%'; \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/create-db.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/create-db.sql
new file mode 100644
index 00000000000..eef971b76be
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/create-db.sql
@@ -0,0 +1 @@
+// nothing to do under oracle \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/create-user.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/create-user.sql
new file mode 100644
index 00000000000..49b09decb97
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/create-user.sql
@@ -0,0 +1,5 @@
+CREATE USER ${sonar.jdbc.username} IDENTIFIED BY ${sonar.jdbc.password} DEFAULT TABLESPACE USERS ACCOUNT UNLOCK;
+GRANT CONNECT TO ${sonar.jdbc.username};
+GRANT RESOURCE TO ${sonar.jdbc.username};
+GRANT CREATE TABLE to ${sonar.jdbc.username};
+GRANT CREATE SEQUENCE to ${sonar.jdbc.username}; \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/drop-db.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/drop-db.sql
new file mode 100644
index 00000000000..eef971b76be
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/drop-db.sql
@@ -0,0 +1 @@
+// nothing to do under oracle \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/drop-user.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/drop-user.sql
new file mode 100644
index 00000000000..299ec925be6
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/oracle/drop-user.sql
@@ -0,0 +1 @@
+DROP USER ${sonar.jdbc.username} CASCADE; \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/create-db.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/create-db.sql
new file mode 100644
index 00000000000..2cdda76defc
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/create-db.sql
@@ -0,0 +1 @@
+CREATE DATABASE ${sonar.jdbc.username}; \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/create-user.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/create-user.sql
new file mode 100644
index 00000000000..d3cf35a438d
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/create-user.sql
@@ -0,0 +1 @@
+CREATE USER ${sonar.jdbc.username} WITH PASSWORD '${sonar.jdbc.password}' CREATEDB; \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/drop-db.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/drop-db.sql
new file mode 100644
index 00000000000..12cca84099b
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/drop-db.sql
@@ -0,0 +1 @@
+DROP DATABASE IF EXISTS ${sonar.jdbc.username}; \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/drop-user.sql b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/drop-user.sql
new file mode 100644
index 00000000000..319856fac78
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/database/postgresql/drop-user.sql
@@ -0,0 +1 @@
+DROP USER IF EXISTS ${sonar.jdbc.username}; \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/license/AL2.txt b/subprojects/sonar-dev-maven-plugin/src/main/resources/license/AL2.txt
new file mode 100644
index 00000000000..2550cc485b1
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/license/AL2.txt
@@ -0,0 +1,14 @@
+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-dev-maven-plugin/src/main/resources/license/LGPL3.txt b/subprojects/sonar-dev-maven-plugin/src/main/resources/license/LGPL3.txt
new file mode 100644
index 00000000000..e7f3cc3e5ad
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/license/LGPL3.txt
@@ -0,0 +1,17 @@
+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-dev-maven-plugin/src/main/resources/server/sonar.properties b/subprojects/sonar-dev-maven-plugin/src/main/resources/server/sonar.properties
new file mode 100644
index 00000000000..2dd5f5fca27
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/server/sonar.properties
@@ -0,0 +1,103 @@
+#--------------------------------------------------------
+# To use an environment variable, use the following syntax : ${env:NAME_OF_ENV_VARIABLE}
+# For example :
+# sonar.jdbc.url: ${env:SONAR_JDBC_URL}
+#
+#
+# See also the file conf/wrapper.conf for JVM advanced settings
+#---------------------------------------------------------
+
+
+#---------------------------------------------------------
+# WEB
+#---------------------------------------------------------
+# Listen host/port and context path (for example / or /sonar). Default values are 0.0.0.0:9000/
+# ONLY IF STANDALONE MODE. NOT USED IF DEPLOYED AS A WAR.
+#sonar.web.host: 0.0.0.0
+#sonar.web.port: 9000
+#sonar.web.context: /
+
+# Apache mod_jk connector. Supported only in standalone mode.
+# Uncomment to activate AJP13 connector.
+#sonar.ajp13.port: 8009
+
+#---------------------------------------------------------
+# DATABASE
+#---------------------------------------------------------
+
+#----- Embedded database
+# Comment the following lines to deactivate the default embedded database (used only for tests and demos)
+#sonar.jdbc.url: jdbc:derby://localhost:1527/sonar;create=true
+#sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
+#sonar.jdbc.validationQuery: values(1)
+# data directory, autodetected : /data if standalone application, /WEB-INF/classes/data if WAR deployement (exploded mode)
+#sonar.embeddedDatabase.dataDir:
+# derby embedded database server listening port, defaults to 1527
+#sonar.derby.drda.portNumber: 1527
+
+#----- MySQL 5.x/6.x
+# Comment the embedded database and uncomment the following lines to use MySQL
+#sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
+#sonar.jdbc.driverClassName: com.mysql.jdbc.Driver
+#sonar.jdbc.validationQuery: select 1
+
+
+#----- Oracle 10g/11g
+# Comment the embedded database and uncomment the following lines to use Oracle
+#sonar.jdbc.url: jdbc:oracle:thin:@localhost/XE
+#sonar.jdbc.driverClassName: oracle.jdbc.driver.OracleDriver
+#sonar.jdbc.validationQuery: select 1 from dual
+
+# Activate if more than one Sonar Oracle schemas on the data server (for example different versions installed).
+# In that case, use the same property during maven analysis (-Dsonar.hibernate.default_schema=xxx)
+#sonar.hibernate.default_schema: sonar
+
+#----- PostgreSQL 8.x
+# uncomment the 3 following lines to use PostgreSQL
+#sonar.jdbc.url: jdbc:postgresql://localhost/sonar
+#sonar.jdbc.driverClassName: org.postgresql.Driver
+#sonar.jdbc.validationQuery: select 1
+
+
+#----- Microsoft SQLServer - NOT TESTED and NOT SUPPORTED.
+# The Jtds open source driver is available in extensions/jdbc-driver/mssql. More details on http://jtds.sourceforge.
+#sonar.jdbc.url: jdbc:jtds:sqlserver://localhost;databaseName=SONAR;SelectMethod=Cursor
+#sonar.jdbc.driverClassName: net.sourceforge.jtds.jdbc.Driver
+#sonar.jdbc.validationQuery: select 1
+
+
+#----- Global database settings
+#sonar.jdbc.username: sonar
+#sonar.jdbc.password: sonar
+sonar.jdbc.maxActive: 10
+sonar.jdbc.maxIdle: 5
+sonar.jdbc.minIdle: 2
+sonar.jdbc.maxWait: 5000
+sonar.jdbc.minEvictableIdleTimeMillis: 600000
+sonar.jdbc.timeBetweenEvictionRunsMillis: 30000
+
+# Transaction isolation level. Default driver setting is used by default.
+# Values : 1 (TRANSACTION_READ_UNCOMMITED), 2 (TRANSACTION_READ_COMMITTED), 4 (TRANSACTION_REPEATABLE_READ), 8 (TRANSACTION_SERIALIZABLE)
+#sonar.jdbc.defaultTransactionIsolation: 2
+
+
+# When packaged in a WAR, JDBC datasource can be configured into the application server then registered to JNDI.
+# In such a case Sonar uses this datasource to connect to database, else if binds itself its own datasource.
+# Note : Jonas does not accept to bind subcontexts, so name should be something like 'jdbc-sonar', without slashes.
+#sonar.jdbc.jndiName: jdbc/sonar
+
+# If you don't use the default JDBC drivers, as listed above, then you have to explicitly set the dialect to use.
+# Values are : mysql, derby, oracle, postgresql
+#sonar.jdbc.dialect=
+
+
+#---------------------------------------------------------
+# EXTENSIONS
+#---------------------------------------------------------
+# Absolute path of coding rules extensions (custom rules that are not provided with tools like Checkstyle or PMD).
+# This parameter is useful when Sonar is deployed as a WAR. It avoids from packaging the WAR file each time extensions JARs are updated.
+# The directory contains subdirectories like checkstyle/ and pmd/
+# Example :
+# sonar.rules.extensionsPath: /user/home/jdoe/sonar/extensions
+# Example for windows platform (backslash char must be escaped) :
+# sonar.rules.extensionsPath: D:\\softwares\\sonar-1.8\\extensions
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/resources/server/wrapper.conf b/subprojects/sonar-dev-maven-plugin/src/main/resources/server/wrapper.conf
new file mode 100644
index 00000000000..232e2fb8d02
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/resources/server/wrapper.conf
@@ -0,0 +1,121 @@
+wrapper.java.additional.1=-Djava.awt.headless=true
+wrapper.java.additional.2=-XX:MaxPermSize=256m
+wrapper.java.additional.3=-server
+wrapper.java.initmemory=256
+wrapper.java.maxmemory=1024
+
+#********************************************************************
+# Wrapper Java Properties
+#********************************************************************
+# JVM
+# Can be an absolute path, for example:
+#wrapper.java.command=/path/to/my/jdk/bin/java
+wrapper.java.command=java
+
+# Java Main class. This class must implement the WrapperListener interface
+# or guarantee that the WrapperManager class is initialized. Helper
+# classes are provided to do this for you. See the Integration section
+# of the documentation for details.
+wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
+
+# Java Classpath (include wrapper.jar) Add class path elements as
+# needed starting from 1
+wrapper.java.classpath.1=../../lib/*.jar
+wrapper.java.classpath.2=../../
+wrapper.java.classpath.3=../../extensions/jdbc-driver/derby/*.jar
+wrapper.java.classpath.4=../../extensions/jdbc-driver/mysql/*.jar
+wrapper.java.classpath.5=../../extensions/jdbc-driver/oracle/*.jar
+wrapper.java.classpath.6=../../extensions/jdbc-driver/postgresql/*.jar
+wrapper.java.classpath.7=../../extensions/jdbc-driver/mssql/*.jar
+wrapper.java.classpath.8=../../conf/
+
+# Java Library Path (location of Wrapper.DLL or libwrapper.so)
+wrapper.java.library.path.1=./lib
+
+# Application parameters. Add parameters as needed starting from 1
+wrapper.app.parameter.1=org.sonar.application.StartServer
+
+#********************************************************************
+# Profiling and debbuging - for development only
+# If wrapper.java.additional.3=-server is not commented, parameter ids should start from 4 instead of 3.
+#********************************************************************
+# Java remote debugging
+#wrapper.java.additional.3=-agentlib:jdwp=transport=dt_socket,server=y,address=8000
+
+# JProfiler 5
+#wrapper.java.additional.3=-Xint
+#wrapper.java.additional.4=-agentlib:jprofilerti=port=8849
+#wrapper.java.additional.5=-Xbootclasspath/a:/Applications/jprofiler5/bin/agent.jar
+
+# JMX remote monitoring on Sun JVM (warning, security is disabled)
+#wrapper.java.additional.3=-Dcom.sun.management.jmxremote
+#wrapper.java.additional.4=-Dcom.sun.management.jmxremote.port=9005
+#wrapper.java.additional.5=-Dcom.sun.management.jmxremote.authenticate=false
+#wrapper.java.additional.6=-Dcom.sun.management.jmxremote.ssl=false
+
+#********************************************************************
+# Wrapper Logging Properties
+#********************************************************************
+# Format of output for the console. (See docs for formats)
+wrapper.console.format=PM
+
+# Log Level for console output. (See docs for log levels)
+wrapper.console.loglevel=NONE
+
+# Log file to use for wrapper output logging.
+wrapper.logfile=../../logs/sonar.log
+
+# Format of output for the log file. (See docs for formats)
+wrapper.logfile.format=LPTM
+
+# Log Level for log file output. (See docs for log levels)
+wrapper.logfile.loglevel=INFO
+
+# Maximum size that the log file will be allowed to grow to before
+# the log is rolled. Size is specified in bytes. The default value
+# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
+# 'm' (mb) suffix. For example: 10m = 10 megabytes.
+#wrapper.logfile.maxsize=0
+
+# Maximum number of rolled log files which will be allowed before old
+# files are deleted. The default value of 0 implies no limit.
+#wrapper.logfile.maxfiles=0
+
+# Log Level for sys/event log output. (See docs for log levels)
+wrapper.syslog.loglevel=NONE
+
+#********************************************************************
+# Wrapper Windows Properties
+#********************************************************************
+# Title to use when running as a console
+wrapper.console.title=Sonar
+
+#********************************************************************
+# Wrapper Windows NT/2000/XP Service Properties
+#********************************************************************
+# WARNING - Do not modify any of these properties when an application
+# using this configuration file has been installed as a service.
+# Please uninstall the service before modifying this section. The
+# service can then be reinstalled.
+
+# Name of the service
+wrapper.ntservice.name=Sonar
+
+# Display name of the service
+wrapper.ntservice.displayname=Sonar
+
+# Description of the service
+wrapper.ntservice.description=Sonar
+
+# Service dependencies. Add dependencies as needed starting from 1
+wrapper.ntservice.dependency.1=
+
+# Mode in which the service is installed. AUTO_START or DEMAND_START
+wrapper.ntservice.starttype=AUTO_START
+
+# Allow the service to interact with the desktop.
+wrapper.ntservice.interactive=false
+
+#********************************************************************
+# restart the process if CPU is heavily loaded during 240 seconds.
+wrapper.ping.timeout=240 \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/scripts/start-stop.build.xml b/subprojects/sonar-dev-maven-plugin/src/main/scripts/start-stop.build.xml
new file mode 100644
index 00000000000..1b6344b1cf6
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/scripts/start-stop.build.xml
@@ -0,0 +1,451 @@
+<project>
+ <property name="tmpdir" value="${java.io.tmpdir}/sonar"/>
+ <property name="tomcat6.home" value="${tmpdir}/tomcat6"/>
+
+ <taskdef resource="cargo.tasks"/>
+ <taskdef name="httpmpost" classname="net.sf.fikin.ant.httpclientanttask.AntMultipartPostMethod"/>
+ <taskdef name="httppost" classname="net.sf.fikin.ant.httpclientanttask.AntPostMethod"/>
+ <taskdef resource="net/sf/antcontrib/antlib.xml"/>
+
+ <!-- entry points : start and stop -->
+ <target name="start" depends="expand-database-profile,prepare-standalone-configuration,drop-database,configure-sonar">
+ <parallel>
+ <antcall target="start-standalone"/>
+ <antcall target="setup"/>
+ </parallel>
+ </target>
+
+ <target name="stop" depends="prepare-standalone-configuration,stop-standalone"/>
+
+ <target name="prepare-standalone-configuration">
+ <condition property="sonar.bin.path" value="bin/macosx-universal-64/sonar.sh">
+ <os family="mac"/>
+ </condition>
+ <condition property="sonar.bin.path" value="bin/windows-x86-32/StartSonar.bat">
+ <os family="windows"/>
+ </condition>
+ <condition property="sonar.bin.path" value="bin/linux-x86-32/sonar.sh">
+ <os family="unix"/>
+ </condition>
+ </target>
+
+ <!--
+
+ DATABASE PROFILES
+
+ -->
+ <target name="expand-database-profile">
+ <!-- derby -->
+ <condition property="sonar.jdbc.url" value="jdbc:derby://localhost:1527/sonar;create=true">
+ <and>
+ <equals arg1="${sonar.database}" arg2="derby"/>
+ <not>
+ <isset property="sonar.jdbc.url"/>
+ </not>
+ </and>
+ </condition>
+ <condition property="sonar.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver">
+ <and>
+ <equals arg1="${sonar.database}" arg2="derby"/>
+ <not>
+ <isset property="sonar.jdbc.driver"/>
+ </not>
+ </and>
+ </condition>
+
+ <!-- mysql -->
+ <condition property="sonar.jdbc.url"
+ value="jdbc:mysql://localhost:3306/sonar?useUnicode=true&amp;characterEncoding=utf8">
+ <and>
+ <equals arg1="${sonar.database}" arg2="mysql"/>
+ <not>
+ <isset property="sonar.jdbc.url"/>
+ </not>
+ </and>
+ </condition>
+ <condition property="sonar.jdbc.driver" value="com.mysql.jdbc.Driver">
+ <and>
+ <equals arg1="${sonar.database}" arg2="mysql"/>
+ <not>
+ <isset property="sonar.jdbc.driver"/>
+ </not>
+ </and>
+ </condition>
+
+ <!-- postgresql -->
+ <condition property="sonar.jdbc.url" value="jdbc:postgresql://localhost/sonar">
+ <and>
+ <equals arg1="${sonar.database}" arg2="postgresql"/>
+ <not>
+ <isset property="sonar.jdbc.url"/>
+ </not>
+ </and>
+ </condition>
+ <condition property="sonar.jdbc.driver" value="org.postgresql.Driver">
+ <and>
+ <equals arg1="${sonar.database}" arg2="postgresql"/>
+ <not>
+ <isset property="sonar.jdbc.driver"/>
+ </not>
+ </and>
+ </condition>
+
+ <!-- oracle -->
+ <condition property="sonar.jdbc.url" value="jdbc:oracle:thin:@localhost/XE">
+ <and>
+ <equals arg1="${sonar.database}" arg2="oracle"/>
+ <not>
+ <isset property="sonar.jdbc.url"/>
+ </not>
+ </and>
+ </condition>
+ <condition property="sonar.jdbc.driver" value="oracle.jdbc.driver.OracleDriver">
+ <and>
+ <equals arg1="${sonar.database}" arg2="oracle"/>
+ <not>
+ <isset property="sonar.jdbc.driver"/>
+ </not>
+ </and>
+ </condition>
+
+ <!-- SQLServer -->
+ <condition property="sonar.jdbc.url" value="jdbc:jtds:sqlserver://localhost;databaseName=SONAR;SelectMethod=Cursor">
+ <and>
+ <equals arg1="${sonar.database}" arg2="mssql"/>
+ <not>
+ <isset property="sonar.jdbc.url"/>
+ </not>
+ </and>
+ </condition>
+ <condition property="sonar.jdbc.driver" value="net.sourceforge.jtds.jdbc.Driver">
+ <and>
+ <equals arg1="${sonar.database}" arg2="mssql"/>
+ <not>
+ <isset property="sonar.jdbc.driver"/>
+ </not>
+ </and>
+ </condition>
+ </target>
+
+
+ <target name="start-war" depends="expand-database-profile,drop-database,configure-sonar">
+ <parallel>
+ <antcall target="start-tomcat"/>
+ <antcall target="setup"/>
+ </parallel>
+ </target>
+
+ <target name="stop-war" depends="stop-tomcat"/>
+
+ <!-- STEP 1 : initialize the database -->
+ <target name="drop-database">
+ <condition property="execute.drop.database">
+ <istrue value="${sonar.dropDatabase}"/>
+ </condition>
+ <antcall target="do-drop-database"/>
+ </target>
+
+ <target name="do-drop-database" if="execute.drop.database">
+ <sql driver="${sonar.jdbc.driver}"
+ url="${sonar.jdbc.rootUrl}"
+ userid="${sonar.jdbc.rootUsername}"
+ password="${sonar.jdbc.rootPassword}"
+ onerror="continue"
+ autocommit="true"
+ expandProperties="true">
+ <resources>
+ <javaresource name="database/${sonar.database}/drop-db.sql"/>
+ <javaresource name="database/${sonar.database}/drop-user.sql"/>
+ <javaresource name="database/${sonar.database}/create-user.sql"/>
+ <javaresource name="database/${sonar.database}/create-db.sql"/>
+ </resources>
+ </sql>
+
+ <echo>Database is ready</echo>
+ </target>
+
+
+ <!-- STEP 2 : install Sonar -->
+ <target name="clean-sonar-home" if="execute.sonar.clean">
+ <delete dir="${tmpdir}/sonar-${sonar.runtimeVersion}"/>
+ <mkdir dir="${tmpdir}"/>
+ </target>
+
+
+ <target name="prepare-sonar-home" unless="is.installed">
+ <copy tofile="${tmpdir}/sonar-${sonar.runtimeVersion}.zip" overwrite="true" verbose="true" flatten="true"
+ failonerror="false"
+ file="${settings.localRepository}/org/codehaus/sonar/sonar-application/${sonar.runtimeVersion}/sonar-application-${sonar.runtimeVersion}.zip">
+ </copy>
+ <condition property="execute.download-sonar">
+ <not>
+ <available file="${tmpdir}/sonar-${sonar.runtimeVersion}.zip"/>
+ </not>
+ </condition>
+ <antcall target="download-sonar"/>
+ <unzip src="${tmpdir}/sonar-${sonar.runtimeVersion}.zip" dest="${tmpdir}"/>
+ </target>
+
+
+ <target name="download-sonar" if="execute.download-sonar">
+ <echo>Downloading sonar</echo>
+ <get src="http://dist.sonar.codehaus.org/sonar-${sonar.runtimeVersion}.zip"
+ dest="${tmpdir}/sonar-${sonar.runtimeVersion}.zip"/>
+ <echo>Installing to local maven repo</echo>
+ <mvninstall groupId="org.codehaus.sonar"
+ artifactId="sonar-application"
+ version="${sonar.runtimeVersion}"
+ packaging="zip"
+ file="${tmpdir}/sonar-${sonar.runtimeVersion}.zip"/>
+ </target>
+
+ <target name="copy-extensions" if="has.extensions">
+ <echo>Copy extensions...</echo>
+ <copy todir="${tmpdir}/sonar-${sonar.runtimeVersion}/extensions" overwrite="true" verbose="true" flatten="false">
+ <fileset dir="${sonar.extensionsDir}"/>
+ </copy>
+ </target>
+
+
+ <target name="copy-plugin-artifact" if="has.plugin.artifact">
+ <echo>Copy plugin artifact...</echo>
+ <copy todir="${tmpdir}/sonar-${sonar.runtimeVersion}/extensions/plugins" overwrite="true" verbose="true"
+ flatten="true"
+ file="${sonar.pluginArtifact}">
+ </copy>
+ </target>
+
+
+ <target name="configure-sonar">
+ <condition property="execute.sonar.clean" value="true">
+ <istrue value="${sonar.clean}"/>
+ </condition>
+ <antcall target="clean-sonar-home" />
+
+ <available property="is.installed" file="${tmpdir}/sonar-${sonar.runtimeVersion}/conf/sonar.properties"/>
+ <antcall target="prepare-sonar-home"/>
+
+ <copy todir="${tmpdir}/sonar-${sonar.runtimeVersion}/conf/" overwrite="true" verbose="true" flatten="true">
+ <resources>
+ <javaresource name="server/sonar.properties"/>
+ <javaresource name="server/wrapper.conf"/>
+ </resources>
+ </copy>
+
+ <available property="has.extensions" file="${sonar.extensionsDir}"/>
+ <antcall target="copy-extensions"/>
+
+ <available file="${sonar.pluginArtifact}" property="has.plugin.artifact"/>
+ <antcall target="copy-plugin-artifact"/>
+
+ </target>
+
+
+ <!-- STEP 3 : start web server -->
+ <target name="start-standalone">
+ <echo>Start server</echo>
+
+ <chmod perm="777" type="file">
+ <fileset dir="${tmpdir}/sonar-${sonar.runtimeVersion}/bin">
+ <include name="**/*"/>
+ </fileset>
+ </chmod>
+
+ <condition property="windows">
+ <os family="windows"/>
+ </condition>
+
+ <antcall target="start-standalone-windows" />
+ <antcall target="start-standalone-unix" />
+ </target>
+
+ <target name="start-standalone-windows" if="windows">
+<!-- <condition property="sonar.command" value="restart" else="console">
+ <istrue value="${sonar.background}"/>
+ </condition>-->
+ <exec executable="${tmpdir}/sonar-${sonar.runtimeVersion}/${sonar.bin.path}">
+ <env key="sonar.jdbc.url" value="${sonar.jdbc.url}"/>
+ <env key="sonar.jdbc.driverClassName" value="${sonar.jdbc.driver}"/>
+ <env key="sonar.jdbc.username" value="${sonar.jdbc.username}"/>
+ <env key="sonar.jdbc.password" value="${sonar.jdbc.password}"/>
+ </exec>
+ </target>
+
+ <target name="start-standalone-unix" unless="windows">
+ <condition property="sonar.command" value="restart" else="console">
+ <istrue value="${sonar.background}"/>
+ </condition>
+ <exec executable="${tmpdir}/sonar-${sonar.runtimeVersion}/${sonar.bin.path}">
+ <arg line="${sonar.command}"/>
+ <env key="sonar.jdbc.url" value="${sonar.jdbc.url}"/>
+ <env key="sonar.jdbc.driverClassName" value="${sonar.jdbc.driver}"/>
+ <env key="sonar.jdbc.username" value="${sonar.jdbc.username}"/>
+ <env key="sonar.jdbc.password" value="${sonar.jdbc.password}"/>
+ </exec>
+ </target>
+
+ <target name="stop-standalone">
+ <exec executable="${tmpdir}/sonar-${sonar.runtimeVersion}/${sonar.bin.path}">
+ <arg line="stop"/>
+ </exec>
+ </target>
+
+
+ <target name="start-tomcat">
+ <echo>Build WAR</echo>
+ <ant dir="${tmpdir}/sonar-${sonar.runtimeVersion}/war/" inheritAll="false"/>
+
+ <mkdir dir="${tomcat6.home}"/>
+ <mkdir dir="${tmpdir}/sonar-${sonar.runtimeVersion}/logs"/>
+
+ <condition property="sonar.wait" value="true" else="false">
+ <isfalse value="${sonar.background}"/>
+ </condition>
+ <echo>Start tomcat, background mode: ${sonar.background}</echo>
+
+ <cargo containerId="tomcat6x" action="start" wait="${sonar.wait}" id="tmptmct6-${sonar.runtimeVersion}"
+ output="${tmpdir}/sonar-${sonar.runtimeVersion}/logs/output.log"
+ log="${tmpdir}/sonar-${sonar.runtimeVersion}/logs/cargo.log">
+ <zipurlinstaller
+ installurl="http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.26/bin/apache-tomcat-6.0.26.zip"/>
+ <configuration type="standalone" home="${tomcat6.home}">
+ <property name="cargo.jvmargs"
+ value="-Xmx1024m -XX:MaxPermSize=256m -server -Dsonar.jdbc.url=${sonar.jdbc.url} -Dsonar.jdbc.driverClassName=${sonar.jdbc.driver} -Dsonar.jdbc.username=${sonar.jdbc.username} -Dsonar.jdbc.password=${sonar.jdbc.password}"/>
+ <property name="cargo.servlet.port" value="9000"/>
+ <property name="cargo.remote.username" value="admin"/>
+ <property name="cargo.remote.password" value=""/>
+ <deployable type="war" file="${tmpdir}/sonar-${sonar.runtimeVersion}/war/sonar.war">
+ <property name="context" value="ROOT"/>
+ </deployable>
+ </configuration>
+ </cargo>
+ <antcall target="wait-for-server"/>
+ </target>
+
+ <target name="stop-tomcat">
+ <echo>Stopping tomcat</echo>
+ <cargo containerId="tomcat6x" action="stop" wait="true" id="tmptmct6-${sonar.runtimeVersion}">
+ <zipurlinstaller
+ installurl="http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.26/bin/apache-tomcat-6.0.26.zip"/>
+ <configuration type="standalone" home="${tomcat6.home}">
+ <property name="cargo.jvmargs" value="-Xmx512m -server"/>
+ <property name="cargo.servlet.port" value="9000"/>
+ <property name="cargo.remote.username" value="admin"/>
+ <property name="cargo.remote.password" value=""/>
+ </configuration>
+ </cargo>
+ </target>
+
+ <!-- STEP 4 : setup sonar -->
+
+ <target name="wait-for-server">
+ <waitfor maxwait="5" maxwaitunit="minute" checkevery="10" checkeveryunit="second">
+ <http url="http://localhost:9000"/>
+ </waitfor>
+ </target>
+
+ <target name="setup" depends="wait-for-server">
+ <httppost url="http://localhost:9000/setup/setup_database" logLevel="none"/>
+ <echo message="Database is up."/>
+
+ <condition property="execute.restore.backup" value="true">
+ <isset property="sonar.configBackup"/>
+ </condition>
+ <antcall target="restore-backup"/>
+ </target>
+
+
+ <target name="restore-backup" if="execute.restore.backup">
+ <echo message="Restoring sonar backup"/>
+
+ <httppost url="http://localhost:9000/sessions/login" logLevel="none">
+ <post name="login" value="admin"/>
+ <post name="password" value="admin"/>
+ </httppost>
+ <echo message="Logged in."/>
+
+ <httpmpost url="http://localhost:9000/backup/import" logLevel="none">
+ <postFile name="file" file="${sonar.configBackup}"/>
+ </httpmpost>
+ <echo message="Backup is restored."/>
+ </target>
+
+
+ <!-- STEP 5 : analyze projects -->
+
+ <target name="analyze" depends="expand-database-profile">
+ <for param="pom">
+ <path>
+ <fileset dir="${sonar.projectsDir}" includes="*/pom.xml"/>
+ </path>
+ <sequential>
+ <mvn pom="@{pom}" failonerror="false" args="clean install -DskipTests"/>
+ <mvnsonar pom="@{pom}"/>
+ </sequential>
+ </for>
+ </target>
+
+
+ <macrodef name="mvn">
+ <attribute name="failonerror" default="true"/>
+ <attribute name="pom"/>
+ <attribute name="args" default=""/>
+
+ <sequential>
+ <exec failonerror="@{failonerror}" executable="mvn.bat" osfamily="Windows">
+ <arg line="-f @{pom}"/>
+ <arg line="@{args}"/>
+ </exec>
+ <exec failonerror="@{failonerror}" executable="mvn" osfamily="unix">
+ <arg line="-f @{pom}"/>
+ <arg line="@{args} "/>
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="mvnsonar">
+ <attribute name="failonerror" default="true"/>
+ <attribute name="args" default=""/>
+ <attribute name="pom"/>
+
+ <sequential>
+ <exec failonerror="@{failonerror}" executable="${maven.home}/bin/mvn.bat" osfamily="Windows">
+ <arg line="org.codehaus.mojo:sonar-maven-plugin:1.0-beta-1:sonar @{args} -B -e"/>
+ <arg line="-f @{pom}"/>
+ <arg value='-Dsonar.jdbc.url="${sonar.jdbc.url}"'/>
+ <!-- double quotes for windows -->
+ <arg value="-Dsonar.jdbc.driver=${sonar.jdbc.driver}"/>
+ <arg value="-Dsonar.jdbc.username=${sonar.jdbc.username}"/>
+ <arg value="-Dsonar.jdbc.password=${sonar.jdbc.password}"/>
+ </exec>
+ <exec failonerror="@{failonerror}" executable="${maven.home}/bin/mvn" osfamily="unix">
+ <arg line="org.codehaus.mojo:sonar-maven-plugin:1.0-beta-1:sonar @{args} -B -e"/>
+ <arg line="-f @{pom}"/>
+ <arg value='-Dsonar.jdbc.url=${sonar.jdbc.url}'/>
+ <arg value="-Dsonar.jdbc.driver=${sonar.jdbc.driver}"/>
+ <arg value="-Dsonar.jdbc.username=${sonar.jdbc.username}"/>
+ <arg value="-Dsonar.jdbc.password=${sonar.jdbc.password}"/>
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <macrodef name="mvninstall">
+ <attribute name="failonerror" default="false"/>
+ <attribute name="groupId"/>
+ <attribute name="artifactId"/>
+ <attribute name="version"/>
+ <attribute name="packaging" default="jar"/>
+ <attribute name="file"/>
+
+ <sequential>
+ <exec failonerror="@{failonerror}" executable="mvn.bat" osfamily="Windows">
+ <arg
+ line="install:install-file -DgroupId=@{groupId} -DartifactId=@{artifactId} -Dversion=@{version} -Dpackaging=@{packaging} -Dfile=@{file}"/>
+ </exec>
+ <exec failonerror="@{failonerror}" executable="mvn" osfamily="unix">
+ <arg
+ line="install:install-file -DgroupId=@{groupId} -DartifactId=@{artifactId} -Dversion=@{version} -Dpackaging=@{packaging} -Dfile=@{file}"/>
+ </exec>
+ </sequential>
+ </macrodef>
+</project>
diff --git a/subprojects/sonar-dev-maven-plugin/src/main/scripts/start-stop.mojos.xml b/subprojects/sonar-dev-maven-plugin/src/main/scripts/start-stop.mojos.xml
new file mode 100644
index 00000000000..ee9d8f8c41f
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/main/scripts/start-stop.mojos.xml
@@ -0,0 +1,362 @@
+<pluginMetadata>
+ <mojos>
+ <mojo>
+ <goal>start</goal>
+ <call>start</call>
+ <requiresProject>false</requiresProject>
+ <parameters>
+ <parameter>
+ <name>sonar.runtimeVersion</name>
+ <property>sonar.runtimeVersion</property>
+ <expression>${sonar.runtimeVersion}</expression>
+ <required>true</required>
+ <type>java.lang.String</type>
+ <description>Sonar version</description>
+ <defaultValue>2.2</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.database</name>
+ <property>sonar.database</property>
+ <required>false</required>
+ <expression>${sonar.database}</expression>
+ <type>java.lang.String</type>
+ <description>Database profile: [derby, mssql, mysql, oracle, postgresql]</description>
+ <defaultValue>derby</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.dropDatabase</name>
+ <property>sonar.dropDatabase</property>
+ <expression>${sonar.dropDatabase}</expression>
+ <required>false</required>
+ <type>java.lang.Boolean</type>
+ <defaultValue>false</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.url</name>
+ <property>sonar.jdbc.url</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.url}</expression>
+ <type>java.lang.String</type>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.driver</name>
+ <property>sonar.jdbc.driver</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.driver}</expression>
+ <type>java.lang.String</type>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.rootUsername</name>
+ <property>sonar.jdbc.rootUsername</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.rootUsername}</expression>
+ <type>java.lang.String</type>
+ <description>Used when dropDatabase is true</description>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.rootPassword</name>
+ <property>sonar.jdbc.rootPassword</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.rootPassword}</expression>
+ <type>java.lang.String</type>
+ <description>Used when dropDatabase is true</description>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.rootUrl</name>
+ <property>sonar.jdbc.rootUrl</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.rootUrl}</expression>
+ <type>java.lang.String</type>
+ <description>Used when dropDatabase is true</description>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.username</name>
+ <property>sonar.jdbc.username</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.username}</expression>
+ <type>java.lang.String</type>
+ <defaultValue>sonar</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.password</name>
+ <property>sonar.jdbc.password</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.password}</expression>
+ <type>java.lang.String</type>
+ <defaultValue>sonar</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.pluginArtifact</name>
+ <property>sonar.pluginArtifact</property>
+ <expression>${sonar.pluginArtifact}</expression>
+ <required>false</required>
+ <type>java.lang.File</type>
+ <defaultValue>${project.build.directory}/${project.build.finalName}.jar</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.extensionsDir</name>
+ <property>sonar.extensionsDir</property>
+ <expression>${sonar.extensionsDir}</expression>
+ <required>false</required>
+ <type>java.lang.File</type>
+ <defaultValue>${project.build.directory}/extensions</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.background</name>
+ <property>sonar.background</property>
+ <expression>${sonar.background}</expression>
+ <required>false</required>
+ <type>java.lang.Boolean</type>
+ <defaultValue>false</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.clean</name>
+ <property>sonar.clean</property>
+ <expression>${sonar.clean}</expression>
+ <required>false</required>
+ <type>java.lang.Boolean</type>
+ <defaultValue>true</defaultValue>
+ </parameter>
+ <parameter>
+ <name>settings.localRepository</name>
+ <property>settings.localRepository</property>
+ <expression>${settings.localRepository}</expression>
+ <required>false</required>
+ <type>java.lang.File</type>
+ </parameter>
+ <parameter>
+ <name>sonar.configBackup</name>
+ <property>sonar.configBackup</property>
+ <expression>${sonar.configBackup}</expression>
+ <required>false</required>
+ <type>java.lang.File</type>
+ </parameter>
+ </parameters>
+ </mojo>
+
+ <mojo>
+ <goal>stop</goal>
+ <call>stop</call>
+ <requiresProject>false</requiresProject>
+ <parameters>
+ <parameter>
+ <name>sonar.runtimeVersion</name>
+ <property>sonar.runtimeVersion</property>
+ <required>true</required>
+ <type>java.lang.String</type>
+ <description>Sonar version</description>
+ <expression>${sonar.runtimeVersion}</expression>
+ <defaultValue>2.2</defaultValue>
+ </parameter>
+ </parameters>
+ </mojo>
+
+ <mojo>
+ <goal>start-war</goal>
+ <call>start-war</call>
+ <requiresProject>false</requiresProject>
+ <parameters>
+ <parameter>
+ <name>sonar.runtimeVersion</name>
+ <property>sonar.runtimeVersion</property>
+ <required>true</required>
+ <type>java.lang.String</type>
+ <description>Sonar version</description>
+ <expression>${sonar.runtimeVersion}</expression>
+ <defaultValue>2.2</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.database</name>
+ <property>sonar.database</property>
+ <required>false</required>
+ <expression>${sonar.database}</expression>
+ <type>java.lang.String</type>
+ <description>Database profile: [derby, mssql, mysql, oracle, postgresql]</description>
+ <defaultValue>derby</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.dropDatabase</name>
+ <property>sonar.dropDatabase</property>
+ <expression>${sonar.dropDatabase}</expression>
+ <required>false</required>
+ <type>java.lang.Boolean</type>
+ <defaultValue>false</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.url</name>
+ <property>sonar.jdbc.url</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.url}</expression>
+ <type>java.lang.String</type>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.driver</name>
+ <property>sonar.jdbc.driver</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.driver}</expression>
+ <type>java.lang.String</type>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.rootUsername</name>
+ <property>sonar.jdbc.rootUsername</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.rootUsername}</expression>
+ <type>java.lang.String</type>
+ <description>Used when dropDatabase is true</description>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.rootPassword</name>
+ <property>sonar.jdbc.rootPassword</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.rootPassword}</expression>
+ <type>java.lang.String</type>
+ <description>Used when dropDatabase is true</description>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.rootUrl</name>
+ <property>sonar.jdbc.rootUrl</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.rootUrl}</expression>
+ <type>java.lang.String</type>
+ <description>Used when dropDatabase is true</description>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.username</name>
+ <property>sonar.jdbc.username</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.username}</expression>
+ <type>java.lang.String</type>
+ <defaultValue>sonar</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.password</name>
+ <property>sonar.jdbc.password</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.password}</expression>
+ <type>java.lang.String</type>
+ <defaultValue>sonar</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.pluginArtifact</name>
+ <property>sonar.pluginArtifact</property>
+ <expression>${sonar.pluginArtifact}</expression>
+ <required>false</required>
+ <type>java.lang.File</type>
+ <defaultValue>${project.build.directory}/${project.build.finalName}.jar</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.extensionsDir</name>
+ <property>sonar.extensionsDir</property>
+ <expression>${sonar.extensionsDir}</expression>
+ <required>false</required>
+ <type>java.lang.File</type>
+ <defaultValue>${project.build.directory}/extensions</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.background</name>
+ <property>sonar.background</property>
+ <expression>${sonar.background}</expression>
+ <required>false</required>
+ <type>java.lang.Boolean</type>
+ <defaultValue>false</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.clean</name>
+ <property>sonar.clean</property>
+ <expression>${sonar.clean}</expression>
+ <required>false</required>
+ <type>java.lang.Boolean</type>
+ <defaultValue>true</defaultValue>
+ </parameter>
+ <parameter>
+ <name>settings.localRepository</name>
+ <property>settings.localRepository</property>
+ <expression>${settings.localRepository}</expression>
+ <required>false</required>
+ <type>java.lang.File</type>
+ </parameter>
+ <parameter>
+ <name>sonar.configBackup</name>
+ <property>sonar.configBackup</property>
+ <expression>${sonar.configBackup}</expression>
+ <required>false</required>
+ <type>java.lang.File</type>
+ </parameter>
+ </parameters>
+ </mojo>
+
+ <mojo>
+ <goal>stop-war</goal>
+ <call>stop-war</call>
+ <requiresProject>false</requiresProject>
+ <parameters>
+ <parameter>
+ <name>sonar.runtimeVersion</name>
+ <property>sonar.runtimeVersion</property>
+ <required>true</required>
+ <type>java.lang.String</type>
+ <description>Sonar version</description>
+ <expression>${sonar.runtimeVersion}</expression>
+ <defaultValue>2.2</defaultValue>
+ </parameter>
+ </parameters>
+ </mojo>
+
+
+ <mojo>
+ <goal>analyze</goal>
+ <call>analyze</call>
+ <requiresProject>false</requiresProject>
+ <parameters>
+ <parameter>
+ <name>sonar.database</name>
+ <property>sonar.database</property>
+ <required>false</required>
+ <expression>${sonar.database}</expression>
+ <type>java.lang.String</type>
+ <description>Database profile: [derby, mssql, mysql, oracle, postgresql]</description>
+ <defaultValue>derby</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.url</name>
+ <property>sonar.jdbc.url</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.url}</expression>
+ <type>java.lang.String</type>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.driver</name>
+ <property>sonar.jdbc.driver</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.driver}</expression>
+ <type>java.lang.String</type>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.username</name>
+ <property>sonar.jdbc.username</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.username}</expression>
+ <type>java.lang.String</type>
+ <defaultValue>sonar</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.jdbc.password</name>
+ <property>sonar.jdbc.password</property>
+ <required>false</required>
+ <expression>${sonar.jdbc.password}</expression>
+ <type>java.lang.String</type>
+ <defaultValue>sonar</defaultValue>
+ </parameter>
+ <parameter>
+ <name>sonar.projectsDir</name>
+ <property>sonar.projectsDir</property>
+ <expression>${sonar.projectsDir}</expression>
+ <required>true</required>
+ <type>java.lang.File</type>
+ <defaultValue>${basedir}</defaultValue>
+ </parameter>
+ </parameters>
+ </mojo>
+
+ </mojos>
+</pluginMetadata> \ No newline at end of file
diff --git a/subprojects/sonar-dev-maven-plugin/src/test/java/org/sonar/dev/TrimMojoTest.java b/subprojects/sonar-dev-maven-plugin/src/test/java/org/sonar/dev/TrimMojoTest.java
new file mode 100644
index 00000000000..92dd604d7ca
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/test/java/org/sonar/dev/TrimMojoTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.dev;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.assertThat;
+import org.junit.Test;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
+import java.io.File;
+import java.io.IOException;
+
+public class TrimMojoTest {
+
+ @Test
+ public void trimFilesFromDirectory() throws IOException, MojoFailureException, MojoExecutionException {
+ File dir = newDir("trimFilesFromDirectory");
+ File file1 = copyResourceToDir(1, dir);
+ File file2 = copyResourceToDir(2, dir);
+
+ TrimMojo mojo = new TrimMojo();
+ mojo.setDirectory(dir);
+ mojo.execute();
+
+ assertTrimmed(file1);
+ assertTrimmed(file2);
+ }
+
+ @Test
+ public void excludeSomeFiles() throws IOException, MojoFailureException, MojoExecutionException {
+ File dir = newDir("excludeSomeFiles");
+ File file1 = copyResourceToDir(1, dir);
+ File file2 = copyResourceToDir(2, dir);
+
+ TrimMojo mojo = new TrimMojo();
+ mojo.setDirectory(dir);
+ mojo.setExcludes(new String[]{"**/*-1.txt"});
+ mojo.execute();
+
+ assertNotTrimmed(file1);
+ assertTrimmed(file2);
+ }
+
+ @Test
+ public void trimOnlySomeFiles() throws IOException, MojoFailureException, MojoExecutionException {
+ File dir = newDir("trimOnlySomeFiles");
+ File file1 = copyResourceToDir(1, dir);
+ File file2 = copyResourceToDir(2, dir);
+
+ TrimMojo mojo = new TrimMojo();
+ mojo.setDirectory(dir);
+ mojo.setIncludes(new String[]{"**/*-1.txt"});
+ mojo.execute();
+
+ assertTrimmed(file1);
+ assertNotTrimmed(file2);
+ }
+
+ private void assertNotTrimmed(File file) throws IOException {
+ String content = FileUtils.readFileToString(file);
+ assertThat(content, startsWith(" "));
+ assertThat(content, containsString(" "));
+ }
+
+ private void assertTrimmed(File file) throws IOException {
+ String content = FileUtils.readFileToString(file);
+ assertThat(content, startsWith("many spaces"));
+ assertThat(content, not(containsString(" ")));
+ assertThat(content, containsString("white spaces should be kept in the line"));
+ }
+
+
+ private File copyResourceToDir(int index, File dir) throws IOException {
+ File file = new File(dir, "whitespace-indented-" + index + ".txt");
+ FileUtils.copyURLToFile(getClass().getResource("/org/sonar/dev/TrimMojoTest/whitespace-indented.txt"), file);
+ return file;
+ }
+
+ private File newDir(String name) throws IOException {
+ File dir = new File("target/tmp/org/sonar/dev/TrimMojoTest/" + name);
+ FileUtils.forceMkdir(dir);
+ FileUtils.cleanDirectory(dir);
+ return dir;
+ }
+}
diff --git a/subprojects/sonar-dev-maven-plugin/src/test/resources/org/sonar/dev/TrimMojoTest/whitespace-indented.txt b/subprojects/sonar-dev-maven-plugin/src/test/resources/org/sonar/dev/TrimMojoTest/whitespace-indented.txt
new file mode 100644
index 00000000000..5ee36296681
--- /dev/null
+++ b/subprojects/sonar-dev-maven-plugin/src/test/resources/org/sonar/dev/TrimMojoTest/whitespace-indented.txt
@@ -0,0 +1,9 @@
+ many spaces
+ before and after
+ white spaces should be kept in the line
+
+
+
+
+
+ \ No newline at end of file