summaryrefslogtreecommitdiffstats
path: root/sonar-application/src/main/assembly/war/build.xml
blob: 32aecf746ce69cae6195f2f1f7f6eb570f0a4d68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!--
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
-->
<project name="Sonar WAR builder" basedir="." default="war">
   <pathconvert targetos="unix" property="sonarHome">
      <path location="${basedir}/.."/>
    </pathconvert>
    
  <target name="war" depends="clean">
    <mkdir dir="build/sonar-server"/>
    <copy todir="build/sonar-server">
      <fileset dir="sonar-server"/>
    </copy>

    <!-- add JDBC driver to classpath -->
    <copy todir="build/sonar-server/WEB-INF/lib" flatten="true">
      <fileset dir="../extensions/jdbc-driver" includes="**/*.jar"/>
    </copy>

    <!-- sonar properties -->
    <copy todir="build/sonar-server/WEB-INF/classes/conf" file="../conf/sonar.properties" overwrite="true"
          failonerror="true"/>

    <condition property="sonarhome.found">
      <isfileselected file="build/sonar-server/WEB-INF/classes/conf/sonar.properties">
        <contains text="sonar.home"/>
      </isfileselected>
    </condition>

    <antcall target="append-sonar-home"/>

    <!-- copy the logback config -->
    <copy todir="build/sonar-server/WEB-INF/classes">
      <fileset dir="../conf" includes="logback.xml"/>
    </copy>

    <!-- changing the loggers defaut appender to the SONAR_WAR appender -->
    <replace file="build/sonar-server/WEB-INF/classes/logback.xml">
      <replacetoken><![CDATA[<appender-ref ref="SONAR_FILE"/>]]></replacetoken>
      <replacevalue><![CDATA[<appender-ref ref="SONAR_WAR"/>]]></replacevalue>
    </replace>

    <war destfile="sonar.war" webxml="build/sonar-server/WEB-INF/web.xml">
      <fileset dir="build/sonar-server"/>
    </war>

    <echo>
    -----------------------------------------------------------------------------------------------------------
    sonar.war is ready to be deployed. It is linked to the Sonar home directory:
    ${sonarHome}
    
    IMPORTANT NOTES :
    * supported web servers are Jetty and Tomcat 5.x/6.x
    * the web application uses the Sonar home directory. For this reason it must be deployed on this host only.
    * the war file must be rebuilt when :
        - configuration is updated (files in the directory conf/)
        - the Sonar home directory is moved to other location
        - sonar is upgraded to a new version
      It does not have to be rebuilt when a plugin is removed or installed.
    -----------------------------------------------------------------------------------------------------------
    </echo>
  </target>

  <target name="clean">
    <delete dir="build"/>
    <delete file="sonar.war"/>
  </target>

  <target name="append-sonar-home" unless="sonarhome.found">
    <echo>Setting home to: ${sonarHome}</echo>
    <echo file="build/sonar-server/WEB-INF/classes/conf/sonar.properties" append="yes">
      sonar.home=${sonarHome}
    </echo>
  </target>

</project>