View Javadoc
1 /* 2 AntMake 3 4 Copyright (C) 2003 Jose San Leandro Armend?riz 5 jsanleandro@yahoo.es 6 chousz@yahoo.com 7 8 This library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public 10 License as published by the Free Software Foundation; either 11 version 2 of the License, or (at your option) any later version. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 General Public License for more details. 17 18 You should have received a copy of the GNU General Public 19 License along with this library; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 22 Thanks to ACM S.L. for distributing this library under the GPL license. 23 Contact info: jsr000@terra.es 24 Postal Address: c/Playa de Lagoa, 1 25 Urb. Valdecaba?as 26 Boadilla del monte 27 28660 Madrid 28 Spain 29 30 ****************************************************************************** 31 * 32 * Filename: $RCSfile: AntMakeTask.java,v $ 33 * 34 * Author: Jose San Leandro Armend?riz 35 * 36 * Description: Generates required files to build a Java project using GNU 37 * Autoconf, Automake and libtool. 38 * 39 * Last modified by: $Author: chous $ at $Date: 2004/02/03 07:53:23 $ 40 * 41 * File version: $Revision: 1.9 $ 42 * 43 * Project version: $Name: $ 44 * 45 * $Id: AntMakeTask.java,v 1.9 2004/02/03 07:53:23 chous Exp $ 46 * 47 */ 48 package org.acmsl.antmake; 49 50 /* 51 * Importing project classes. 52 */ 53 import org.acmsl.antmake.AntMake; 54 import org.acmsl.antmake.AntMakeException; 55 import org.acmsl.antmake.AntMakeUtils; 56 57 /* 58 * Importing some Ant classes. 59 */ 60 import org.apache.tools.ant.BuildException; 61 import org.apache.tools.ant.Project; 62 import org.apache.tools.ant.taskdefs.Javadoc; 63 import org.apache.tools.ant.taskdefs.MatchingTask; 64 import org.apache.tools.ant.types.FileSet; 65 import org.apache.tools.ant.types.Path; 66 import org.apache.tools.ant.types.Reference; 67 68 /* 69 * Importing some JDK classes. 70 */ 71 import java.io.File; 72 import java.io.IOException; 73 74 /*** 75 * Generates required files to build a Java project using GNU 76 * Autoconf, Automake and libtool. 77 * @author <a href="mailto:jsanleandro@yahoo.es" 78 >Jose San Leandro</a> 79 * @version $Revision: 1.9 $ 80 */ 81 public class AntMakeTask 82 extends MatchingTask 83 { 84 /*** 85 * The source path. 86 */ 87 private Path m__Sourcepath; 88 89 /*** 90 * The class path. 91 */ 92 private Path m__Classpath; 93 94 /*** 95 * The path where to find all licenses of 96 * the required dependencies. 97 */ 98 private Path m__LibLicensePath; 99 100 /*** 101 * The project name. 102 */ 103 private String m__strProjectName; 104 105 /*** 106 * The project version. 107 */ 108 private String m__strProjectVersion; 109 110 /*** 111 * The destination folder. 112 */ 113 private File m__DestinationFolder; 114 115 /*** 116 * The README file. 117 */ 118 private File m__Readme; 119 120 /*** 121 * The AUTHORS file. 122 */ 123 private File m__Authors; 124 125 /*** 126 * The COPYING file. 127 */ 128 private File m__Copying; 129 130 /*** 131 * Creates a AntMakeTask. 132 */ 133 public AntMakeTask() {}; 134 135 /*** 136 * Specifies the sourcepath. 137 * @param sourcepath such path. 138 */ 139 public void setSourcepath(Path sourcepath) 140 { 141 m__Sourcepath = sourcepath; 142 } 143 144 /*** 145 * Retrieves the sourcepath. 146 * @return such path. 147 */ 148 public Path getSourcepath() 149 { 150 return m__Sourcepath; 151 } 152 153 /*** 154 * Creates the source-roots path. 155 * @return such path. 156 */ 157 public Path createSourcepath() 158 { 159 Path result = getSourcepath(); 160 161 if (result == null) 162 { 163 result = new Path(getProject()); 164 setSourcepath(result); 165 } 166 167 return result.createPath(); 168 } 169 170 /*** 171 * Specifies the sourcepath reference. 172 * @param ref such reference. 173 */ 174 public void setSourcepathref(Reference ref) 175 { 176 createSourcepath().setRefid(ref); 177 } 178 179 /*** 180 * Specifies the classpath. 181 * @param classpath such path. 182 */ 183 public void setClasspath(Path classpath) 184 { 185 m__Classpath = classpath; 186 } 187 188 /*** 189 * Retrieves the classpath. 190 * @return such path. 191 */ 192 public Path getClasspath() 193 { 194 return m__Classpath; 195 } 196 197 /*** 198 * Creates the classpath. 199 * @return such path. 200 */ 201 public Path createClasspath() 202 { 203 Path result = getClasspath(); 204 205 if (result == null) 206 { 207 result = new Path(getProject()); 208 setClasspath(result); 209 } 210 211 return result.createPath(); 212 } 213 214 /*** 215 * Specifies the classpath reference. 216 * @param ref such reference. 217 */ 218 public void setClasspathref(Reference ref) 219 { 220 createClasspath().setRefid(ref); 221 } 222 223 /*** 224 * Specifies the library licenses path. 225 * @param liblicensepath such path. 226 */ 227 public void setLiblicensepath(Path liblicensepath) 228 { 229 m__LibLicensePath = liblicensepath; 230 } 231 232 /*** 233 * Retrieves the library licenses path. 234 * @return such path. 235 */ 236 public Path getLiblicensepath() 237 { 238 return m__LibLicensePath; 239 } 240 241 /*** 242 * Creates the library licenses path. 243 * @return such path. 244 */ 245 public Path createLiblicensepath() 246 { 247 Path result = getLiblicensepath(); 248 249 if (result == null) 250 { 251 result = new Path(getProject()); 252 setLiblicensepath(result); 253 } 254 255 return result.createPath(); 256 } 257 258 /*** 259 * Specifies the library licenses path reference. 260 * @param ref such reference. 261 */ 262 public void setLiblicensepathref(Reference ref) 263 { 264 createLiblicensepath().setRefid(ref); 265 } 266 267 /*** 268 * Specifies the project name. 269 * @param name the project name. 270 */ 271 public void setProjectname(String name) 272 { 273 m__strProjectName = name; 274 } 275 276 /*** 277 * Retrieves the project name. 278 * @return such name. 279 */ 280 public String getProjectname() 281 { 282 return m__strProjectName; 283 } 284 285 /*** 286 * Specifies the project version. 287 * @param version the project version. 288 */ 289 public void setProjectversion(String version) 290 { 291 m__strProjectVersion = version; 292 } 293 294 /*** 295 * Retrieves the project version. 296 * @return such version. 297 */ 298 public String getProjectversion() 299 { 300 return m__strProjectVersion; 301 } 302 303 /*** 304 * Specifies the destination folder. 305 * @param destination the base folder of the files to generate. 306 */ 307 public void setDestinationfolder(File destination) 308 { 309 m__DestinationFolder = destination; 310 } 311 312 /*** 313 * Retrieves the destination folder. 314 * @return such folder. 315 */ 316 public File getDestinationfolder() 317 { 318 return m__DestinationFolder; 319 } 320 321 /*** 322 * Specifies the README file. 323 * @param readme such file. 324 */ 325 public void setReadmefile(File readme) 326 { 327 m__Readme = readme; 328 } 329 330 /*** 331 * Retrieves the README file. 332 * @return such file. 333 */ 334 public File getReadmefile() 335 { 336 return m__Readme; 337 } 338 339 /*** 340 * Specifies the AUTHORS file. 341 * @param authors such file. 342 */ 343 public void setAuthorsfile(File authors) 344 { 345 m__Authors = authors; 346 } 347 348 /*** 349 * Retrieves the AUTHORS file. 350 * @return such file. 351 */ 352 public File getAuthorsfile() 353 { 354 return m__Authors; 355 } 356 357 /*** 358 * Specifies the COPYING file. 359 * @param copying such file. 360 */ 361 public void setCopyingfile(File copying) 362 { 363 m__Copying = copying; 364 } 365 366 /*** 367 * Retrieves the COPYING file. 368 * @return such file. 369 */ 370 public File getCopyingfile() 371 { 372 return m__Copying; 373 } 374 375 /*** 376 * Validates the parameters given. 377 * @throws BuildException if any parameter 378 * is not valid. 379 */ 380 protected void validateParameters() 381 throws BuildException 382 { 383 Path t_SourcePath = getSourcepath(); 384 385 if (t_SourcePath == null) 386 { 387 throw new BuildException("No sources specified"); 388 } 389 390 Path t_Classpath = getClasspath(); 391 392 if (t_Classpath == null) 393 { 394 throw new BuildException("No classpath specified"); 395 } 396 397 Path t_LibLicensePath = getLiblicensepath(); 398 399 if (false) //(t_LibLicensePath == null) 400 { 401 throw new BuildException("No library license path specified"); 402 } 403 404 String t_strProjectName = getProjectname(); 405 406 if ( (t_strProjectName == null) 407 || (t_strProjectName.trim().equals(""))) 408 { 409 throw new BuildException("No project name specified"); 410 } 411 412 String t_strProjectVersion = getProjectversion(); 413 414 if ( (t_strProjectVersion == null) 415 || (t_strProjectVersion.trim().equals(""))) 416 { 417 throw new BuildException("No project version specified"); 418 } 419 420 File t_DestinationFolder = getDestinationfolder(); 421 422 if (t_DestinationFolder == null) 423 { 424 throw new BuildException("No destination folder specified"); 425 } 426 427 File t_Readme = getReadmefile(); 428 429 if (t_Readme == null) 430 { 431 throw new BuildException("No README file specified"); 432 } 433 434 File t_Authors = getAuthorsfile(); 435 436 if (t_Authors == null) 437 { 438 throw new BuildException("No AUTHORS file specified"); 439 } 440 441 File t_Copying = getCopyingfile(); 442 443 if (t_Copying == null) 444 { 445 throw new BuildException("No COPYING file specified"); 446 } 447 } 448 449 /*** 450 * Requests the AntMake generation process to be performed. 451 * @throws BuildException whenever the required 452 * parameters are not present or valid. 453 */ 454 public void execute() 455 throws BuildException 456 { 457 validateParameters(); 458 459 AntMake t_AntMake = AntMake.getInstance(); 460 461 AntMakeUtils t_AntMakeUtils = AntMakeUtils.getInstance(); 462 463 FileSet[] t_aFileSets = 464 t_AntMakeUtils.toFileSets( 465 getSourcepath(), 466 new String[] { "**/*" }, 467 new String[] { "**/CVS" }); 468 469 try 470 { 471 t_AntMake.buildProject( 472 getProjectname(), 473 getProjectversion(), 474 getDestinationfolder(), 475 t_aFileSets, 476 getClasspath(), 477 this); 478 } 479 catch (AntMakeException antMakeException) 480 { 481 throw new BuildException(antMakeException); 482 } 483 } 484 }

This page was automatically generated by Maven