Exemplo n.º 1
0
  private String composeAllFileContents(IFolder folder) {
    String contents = "";
    try {
      int lineNumber = 0;
      for (IResource member : folder.members()) {
        if (member.getType() == IResource.FILE
            && DeltajComposer.FILE_EXT.equals("." + member.getFileExtension())) {
          DeltajFile file = new DeltajFile((IFile) member, lineNumber, 0);

          InputStream source = null;
          source = ((IFile) member).getContents();
          BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(source));
          StringBuilder stringBuilder = new StringBuilder();
          String line = null;
          while ((line = bufferedReader.readLine()) != null) {
            stringBuilder.append(line + "\n");
            lineNumber++;
          }
          bufferedReader.close();
          contents += stringBuilder.toString() + "\n";
          file.setEndLine(lineNumber++);
          this.deltajFiles.add(file);
        } else if (member.getType() == IResource.FOLDER) {
          contents += composeAllFileContents((IFolder) member);
        }
      }
    } catch (CoreException e) {
      DeltajCorePlugin.getDefault().logError(e);
    } catch (IOException e) {
      DeltajCorePlugin.getDefault().logError(e);
    }
    return contents;
  }
Exemplo n.º 2
0
 private String parseApplicationRules() {
   String deltas = "";
   try {
     InputStream source = null;
     source =
         this.featureProject.getProject().getFile(DeltajComposer.FILENAME_RULES).getContents();
     BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(source));
     StringBuilder stringBuilder = new StringBuilder();
     String line = null;
     while ((line = bufferedReader.readLine()) != null) stringBuilder.append(line + "\n");
     bufferedReader.close();
     deltas += stringBuilder.toString() + "\n";
   } catch (CoreException e) {
     DeltajCorePlugin.getDefault().logError(e);
   } catch (IOException e) {
     DeltajCorePlugin.getDefault().logError(e);
   }
   return deltas;
 }
Exemplo n.º 3
0
  @Override
  public void performFullBuild(IFile config) {
    if (!isPluginInstalled(PLUGIN_ID_XTEXT)) {
      generateWarning(PLUGIN_WARNING_XTEXT);
      return;
    }
    if (!isPluginInstalled(PLUGIN_ID_XTYPES)) {
      generateWarning(PLUGIN_WARNING_XTYPES);
      return;
    }
    // init console
    MessageConsole console = new MessageConsole("DeltaJ Error Log", null);
    console.activate();
    ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] {(IConsole) console});
    consoleMessageStream = console.newMessageStream();

    // initialization
    this.errors = 0;
    this.errorReport = "";
    boolean ioError = false;
    this.outputPath = this.featureProject.getBuildPath().replace('\\', '/') + "/";
    this.configName = config.getName().split("\\.")[0];
    this.spl = new DeltajSPLDefinition();
    IFolder sourceFolder = featureProject.getSourceFolder();
    this.featureModel = featureProject.getFeatureModel();
    this.spl.setName(this.featureModel.getRoot().getName());

    // get all features
    this.spl.addAllFeatures(this.featureModel.getConcreteFeatures());

    // get deltas specification
    this.spl.setDeltas(parseApplicationRules());

    // get current configuration
    Configuration configuration = new Configuration(this.featureModel);
    ConfigurationReader reader = new ConfigurationReader(configuration);
    try {
      reader.readFromFile(config);
    } catch (CoreException e) {
      DeltajCorePlugin.getDefault().logError(e);
    } catch (IOException e) {
      DeltajCorePlugin.getDefault().logError(e);
    }

    // collect all deltaj files of selected features
    String composedDeltas = "";
    deltajFiles = new ArrayList<DeltajFile>();
    composedDeltas += composeAllFileContents(sourceFolder);
    composedDeltas += this.spl.toString();
    composedDeltas += this.createProductDefinition(configuration);

    IFile tmpFile =
        featureProject
            .getProject()
            .getFile(featureProject.getBuildFolder().getName() + "/tmp" + DeltajComposer.FILE_EXT);
    InputStream in = new ByteArrayInputStream(composedDeltas.getBytes());
    try {
      tmpFile.create(in, false, null);
    } catch (CoreException e) {
      DeltajCorePlugin.getDefault().logError(e);
    }

    // compile
    compileResource(tmpFile.getFullPath().toString());

    // cleanup
    try {
      tmpFile.delete(false, null);
    } catch (CoreException e) {
      DeltajCorePlugin.getDefault().logError(e);
    }

    // print errors

    if (!issueList.isEmpty()) {
      for (Issue issue : issueList) {
        printError(issue);
      }
    }
    consoleMessageStream.print(
        "DeltaJ Files compiled with " + this.errors + (this.errors == 1 ? " error" : " errors"));
    if (this.errors != 0 || ioError) {
      this.errorReport += "\n" + this.errors + " compile errors";
      System.out.println(this.errorReport);
    }
  }