summaryrefslogtreecommitdiff
path: root/qpid/java/broker-core/build-generate-sources.xml
blob: 43ea9e2f239ae5f3cd7ce620025988794af03913 (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
92
93
94
95
96
97
98
99
100
101
<!--
 -
 - Licensed to the Apache Software Foundation (ASF) under one
 - or more contributor license agreements.  See the NOTICE file
 - distributed with this work for additional information
 - regarding copyright ownership.  The ASF licenses this file
 - to you 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.
 -
 -->
<project name="QpidBrokerCoreGenerateSources" default="generate-logmessages">

    <!-- Additions to perform LogMessage generation. To enable for a given
    module using the Ant build, add the following to the build.xml:

    <import file="${project.root}/broker-core/build-generate-sources.xml"/>

    <target name="precompile" depends="generate-logmessages"/> -->

    <dirname property="QpidBrokerCoreGenerateSources.basedir" file="${ant.file.QpidBrokerCoreGenerateSources}"/>

    <property name="gentools.classes" location="${build.scratch}/common/gentools" />
    <property name="generated-logmessages-dir" location="${module.src}" />
    <property name="velocity.classes" value="${build.scratch}/broker-core/velocity"/>
    <property name="velocity.timestamp" location="${generated-logmessages-dir}/velocity.timestamp" />
    <property name="velocity.src.dir" value="${QpidBrokerCoreGenerateSources.basedir}/src/velocity/java"/>
    <property name="velocity.template.dir" value="${QpidBrokerCoreGenerateSources.basedir}/src/velocity/templates/org/apache/qpid/server/logging/messages"/>

    <path id="source.generation.classpathref">
          <pathelement path="${project.root}/${velocity.jar}" />
          <pathelement path="${project.root}/${velocity-dep.jar}" />
    </path>

    <condition property="generate.logmessage.sources" value="true">
      <istrue value="${generate}"/>
    </condition>

    <target name="compile-logmessages-generator" >
        <mkdir dir="${velocity.classes}" />
        <!-- Compile LogMessages Velocity Generator -->
        <javac source="${java.source}" target="${java.target}"
               destdir="${velocity.classes}" debug="on" includeantruntime="false"
               srcdir="${velocity.src.dir}" >
          <classpath>
            <path refid="source.generation.classpathref"/>
          </classpath>
        </javac>
    </target>

    <target name="check-logmessages-generation-required">
      <uptodate property="logmessages-generation-not-required" targetfile="${velocity.timestamp}">
        <srcfiles dir="${module.src}" includes="**/*_logmessages.properties" />
        <srcfiles dir="${velocity.src.dir}" includes="**/*.java **/*.vm" />
      </uptodate>
    </target>

    <target name="generate-logmessages" depends="compile-logmessages-generator" if="generate.logmessage.sources">
      <mkdir dir="${generated-logmessages-dir}"/>

      <path id="logmessages.path">
        <fileset  dir="${module.src}">
          <include name="**/*_logmessages.properties"/>
        </fileset>
      </path>

      <pathconvert property="logmessages"
                   refid="logmessages.path"
                   pathsep="' '"/>

      <echo message="logmessages is ${logmessages}"/>

      <java classname="org.apache.qpid.server.logging.GenerateLogMessages" fork="true" failonerror="true">
        <arg line="'${logmessages}'"/>
          <arg value="-j"/>
          <arg value="-o"/>
          <arg value="${generated-logmessages-dir}"/>
          <arg value="-t"/>
          <arg value="${velocity.template.dir}"/>
          <arg value="-s"/>
          <arg value="${module.src}"/>

        <classpath>
          <pathelement path="${module.src}"/>
          <pathelement path="${velocity.classes}" />
          <path refid="source.generation.classpathref"/>
        </classpath>
      </java>
      <touch file="${velocity.timestamp}" />
    </target>

</project>