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.

IncrementalOutputLocationManagerTests.java 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /********************************************************************
  2. * Copyright (c) 2006 Contributors. All rights reserved.
  3. * This program and the accompanying materials are made available
  4. * under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution and is available at
  6. * http://eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: IBM Corporation - initial API and implementation
  9. * Helen Hawkins - initial version
  10. *******************************************************************/
  11. package org.aspectj.systemtest.incremental.tools;
  12. import java.io.File;
  13. import java.util.ArrayList;
  14. import java.util.List;
  15. import org.aspectj.ajde.core.IOutputLocationManager;
  16. /**
  17. * OutputLocationManger tests which check whether the correct type of build has happened.
  18. */
  19. public class IncrementalOutputLocationManagerTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed {
  20. public void testPr166580() {
  21. initialiseProject("PR166580");
  22. configureOutputLocationManager("PR166580",new MyOutputLocationManager("PR166580",2));
  23. build("PR166580");
  24. checkWasFullBuild();
  25. alter("PR166580","inc1");
  26. build("PR166580");
  27. checkWasntFullBuild();
  28. }
  29. /**
  30. * Will send output from src dir 'srcX' to directory 'binX'
  31. */
  32. private class MyOutputLocationManager implements IOutputLocationManager {
  33. private String projectDir;
  34. private int numberOfSrcDirs;
  35. private List allOutputDirs;
  36. public MyOutputLocationManager(String projectName, int numberOfSrcDirs) {
  37. projectDir = getWorkingDir() + File.separator + projectName;
  38. this.numberOfSrcDirs = numberOfSrcDirs;
  39. }
  40. public File getOutputLocationForClass(File compilationUnit) {
  41. String path = compilationUnit.getAbsolutePath();
  42. int index = path.indexOf("src");
  43. String number = path.substring(index +3,index + 4);
  44. File ret = new File(projectDir + File.separator + "bin" + number);
  45. if (!ret.exists()) {
  46. ret.mkdirs();
  47. }
  48. return ret;
  49. }
  50. public File getOutputLocationForResource(File resource) {
  51. return getOutputLocationForClass(resource);
  52. }
  53. public List getAllOutputLocations() {
  54. if (allOutputDirs == null) {
  55. allOutputDirs = new ArrayList();
  56. for (int i = 0; i < numberOfSrcDirs + 1; i++) {
  57. File f = null;
  58. if (i == 0) {
  59. f = new File(projectDir + File.separator + "bin");
  60. } else {
  61. f = new File(projectDir + File.separator + "bin" + i);
  62. }
  63. allOutputDirs.add(f);
  64. }
  65. }
  66. return allOutputDirs;
  67. }
  68. public File getDefaultOutputLocation() {
  69. return new File(projectDir + File.separator + "bin");
  70. }
  71. }
  72. }