Browse Source

SONAR-9587 use classpath rather than fat jar for sonar-application

tags/6.6-RC1
Sébastien Lesaint 6 years ago
parent
commit
a444ad1e6b

+ 2
- 2
server/sonar-main/src/main/java/org/sonar/application/config/AppSettingsLoaderImpl.java View File

@@ -74,9 +74,9 @@ public class AppSettingsLoaderImpl implements AppSettingsLoader {

private static File detectHomeDir() {
try {
File appJar = new File(AppSettingsLoaderImpl.class.getProtectionDomain().getCodeSource().getLocation().toURI());
File appJar = new File(Class.forName("org.sonar.application.App").getProtectionDomain().getCodeSource().getLocation().toURI());
return appJar.getParentFile().getParentFile();
} catch (URISyntaxException e) {
} catch (URISyntaxException | ClassNotFoundException e) {
throw new IllegalStateException("Cannot detect path of main jar file", e);
}
}

+ 29
- 0
server/sonar-main/src/test/java/org/sonar/application/App.java View File

@@ -0,0 +1,29 @@
/*
* SonarQube
* Copyright (C) 2009-2017 SonarSource SA
* mailto:info 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 org.sonar.application;

/**
* This class is looked for by {@link org.sonar.application.config.AppSettingsLoaderImpl} to locate the location
* of SQ's sonar-application jar file.
*
* Adding a fake one here to be able to test the feature in {@link org.sonar.application.config.AppSettingsLoaderImplTest}.
*/
public class App {
}

+ 19
- 0
sonar-application/assembly-common.xml View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly>
<id>common-lib-dir</id>
<formats>
<format>dir</format>
</formats>
<baseDirectory>/</baseDirectory>
<dependencySets>

<dependencySet>
<outputDirectory>/</outputDirectory>
<useTransitiveFiltering>true</useTransitiveFiltering>
<useProjectArtifact>false</useProjectArtifact>
<scope>runtime</scope>
</dependencySet>

</dependencySets>

</assembly>

+ 5
- 8
sonar-application/assembly.xml View File

@@ -28,14 +28,6 @@
<scope>provided</scope>
</dependencySet>


<dependencySet>
<outputDirectory>lib/common</outputDirectory>
<useTransitiveFiltering>true</useTransitiveFiltering>
<useProjectArtifact>false</useProjectArtifact>
<scope>runtime</scope>
</dependencySet>

<dependencySet>
<outputDirectory>lib/server</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
@@ -122,6 +114,11 @@
</dependencySets>

<fileSets>
<!-- common directory -->
<fileSet>
<directory>target/common</directory>
<outputDirectory>lib/common</outputDirectory>
</fileSet>
<!-- wrapper binaries -->
<fileSet>
<directory>src/main/assembly</directory>

+ 17
- 31
sonar-application/pom.xml View File

@@ -1,5 +1,7 @@
<?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">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
@@ -180,7 +182,8 @@
<archive>
<index>true</index>
<manifest>
<addClasspath>false</addClasspath>
<addClasspath>true</addClasspath>
<classpathPrefix>common</classpathPrefix>
<mainClass>org.sonar.application.App</mainClass>
</manifest>
<manifestEntries>
@@ -191,41 +194,24 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<id>assemble-common-lib-dir</id>
<phase>prepare-package</phase>
<goals>
<goal>shade</goal>
<goal>single</goal>
</goals>
<configuration>
<keepDependenciesWithProvidedScope>false</keepDependenciesWithProvidedScope>
<artifactSet>
<!--excluding some transitive dependencies which are not necessary to the main process to create-->
<!--a smaller jar and use less memory-->
<excludes>
<exclude>org.apache.lucene:lucene-analyzers-common</exclude>
<exclude>org.apache.lucene:lucene-backward-codecs</exclude>
<exclude>org.apache.lucene:lucene-grouping</exclude>
<exclude>org.apache.lucene:lucene-memory</exclude>
<exclude>org.apache.lucene:lucene-misc</exclude>
<exclude>org.apache.lucene:lucene-spatial-extras</exclude>
<exclude>org.apache.lucene:lucene-spatial3d</exclude>
<exclude>org.elasticsearch.plugin:reindex-client</exclude>
<exclude>org.elasticsearch.plugin:lang-mustache-client</exclude>
<exclude>org.elasticsearch.plugin:percolator-client</exclude>
<exclude>org.elasticsearch.plugin:transport-netty3-client</exclude>
</excludes>
</artifactSet>
<appendAssemblyId>false</appendAssemblyId>
<finalName>common</finalName>
<descriptors>
<descriptor>assembly-common.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assemble-distribution-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
@@ -254,8 +240,8 @@
<configuration>
<rules>
<requireFilesSize>
<minsize>200000000</minsize>
<maxsize>215000000</maxsize>
<minsize>165000000</minsize>
<maxsize>180000000</maxsize>
<files>
<file>${project.build.directory}/sonarqube-${project.version}.zip</file>
</files>

+ 2
- 1
sonar-application/src/main/assembly/conf/wrapper.conf View File

@@ -16,7 +16,8 @@ wrapper.java.additional.1=-Dsonar.wrapped=true
wrapper.java.additional.2=-Djava.awt.headless=true
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
wrapper.java.classpath.1=../../lib/jsw/*.jar
wrapper.java.classpath.2=../../lib/*.jar
wrapper.java.classpath.2=../../lib/common/*.jar
wrapper.java.classpath.3=../../lib/*.jar
wrapper.java.library.path.1=./lib
wrapper.app.parameter.1=org.sonar.application.App
wrapper.java.initmemory=8

Loading…
Cancel
Save