+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
- <id>bin</id>
- <formats>
- <format>zip</format>
- </formats>
- <includeBaseDirectory>true</includeBaseDirectory>
- <fileSets>
- <fileSet>
- <directory>src/main/assembly/bin</directory>
- <outputDirectory>bin</outputDirectory>
- <includes>
- <include>sonar-runner.bat</include>
- <include>sonar-scanner.bat</include>
- <include>sonar-scanner-debug.bat</include>
- </includes>
- <lineEnding>dos</lineEnding>
- <filtered>true</filtered>
- </fileSet>
- <fileSet>
- <directory>src/main/assembly/bin</directory>
- <outputDirectory>bin</outputDirectory>
- <includes>
- <include>sonar-runner</include>
- <include>sonar-scanner</include>
- <include>sonar-scanner-debug</include>
- </includes>
- <lineEnding>unix</lineEnding>
- <fileMode>0755</fileMode>
- <filtered>true</filtered>
- </fileSet>
- <fileSet>
- <directory>src/main/assembly/conf</directory>
- <outputDirectory>conf</outputDirectory>
- <fileMode>0644</fileMode>
- <lineEnding>dos</lineEnding>
- </fileSet>
- <fileSet>
- <directory>${project.build.directory}</directory>
- <outputDirectory>lib</outputDirectory>
- <includes>
- <include>${project.build.finalName}.jar</include>
- </includes>
- </fileSet>
- </fileSets>
-</assembly>
<dependency>
<groupId>org.sonarsource.orchestrator</groupId>
<artifactId>sonar-orchestrator</artifactId>
- <version>3.13</version>
+ <version>3.15.0.974</version>
</dependency>
<dependency>
<groupId>junit</groupId>
</execution>
</executions>
</plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<artifact>org.sonarsource.scanner.cli:sonar-scanner-cli:${scanner.version}:zip</artifact>
</configuration>
</execution>
+ <execution>
+ <id>get-linux-scanner</id>
+ <phase>initialize</phase>
+ <goals>
+ <goal>get</goal>
+ </goals>
+ <configuration>
+ <artifact>org.sonarsource.scanner.cli:sonar-scanner-cli:${scanner.version}:zip:linux</artifact>
+ </configuration>
+ </execution>
+ <execution>
+ <id>get-windows-scanner</id>
+ <phase>initialize</phase>
+ <goals>
+ <goal>get</goal>
+ </goals>
+ <configuration>
+ <artifact>org.sonarsource.scanner.cli:sonar-scanner-cli:${scanner.version}:zip:windows</artifact>
+ </configuration>
+ </execution>
+ <execution>
+ <id>get-macosx-scanner</id>
+ <phase>initialize</phase>
+ <goals>
+ <goal>get</goal>
+ </goals>
+ <configuration>
+ <artifact>org.sonarsource.scanner.cli:sonar-scanner-cli:${scanner.version}:zip:macosx</artifact>
+ </configuration>
+ </execution>
</executions>
</plugin>
</plugins>
--- /dev/null
+/*
+ * SonarSource :: IT :: SonarQube Scanner
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package com.sonar.runner.it;
+
+import com.sonar.orchestrator.build.BuildFailureException;
+import com.sonar.orchestrator.build.SonarScanner;
+import com.sonar.orchestrator.locator.ResourceLocation;
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+import org.junit.After;
+import org.junit.Test;
+import org.sonarqube.ws.WsMeasures.Measure;
+
+import static java.lang.Integer.parseInt;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class DistributionTest extends ScannerTestCase {
+
+ @After
+ public void cleanup() {
+ orchestrator.resetData();
+ }
+
+ @Test
+ public void should_succeed_with_self_contained_jre_despite_rubbish_java_home() throws IOException, InterruptedException {
+ String projectKey = "java:basedir-with-source";
+ orchestrator.getServer().restoreProfile(ResourceLocation.create("/sonar-way-profile.xml"));
+ orchestrator.getServer().provisionProject(projectKey, "Basedir with source");
+ orchestrator.getServer().associateProjectToQualityProfile(projectKey, "java", "sonar-way");
+
+ File projectDir = new File("projects/basedir-with-source");
+ SonarScanner build = newScanner(projectDir, "sonar.projectKey", projectKey)
+ .setEnvironmentVariable("JAVA_HOME", "nonexistent")
+ .useNative();
+ orchestrator.executeBuild(build, true);
+
+ Map<String, Measure> projectMeasures = getMeasures(projectKey, "files", "ncloc");
+ assertThat(parseInt(projectMeasures.get("files").getValue())).isEqualTo(1);
+ assertThat(parseInt(projectMeasures.get("ncloc").getValue())).isGreaterThan(1);
+ }
+
+ @Test(expected = BuildFailureException.class)
+ public void should_fail_without_self_contained_jre_when_rubbish_java_home() throws IOException, InterruptedException {
+ String projectKey = "java:basedir-with-source";
+ orchestrator.getServer().restoreProfile(ResourceLocation.create("/sonar-way-profile.xml"));
+ orchestrator.getServer().provisionProject(projectKey, "Basedir with source");
+ orchestrator.getServer().associateProjectToQualityProfile(projectKey, "java", "sonar-way");
+
+ File projectDir = new File("projects/basedir-with-source");
+ SonarScanner build = newScanner(projectDir, "sonar.projectKey", projectKey)
+ .setEnvironmentVariable("JAVA_HOME", "nonexistent");
+ orchestrator.executeBuild(build, true);
+ }
+}
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-@SuiteClasses({JavaTest.class, MultimoduleTest.class})
+@SuiteClasses({JavaTest.class, MultimoduleTest.class, DistributionTest.class})
public class SonarScannerTestSuite {
@ClassRule
<!-- used for deployment to SonarSource Artifactory -->
<gitRepositoryName>sonar-scanner-cli</gitRepositoryName>
+
+ <!-- configuration for assembly of distributions -->
+ <unpack.dir>${project.build.directory}/unpack</unpack.dir>
+ <scanner.jar>${project.build.finalName}.jar</scanner.jar>
+ <jre.version>8u121</jre.version>
+ <jre.dirname.linux>jre1.8.0_121</jre.dirname.linux>
+ <jre.dirname.windows>jre1.8.0_121</jre.dirname.windows>
+ <jre.dirname.macosx>jre1.8.0_121.jre/Contents/Home</jre.dirname.macosx>
</properties>
<dependencies>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
+ <id>cli</id>
<phase>package</phase>
<goals>
<goal>single</goal>
<appendAssemblyId>false</appendAssemblyId>
<escapeString>\</escapeString>
<descriptors>
- <descriptor>${project.basedir}/assembly.xml</descriptor>
+ <descriptor>src/main/assembly/noarch.xml</descriptor>
</descriptors>
+ <filters>
+ <filter>src/main/assembly/filter-noarch.properties</filter>
+ </filters>
</configuration>
</execution>
</executions>
<module>it</module>
</modules>
</profile>
+
+ <profile>
+ <id>dist-linux</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <id>unpack-linux</id>
+ <phase>package</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>com.oracle</groupId>
+ <artifactId>jre</artifactId>
+ <version>${jre.version}</version>
+ <classifier>linux-x64</classifier>
+ <type>tar.gz</type>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${unpack.dir}/linux</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>assemble-linux</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>sonar-scanner-${project.version}</finalName>
+ <escapeString>\</escapeString>
+ <descriptors>
+ <descriptor>src/main/assembly/dist-linux.xml</descriptor>
+ </descriptors>
+ <filters>
+ <filter>src/main/assembly/filter-dist.properties</filter>
+ </filters>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>dist-windows</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <id>unpack-windows</id>
+ <phase>package</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>com.oracle</groupId>
+ <artifactId>jre</artifactId>
+ <version>${jre.version}</version>
+ <classifier>windows-x64</classifier>
+ <type>tar.gz</type>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${unpack.dir}/windows</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>assemble-windows</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>sonar-scanner-${project.version}</finalName>
+ <escapeString>\</escapeString>
+ <descriptors>
+ <descriptor>src/main/assembly/dist-windows.xml</descriptor>
+ </descriptors>
+ <filters>
+ <filter>src/main/assembly/filter-dist.properties</filter>
+ </filters>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>dist-macosx</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <id>unpack-macosx</id>
+ <phase>package</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>com.oracle</groupId>
+ <artifactId>jre</artifactId>
+ <version>${jre.version}</version>
+ <classifier>macosx-x64</classifier>
+ <type>tar.gz</type>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ <outputDirectory>${unpack.dir}/macosx</outputDirectory>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>assemble-macosx</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>sonar-scanner-${project.version}</finalName>
+ <escapeString>\</escapeString>
+ <descriptors>
+ <descriptor>src/main/assembly/dist-macosx.xml</descriptor>
+ </descriptors>
+ <filters>
+ <filter>src/main/assembly/filter-dist.properties</filter>
+ </filters>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
+
</project>
# make it fully qualified
sonar_runner_home=$(cd "$sonar_runner_home" && pwd)
-# check that the sonar_runner_home has been correctly set
-if [ ! -f "$sonar_runner_home/lib/sonar-scanner-cli-${project.version}.jar" ] ; then
- echo '$sonar_runner_home' does not point to a valid installation directory: $sonar_runner_home
+jar_file=$sonar_runner_home/lib/sonar-scanner-cli-${project.version}.jar
+
+# check that sonar_runner_home has been correctly set
+if [ ! -f "$jar_file" ] ; then
+ echo "File does not exist: $jar_file"
+ echo "'$sonar_runner_home' does not point to a valid installation directory: $sonar_runner_home"
exit 1
fi
fi
fi
-jar_file=${sonar_runner_home}/lib/sonar-scanner-cli-${project.version}.jar
project_home=$(pwd)
#echo "Info: Using sonar-runner at $sonar_runner_home"
# make it fully qualified
sonar_scanner_home=$(cd "$sonar_scanner_home" && pwd -P)
+jar_file=$sonar_scanner_home/lib/sonar-scanner-cli-${project.version}.jar
+
# check that sonar_scanner_home has been correctly set
-if [ ! -f "$sonar_scanner_home/lib/sonar-scanner-cli-${project.version}.jar" ] ; then
- echo '$sonar_scanner_home' does not point to a valid installation directory: $sonar_scanner_home
+if [ ! -f "$jar_file" ] ; then
+ echo "File does not exist: $jar_file"
+ echo "'$sonar_scanner_home' does not point to a valid installation directory: $sonar_scanner_home"
exit 1
fi
+use_embedded_jre=${use_embedded_jre}
+if [ "$use_embedded_jre" = true ]; then
+ export JAVA_HOME=$sonar_scanner_home/lib/jre
+fi
+
if [ -n "$JAVA_HOME" ]
then
java_cmd="$JAVA_HOME/bin/java"
java_cmd="$(which java)"
fi
-jar_file=${sonar_scanner_home}/lib/sonar-scanner-cli-${project.version}.jar
project_home=$(pwd)
#echo "Info: Using sonar-scanner at $sonar_scanner_home"
@REM set local scope for the variables with windows NT shell
@setlocal
+set SONAR_SCANNER_HOME=%~dp0..
+
@REM ==== START VALIDATION ====
@REM *** JAVA EXEC VALIDATION ***
+
+set use_embedded_jre=${use_embedded_jre}
+if "%use_embedded_jre%" == "true" (
+ set JAVA_HOME=%SONAR_SCANNER_HOME%\lib\jre
+)
+
if not "%JAVA_HOME%" == "" goto foundJavaHome
for %%i in (java.exe) do set JAVA_EXEC=%%~$PATH:i
set JAVA_EXEC="%JAVA_HOME%\bin\java.exe"
:OkJava
-set SONAR_SCANNER_HOME=%~dp0..
goto run
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+ <id>linux</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <fileSets>
+
+ <!-- jre basic, except bin/ -->
+ <fileSet>
+ <directory>${unpack.dir}/linux/${jre.dirname.linux}</directory>
+ <outputDirectory>lib/jre</outputDirectory>
+ <excludes>
+ <exclude>bin/**</exclude>
+ <exclude>man/**</exclude>
+ <exclude>plugin/**</exclude>
+ </excludes>
+ </fileSet>
+
+ <!-- jre bin/java -->
+ <fileSet>
+ <directory>${unpack.dir}/linux/${jre.dirname.linux}/bin</directory>
+ <outputDirectory>lib/jre/bin</outputDirectory>
+ <includes>
+ <include>java</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ </fileSet>
+
+ <!-- scanner files -->
+ <fileSet>
+ <directory>${project.build.directory}</directory>
+ <outputDirectory>lib</outputDirectory>
+ <fileMode>0644</fileMode>
+ <includes>
+ <include>${scanner.jar}</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/assembly/conf</directory>
+ <outputDirectory>conf</outputDirectory>
+ <fileMode>0644</fileMode>
+ <lineEnding>unix</lineEnding>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/assembly/bin</directory>
+ <outputDirectory>bin</outputDirectory>
+ <fileMode>0755</fileMode>
+ <lineEnding>unix</lineEnding>
+ <filtered>true</filtered>
+ <includes>
+ <include>sonar-scanner</include>
+ <include>sonar-scanner-debug</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+ <id>macosx</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <fileSets>
+
+ <!-- jre basic, except bin/ -->
+ <fileSet>
+ <directory>${unpack.dir}/macosx/${jre.dirname.macosx}</directory>
+ <outputDirectory>lib/jre</outputDirectory>
+ <excludes>
+ <exclude>bin/**</exclude>
+ <exclude>man/**</exclude>
+ </excludes>
+ </fileSet>
+
+ <!-- jre bin/java -->
+ <fileSet>
+ <directory>${unpack.dir}/macosx/${jre.dirname.macosx}/bin</directory>
+ <outputDirectory>lib/jre/bin</outputDirectory>
+ <includes>
+ <include>java</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ </fileSet>
+
+ <!-- scanner files -->
+ <fileSet>
+ <directory>${project.build.directory}</directory>
+ <outputDirectory>lib</outputDirectory>
+ <fileMode>0644</fileMode>
+ <includes>
+ <include>${scanner.jar}</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/assembly/conf</directory>
+ <outputDirectory>conf</outputDirectory>
+ <fileMode>0644</fileMode>
+ <lineEnding>unix</lineEnding>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/assembly/bin</directory>
+ <outputDirectory>bin</outputDirectory>
+ <fileMode>0755</fileMode>
+ <lineEnding>unix</lineEnding>
+ <filtered>true</filtered>
+ <includes>
+ <include>sonar-scanner</include>
+ <include>sonar-scanner-debug</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+ <id>windows</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <fileSets>
+
+ <!-- jre basic, except bin/ -->
+ <fileSet>
+ <directory>${unpack.dir}/windows/${jre.dirname.windows}</directory>
+ <outputDirectory>lib/jre</outputDirectory>
+ <excludes>
+ <exclude>bin/**</exclude>
+ <exclude>man/**</exclude>
+ <exclude>plugin/**</exclude>
+ </excludes>
+ </fileSet>
+
+ <!-- jre bin -->
+ <fileSet>
+ <directory>${unpack.dir}/windows/${jre.dirname.windows}/bin</directory>
+ <outputDirectory>lib/jre/bin</outputDirectory>
+ <fileMode>0755</fileMode>
+ </fileSet>
+
+ <!-- scanner files -->
+ <fileSet>
+ <directory>${project.build.directory}</directory>
+ <outputDirectory>lib</outputDirectory>
+ <fileMode>0644</fileMode>
+ <includes>
+ <include>${scanner.jar}</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/assembly/conf</directory>
+ <outputDirectory>conf</outputDirectory>
+ <fileMode>0644</fileMode>
+ <lineEnding>unix</lineEnding>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/assembly/bin</directory>
+ <outputDirectory>bin</outputDirectory>
+ <fileMode>0755</fileMode>
+ <lineEnding>dos</lineEnding>
+ <filtered>true</filtered>
+ <includes>
+ <include>sonar-scanner.bat</include>
+ <include>sonar-scanner-debug.bat</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
--- /dev/null
+use_embedded_jre=true
--- /dev/null
+use_embedded_jre=false
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <id>bin</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>src/main/assembly/bin</directory>
+ <outputDirectory>bin</outputDirectory>
+ <includes>
+ <include>sonar-runner.bat</include>
+ <include>sonar-scanner.bat</include>
+ <include>sonar-scanner-debug.bat</include>
+ </includes>
+ <lineEnding>dos</lineEnding>
+ <filtered>true</filtered>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/assembly/bin</directory>
+ <outputDirectory>bin</outputDirectory>
+ <includes>
+ <include>sonar-runner</include>
+ <include>sonar-scanner</include>
+ <include>sonar-scanner-debug</include>
+ </includes>
+ <lineEnding>unix</lineEnding>
+ <fileMode>0755</fileMode>
+ <filtered>true</filtered>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/assembly/conf</directory>
+ <outputDirectory>conf</outputDirectory>
+ <fileMode>0644</fileMode>
+ <lineEnding>dos</lineEnding>
+ </fileSet>
+ <fileSet>
+ <directory>${project.build.directory}</directory>
+ <outputDirectory>lib</outputDirectory>
+ <includes>
+ <include>${project.build.finalName}.jar</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
export DEPLOY_PULL_REQUEST=true
-regular_mvn_build_deploy_analyze
+regular_mvn_build_deploy_analyze -Pdist-linux,dist-windows,dist-macosx