KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > clirr > maven > ClirrUtils


1 //////////////////////////////////////////////////////////////////////////////
2
//Clirr: compares two versions of a java library for binary compatibility
3
//Copyright (C) 2004 Lars Kühne
4
//
5
//This library is free software; you can redistribute it and/or
6
//modify it under the terms of the GNU Lesser General Public
7
//License as published by the Free Software Foundation; either
8
//version 2.1 of the License, or (at your option) any later version.
9
//
10
//This library is distributed in the hope that it will be useful,
11
//but WITHOUT ANY WARRANTY; without even the implied warranty of
12
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
//Lesser General Public License for more details.
14
//
15
//You should have received a copy of the GNU Lesser General Public
16
//License along with this library; if not, write to the Free Software
17
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
//////////////////////////////////////////////////////////////////////////////
19

20 package net.sf.clirr.maven;
21
22 import java.io.File JavaDoc;
23 import java.util.List JavaDoc;
24
25 import org.apache.maven.jelly.MavenJellyContext;
26 import org.apache.maven.project.Version;
27 import org.apache.maven.util.HttpUtils;
28
29
30 /**
31  * Utility class to manipulate POM version information.
32  *
33  * @author Vincent Massol
34  */

35 public class ClirrUtils
36 {
37     /**
38      * @return the latest released version, which means the latest version
39      * listed in the POM <version> elements with a
40      * <code>tag</code> different from <code>HEAD</code>. Returns
41      * null if no latest released version is found
42      * @param versions the list of {@link Version} objects from the POM
43      */

44     public static String JavaDoc getLatestVersion(List JavaDoc versions)
45     {
46         String JavaDoc result = null;
47         
48         if (!versions.isEmpty())
49         {
50             int pos = versions.size();
51             while (pos > 0)
52             {
53                 Version latestVersion =
54                     (Version) versions.get(pos - 1);
55                 
56                 // Is it a released version?
57
if (!latestVersion.getTag().equalsIgnoreCase("HEAD"))
58                 {
59                     result = latestVersion.getId();
60                     break;
61                 }
62                 else
63                 {
64                     pos = pos - 1;
65                 }
66             }
67         }
68         
69         return result;
70     }
71
72     /**
73      * TODO: Add support for proxies
74      */

75     public static void getBaselineJar(MavenJellyContext context)
76         throws Exception JavaDoc
77     {
78         String JavaDoc targetFileName = (String JavaDoc) context.getVariable("clirr.baseline.destination");
79         File JavaDoc targetFile = new File JavaDoc(targetFileName);
80         HttpUtils.getFile(
81             (String JavaDoc) context.getVariable("clirr.baseline.url"),
82             targetFile,
83             false,
84             true,
85             null,
86             null,
87             null,
88             null);
89     }
90     
91 }
92
Popular Tags