ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Ivy (Apache Ant subproject) > Generate EAR deployment descriptor from Ivy resolution report
Date Tue, 17 Apr 2012 08:45:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=IVY&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/IVY/Generate+EAR+deployment+descriptor+from+Ivy+resolution+report">Generate
EAR deployment descriptor from Ivy resolution report</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~b.nossing@finan.nl">Bas
Nossing</a>
    </h4>
        <br/>
                         <h4>Changes (6)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >Using the wealth of information available
from the resolution report in combination with the ANT ivy:report task I came up with the
following solution: <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">asd
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The
following is just an example ANT target that <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">&lt;target
name=&quot;generate&quot;&gt; <br>&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&lt;ivy:info/&gt; <br>&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&lt;ivy:resolve/&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">
<br> <br>{code} <br>&lt;target name=&quot;generate&quot; depends=&quot;resolve&quot;&gt;
<br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-changed-words"><span
class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;</span>&lt;ivy:report</span>
todir=&quot;${bin.archive.dir}/META-INF&quot; outputpattern=&quot;application.xml&quot;
graph=&quot;false&quot; xslfile=&quot;ivy-report-appxml.xsl&quot;/&gt;
<br></td></tr>
            <tr><td class="diff-unchanged" >&lt;/target&gt; <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{code}
<br>&gt; <br></td></tr>
            <tr><td class="diff-unchanged" > <br>asd <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>An old <a href="http://www.fnogol.de/archives/2006/08/21/generate-applicationxml-from-ivyxml-for-packaging-an-ear/"
class="external-link" rel="nofollow">blogpost </a>prompted me to try and devise a
more current and elegant method of compiling the EAR deployment descriptor (application.xml)
from an Ivy resolution report. Being a novice to XSLT use and syntax I chose to base this
transformation/translation on the default Ivy report templates provided with the latest distribution
(at the time of this writing that is Ivy version 2.2.0).</p>

<p>Using the wealth of information available from the resolution report in combination
with the ANT ivy:report task I came up with the following solution:</p>

<p>The following is just an example ANT target that</p>



<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">&lt;target name=<span class="code-quote">"generate"</span>
depends=<span class="code-quote">"resolve"</span>&gt;
    &lt;ivy:report todir=<span class="code-quote">"${bin.archive.dir}/META-INF"</span>
outputpattern=<span class="code-quote">"application.xml"</span> graph=<span
class="code-quote">"<span class="code-keyword">false</span>"</span> xslfile=<span
class="code-quote">"ivy-report-appxml.xsl"</span>/&gt;
&lt;/target&gt;
</pre>
</div></div>
<p>&gt;</p>

<p>asd</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">&lt;?xml version=<span class="code-quote">"1.0"</span>
encoding=<span class="code-quote">"UTF-8"</span>?&gt;
&lt;xsl:stylesheet version=<span class="code-quote">"1.0"</span> xmlns=<span
class="code-quote">"http:<span class="code-comment">//java.sun.com/xml/ns/j2ee"</span>
xmlns:xsl=<span class="code-quote">"http://www.w3.org/1999/XSL/Transform"</span>&gt;
</span>
    &lt;xsl:output  indent=<span class="code-quote">"yes"</span>/&gt;

    &lt;xsl:variable name=<span class="code-quote">"modules"</span> select=<span
class="code-quote">"/ivy-report/dependencies/module"</span>/&gt;
    &lt;xsl:variable name=<span class="code-quote">"revisions"</span> select=<span
class="code-quote">"$modules/revision"</span>/&gt;
    &lt;xsl:variable name=<span class="code-quote">"artifacts"</span> select=<span
class="code-quote">"$revisions/artifacts/artifact"</span>/&gt;
    
    &lt;xsl:template name=<span class="code-quote">"calling"</span>&gt;
        &lt;xsl:param name=<span class="code-quote">"org"</span>/&gt;
        &lt;xsl:param name=<span class="code-quote">"mod"</span>/&gt;
        &lt;xsl:param name=<span class="code-quote">"rev"</span>/&gt;
        &lt;xsl:<span class="code-keyword">if</span> test=<span class="code-quote">"count($modules/revision/caller[(@organisation=$org
and @name=$mod) and @callerrev=$rev]) &gt; 0"</span>&gt;
            &lt;module&gt;
               &lt;xsl:<span class="code-keyword">for</span>-each
select=<span class="code-quote">"$modules/revision/caller[(@organisation=$org and @name=$mod)
and @callerrev=$rev]"</span>&gt;
                 &lt;xsl:call-template name=<span class="code-quote">"called"</span>&gt;
                   &lt;xsl:with-param name=<span class="code-quote">"revision"</span>
select=<span class="code-quote">".."</span>/&gt;
                 &lt;/xsl:call-template&gt;
               &lt;/xsl:<span class="code-keyword">for</span>-each&gt; 
 
            &lt;/module&gt;
        &lt;/xsl:<span class="code-keyword">if</span>&gt;
    &lt;/xsl:template&gt;
    
    &lt;xsl:template name=<span class="code-quote">"called"</span>&gt;
        &lt;xsl:param name=<span class="code-quote">"revision"</span>/&gt;
    
        &lt;xsl:param name=<span class="code-quote">"module"</span>
select=<span class="code-quote">"$revision/../@name"</span>/&gt;
        &lt;xsl:param name=<span class="code-quote">"rev"</span> select=<span
class="code-quote">"$revision/@name"</span>/&gt;
        &lt;xsl:param name=<span class="code-quote">"type"</span> select=<span
class="code-quote">"$revision/artifacts/artifact/@type"</span>/&gt;
        &lt;xsl:param name=<span class="code-quote">"ext"</span> select=<span
class="code-quote">"$revision/artifacts/artifact/@ext"</span>/&gt;
        &lt;xsl:param name=<span class="code-quote">"artifact"</span>
select=<span class="code-quote">"concat($module, '-', $rev, '.', $ext)"</span>/&gt;
        
        &lt;xsl:<span class="code-keyword">if</span> test=<span class="code-quote">"$type='ejb'"</span>&gt;
            &lt;ejb&gt;
                &lt;xsl:value-of select=<span class="code-quote">"$artifact"</span>/&gt;
            &lt;/ejb&gt;
        &lt;/xsl:<span class="code-keyword">if</span>&gt;
        
        &lt;xsl:<span class="code-keyword">if</span> test=<span class="code-quote">"$type='war'"</span>&gt;
            &lt;web&gt;
                &lt;web-uri&gt;
                    &lt;xsl:value-of select=<span class="code-quote">"$artifact"</span>/&gt;
                &lt;/web-uri&gt;
            &lt;/web&gt;
        &lt;/xsl:<span class="code-keyword">if</span>&gt;

        &lt;xsl:<span class="code-keyword">if</span> test=<span class="code-quote">"$type='jar'"</span>&gt;
            &lt;web&gt;
                &lt;module&gt;
                    &lt;java&gt;&lt;xsl:value-of select=<span
class="code-quote">"$artifact"</span>/&gt;&lt;/java&gt;
                &lt;/module&gt;
            &lt;/web&gt;
        &lt;/xsl:<span class="code-keyword">if</span>&gt;
    &lt;/xsl:template&gt;
    
    &lt;xsl:template match=<span class="code-quote">"/ivy-report"</span>&gt;
        &lt;application version=<span class="code-quote">"1.4"</span>
xmlns=<span class="code-quote">"http:<span class="code-comment">//java.sun.com/xml/ns/j2ee"</span>
xmlns:xsi=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
xsi:schemaLocation=<span class="code-quote">"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"</span>&gt;
</span>            &lt;display-name&gt;&lt;xsl:value-of select=<span
class="code-quote">"info/@module"</span>/&gt;&lt;/display-name&gt;
            &lt;xsl:call-template name=<span class="code-quote">"calling"</span>&gt;
                &lt;xsl:with-param name=<span class="code-quote">"org"</span>
select=<span class="code-quote">"info/@organisation"</span>/&gt;
                &lt;xsl:with-param name=<span class="code-quote">"mod"</span>
select=<span class="code-quote">"info/@module"</span>/&gt;
                &lt;xsl:with-param name=<span class="code-quote">"rev"</span>
select=<span class="code-quote">"info/@revision"</span>/&gt;
            &lt;/xsl:call-template&gt;
        &lt;/application&gt;
    &lt;/xsl:template&gt;

&lt;/xsl:stylesheet&gt;
</pre>
</div></div>
<p>asd</p>

<p>asd</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/IVY/Generate+EAR+deployment+descriptor+from+Ivy+resolution+report">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=27844165&revisedVersion=2&originalVersion=1">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/IVY/Generate+EAR+deployment+descriptor+from+Ivy+resolution+report?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message