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 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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.Collections;
  15. import java.util.List;
  16. import java.util.Map;
  17. import org.aspectj.ajde.core.IOutputLocationManager;
  18. /**
  19. * OutputLocationManger tests which check whether the correct type of build has happened.
  20. */
  21. public class IncrementalOutputLocationManagerTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed {
  22. public void testPr166580() {
  23. initialiseProject("PR166580");
  24. configureOutputLocationManager("PR166580", new MyOutputLocationManager("PR166580", 2));
  25. build("PR166580");
  26. checkWasFullBuild();
  27. alter("PR166580", "inc1");
  28. build("PR166580");
  29. checkWasntFullBuild();
  30. }
  31. /**
  32. * Will send output from src dir 'srcX' to directory 'binX'
  33. */
  34. private class MyOutputLocationManager implements IOutputLocationManager {
  35. private String projectDir;
  36. private int numberOfSrcDirs;
  37. private List<File> allOutputDirs;
  38. public MyOutputLocationManager(String projectName, int numberOfSrcDirs) {
  39. projectDir = getWorkingDir() + File.separator + projectName;
  40. this.numberOfSrcDirs = numberOfSrcDirs;
  41. }
  42. public void reportFileWrite(String outputfile, int filetype) {
  43. }
  44. public void reportFileRemove(String outputfile, int filetype) {
  45. }
  46. public Map<File,String> getInpathMap() {
  47. return Collections.emptyMap();
  48. }
  49. public File getOutputLocationForClass(File compilationUnit) {
  50. String path = compilationUnit.getAbsolutePath();
  51. int index = path.indexOf("src");
  52. String number = path.substring(index + 3, index + 4);
  53. File ret = new File(projectDir + File.separator + "bin" + number);
  54. if (!ret.exists()) {
  55. ret.mkdirs();
  56. }
  57. return ret;
  58. }
  59. public File getOutputLocationForResource(File resource) {
  60. return getOutputLocationForClass(resource);
  61. }
  62. public List<File> getAllOutputLocations() {
  63. if (allOutputDirs == null) {
  64. allOutputDirs = new ArrayList<>();
  65. for (int i = 0; i < numberOfSrcDirs + 1; i++) {
  66. File f = null;
  67. if (i == 0) {
  68. f = new File(projectDir + File.separator + "bin");
  69. } else {
  70. f = new File(projectDir + File.separator + "bin" + i);
  71. }
  72. allOutputDirs.add(f);
  73. }
  74. }
  75. return allOutputDirs;
  76. }
  77. public File getDefaultOutputLocation() {
  78. return new File(projectDir + File.separator + "bin");
  79. }
  80. public String getSourceFolderForFile(File sourceFile) {
  81. return null;
  82. }
  83. public int discoverChangesSince(File dir, long buildtime) {
  84. // TODO Auto-generated method stub
  85. return 0;
  86. }
  87. }
  88. }