You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ProductModule.java 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* *******************************************************************
  2. * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Xerox/PARC initial implementation
  11. * ******************************************************************/
  12. package org.aspectj.internal.tools.build;
  13. import java.io.File;
  14. /**
  15. * Struct associating module with target product distribution jar
  16. * and assembly instructions.
  17. * When building product distributions, a zero-length jar file
  18. * in the dist directory may signify a module to be built,
  19. * renamed, and included in the distribution.
  20. */
  21. public class ProductModule {
  22. /** name of distribution directory in product directory */
  23. private static final String DIST = "dist";
  24. /** top-level product directory being produced */
  25. public final File productDir;
  26. /** path to file in distribution template dir for this module jar */
  27. public final File replaceFile;
  28. /** relative path within distribution of this product module jar */
  29. public final String relativePath;
  30. /** the module jar is the file to replace */
  31. public final Module module;
  32. /** if true, assemble all when building module */
  33. public final boolean assembleAll;
  34. public ProductModule(File productDir, File replaceFile, Module module, boolean assembleAll) {
  35. this.replaceFile = replaceFile;
  36. this.module = module;
  37. this.productDir = productDir;
  38. this.assembleAll = assembleAll;
  39. Util.iaxIfNull(module, "module");
  40. Util.iaxIfNotCanReadDir(productDir, "productDir");
  41. Util.iaxIfNotCanReadFile(replaceFile, "replaceFile");
  42. String productDirPath = productDir.getAbsolutePath();
  43. String replaceFilePath = replaceFile.getAbsolutePath();
  44. if (!replaceFilePath.startsWith(productDirPath)) {
  45. String m = "\"" + replaceFilePath
  46. + "\" does not start with \""
  47. + productDirPath
  48. + "\"";
  49. throw new IllegalArgumentException(m);
  50. }
  51. replaceFilePath = replaceFilePath.substring(1+productDirPath.length());
  52. if (!replaceFilePath.startsWith(DIST)) {
  53. String m = "\"" + replaceFilePath
  54. + "\" does not start with \"" + DIST + "\"";
  55. throw new IllegalArgumentException(m);
  56. }
  57. relativePath = replaceFilePath.substring(1 + DIST.length());
  58. }
  59. public String toString() {
  60. return "" + module + " for " + productDir;
  61. }
  62. }