/[schmitzm]/trunk/src/skrueger/versionnumber/ReleaseUtil.java
ViewVC logotype

Diff of /trunk/src/skrueger/versionnumber/ReleaseUtil.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1019 by alfonx, Mon Sep 20 17:41:04 2010 UTC revision 1187 by alfonx, Wed Oct 27 22:46:45 2010 UTC
# Line 21  import org.apache.log4j.Logger; Line 21  import org.apache.log4j.Logger;
21   *   *
22   * <br/>   * <br/>
23   *         1. pom.xml anpassen: <code>   *         1. pom.xml anpassen: <code>
24                          <plugin>                                          <plugin>
25                                  <groupId>org.codehaus.mojo</groupId>                                  <groupId>org.codehaus.mojo</groupId>
26                                  <artifactId>buildnumber-maven-plugin</artifactId>                                  <artifactId>buildnumber-maven-plugin</artifactId>
27                                  <version>1.0-beta-4</version>                                  <version>1.0-beta-4</version>
# Line 35  import org.apache.log4j.Logger; Line 35  import org.apache.log4j.Logger;
35                                          </execution>                                          </execution>
36                                  </executions>                                  </executions>
37                                  <configuration>                                  <configuration>
38                                                                            <!-- <doCheck>false</doCheck> <doUpdate>false</doUpdate> <providerImplementations>
39                                          <doCheck>false</doCheck>                                                  <svn>javasvn</svn> </providerImplementations> -->
40                                          <doUpdate>false</doUpdate>                                          <format>{0,date,yyyyMMddHHmm}</format>
41                                          <providerImplementations>                                          <items>
42                                                  <svn>javasvn</svn>                                                  <item>timestamp</item>
43                                          </providerImplementations>                                          </items>
44                                  </configuration>                                  </configuration>
45                          </plugin>                          </plugin>
46                  </code><br/>                  </code><br/>
# Line 70  public class ReleaseUtil { Line 70  public class ReleaseUtil {
70          private static Logger log = Logger.getLogger(ReleaseUtil.class);          private static Logger log = Logger.getLogger(ReleaseUtil.class);
71    
72          /**          /**
73           * This is the main public API method which never throws an exception.           * Returns all (the most) information in one sting. This is a public method
74             * which never throws an Exception.
75           *           *
76           * @param clazz           * @param clazz
77           *            Pass a class that resides in the same "project" or jar, where           *            Pass a class that resides in the same "project" or jar, where
# Line 117  public class ReleaseUtil { Line 118  public class ReleaseUtil {
118    
119                          return str;                          return str;
120                  } catch (final Exception e) {                  } catch (final Exception e) {
121                          log.error("/release.properties could not be read from "                          log.error(
122                                          + clazz.getSimpleName(), e);                                          "/release.properties could not be read from "
123                                                            + clazz.getSimpleName(), e);
124                          return "0";                          return "0";
125                  }                  }
126    
# Line 154  public class ReleaseUtil { Line 156  public class ReleaseUtil {
156                                  return defaultVer;                                  return defaultVer;
157                          return versionProperty;                          return versionProperty;
158                  } catch (final Exception e) {                  } catch (final Exception e) {
159                          log.error("/release.properties could not be read from "                          log.error(
160                                          + clazz.getSimpleName(), e);                                          "/release.properties could not be read from "
161                                                            + clazz.getSimpleName(), e);
162                          return defaultVer;                          return defaultVer;
163                  }                  }
164    
# Line 208  public class ReleaseUtil { Line 211  public class ReleaseUtil {
211          }          }
212    
213          /**          /**
214           * @param clazz           * Different types of licenses supported.
          *            Pass a class that resides in the same "project" or jar, where  
          *            the /release.properties resides as well.  
          *  
          *            Print the GPL disclaimer to the given {@link Logger} on INFO  
          *            level.  
215           */           */
216          public static void logGPLCopyright(final Logger logger) {          public enum License {
217                  logger                  LGPL3, GPL3
218                                  .info("\nThis program is free software: you can redistribute it and/or modify\n"          };
219                                                  + "it under the terms of the GNU General Public License as published by\n"  
220                                                  + "the Free Software Foundation, either version 3 of the License, or\n"          /**
221                                                  + "(at your option) any later version.\n"           * Print the GPL disclaimer to the given {@link Logger} on INFO level.
222                                                  + "\n"           *
223                                                  + "This program is distributed in the hope that it will be useful,\n"           * @param progname
224                                                  + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"           *            Name of the program as printed in the license. Will
225                                                  + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"           *            automatically be starting with an upper-case letter.
226                                                  + "GNU General Public License for more details.\n");           *            <code>null</code> will fall-back to <code>This program</code>
227             */
228            public static String getLicense(License l, String progname) {
229                    if (progname == null || progname.isEmpty())
230                            progname = "This program";
231                    switch (l) {
232                    case GPL3:
233                            return ("\n"
234                                            + progname
235                                            + " is free software: you can redistribute it and/or modify\n"
236                                            + "it under the terms of the GNU General Public License as published by\n"
237                                            + "the Free Software Foundation, either version 3 of the License, or\n"
238                                            + "(at your option) any later version.\n"
239                                            + "\n"
240                                            + progname
241                                            + " is distributed in the hope that it will be useful,\n"
242                                            + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
243                                            + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n" + "GNU General Public License for more details.\n");
244                    case LGPL3:
245                            return ("\n"
246                                            + progname
247                                            + " is free software: you can redistribute it and/or modify\n"
248                                            + "it under the terms of the GNU Lesser General Public License as published by\n"
249                                            + "the Free Software Foundation, either version 3 of the License, or\n"
250                                            + "(at your option) any later version.\n"
251                                            + "\n"
252                                            + progname
253                                            + " is distributed in the hope that it will be useful,\n"
254                                            + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
255                                            + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n" + "GNU Lesser General Public License for more details.\n");
256                    }
257                    throw new IllegalArgumentException();
258          }          }
259    
260          /**          public static boolean isSnapshot(Class<?> clazz) {
261           * @param clazz                  return getVersionInfo(clazz).contains("SNAPSHOT");
          *            Pass a class that resides in the same "project" or jar, where  
          *            the /release.properties resides as well.  
          *  
          *            Print the LGPL disclaimer to the given {@link Logger} on INFO  
          *            level.  
          */  
         public static void logLGPLCopyright(final Logger logger) {  
                 logger  
                                 .info("\nThis program is free software: you can redistribute it and/or modify\n"  
                                                 + "it under the terms of the GNU Lesser General Public License as published by\n"  
                                                 + "the Free Software Foundation, either version 3 of the License, or\n"  
                                                 + "(at your option) any later version.\n"  
                                                 + "\n"  
                                                 + "This program is distributed in the hope that it will be useful,\n"  
                                                 + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"  
                                                 + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"  
                                                 + "GNU Lesser General Public License for more details.\n");  
262          }          }
263  }  }

Legend:
Removed from v.1019  
changed lines
  Added in v.1187

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26