File: plugin.jelly

package info (click to toggle)
clirr 0.6-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 944 kB
  • sloc: java: 4,275; xml: 2,100; makefile: 9; sh: 4
file content (131 lines) | stat: -rw-r--r-- 4,785 bytes parent folder | download | duplicates (5)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?xml version="1.0"?>

<!--
  =============================================================================
    Maven plugin for Clirr.
  =============================================================================
-->

<project 
  xmlns:j="jelly:core" 
  xmlns:util="jelly:util"
  xmlns:ant="jelly:ant"
  xmlns:x="jelly:xml">

  <!--
     ========================================================================
       Default goal.
     ========================================================================
  -->
  <goal name="clirr" description="Run binary compatibility check"
      prereqs="clirr:check"/>

  <!--
     ========================================================================
       Initializations.
     ========================================================================
  -->
  <goal name="clirr:init">

    <ant:path id="clirr.classpath">
      <ant:pathelement location="${plugin.getDependencyPath('clirr:clirr-core')}"/>
      <ant:pathelement location="${plugin.getDependencyPath('bcel:bcel')}"/>
    </ant:path>

    <ant:taskdef resource="clirrtask.properties" classpathref="clirr.classpath"/>

  </goal>

  <!--
     ========================================================================
       Download baseline version
     ========================================================================
  -->
  <goal name="clirr:download-baseline" prereqs="clirr:init">

    <!-- If the clirr.baseline.version property is not defined, we get
         the last released version from the POM using the <versions> tag. We
         assume the latest version is the last one in the <version> list. -->
    <j:invokeStatic var="latestVersion" method="getLatestVersion" 
        className="net.sf.clirr.maven.ClirrUtils">
      <j:arg type="java.util.List" value="${pom.versions}"/>
    </j:invokeStatic>

    <j:if test="${latestVersion == null}">
      <ant:fail>No released version found in the POM. Please specify a baseline version using the clirr.baseline.version property.</ant:fail>
    </j:if>

    <!-- Compute baseline jar name/url -->
    <j:set var="clirr.baseline.jar"
      value="${pom.artifactId}-${latestVersion}.${clirr.baseline.type}"/>
    <j:set var="clirr.baseline.url"
      value="${clirr.baseline.url}/${clirr.baseline.jar}"/>

    <!-- Location where to put downloaded baseline jar -->
    <j:set var="clirr.baseline.destination"
      value="${maven.repo.local}/${pom.groupId}/${clirr.baseline.type}s/${clirr.baseline.jar}"/>
    
    <!-- Download baseline jar if online -->
    <j:choose>
      <j:when test="${maven.mode.online}">

        <!-- TODO: Improve error reporting when working offline or when an
             error occurs in the call to HttpUtils.getFile() -->
        <j:invokeStatic method="getBaselineJar" 
            className="net.sf.clirr.maven.ClirrUtils">
          <j:arg type="org.apache.maven.jelly.MavenJellyContext" value="${context}"/>
        </j:invokeStatic>

      </j:when>
      <j:otherwise>

        <ant:available property="baselineJarPresent" file="${clirr.baseline.destination}"/>
        <j:if test="${baselineJarPresent == null}">
          <ant:fail>Cannot find file [${clirr.baseline.destination}]</ant:fail>
        </j:if>

      </j:otherwise>
    </j:choose>

  </goal>

  <!--
     ========================================================================
       Run binary compatibility checks.
     ========================================================================
  -->
  <goal name="clirr:check" prereqs="clirr:init"
      description="Run binary compatibility check">

    <j:if test="${context.getVariable('clirr.baseline.download') == true 
        and context.getVariable('clirr.baseline.destination') == null}">
      <attainGoal name="clirr:download-baseline"/>
    </j:if>
    
    <attainGoal name="jar:jar"/>
    
    <ant:dirname property="clirr.baseline.destination.dir" 
        file="${clirr.baseline.destination}"/>
    <ant:basename property="clirr.baseline.destination.basename" 
        file="${clirr.baseline.destination}"/>
    
    <clirr 
        failOnBinWarning="${clirr.fail.on.warning}"
        failOnBinError="${clirr.fail.on.error}"
        failOnSrcWarning="${clirr.fail.on.warning}"
        failOnSrcError="${clirr.fail.on.error}">
      <origFiles dir="${clirr.baseline.destination.dir}" 
          includes="${clirr.baseline.destination.basename}"/>
      <newFiles dir="${maven.build.dir}" includes="${maven.final.name}.jar"/>
      <formatter type="xml" outfile="${clirr.report.file}"/>

      <newClassPath refid="maven.dependency.classpath"/>

      <!-- TODO: If the old version has different dependencies, this is not correct. -->
      <origClassPath refid="maven.dependency.classpath"/>

    </clirr>  
  
  </goal>

</project>