Package org.moxie

Examples of org.moxie.Build


    this.redirectorElement = redirectorElement;
  }

  @Override
  public void execute() {
    Build build = (Build) getProject().getReference(Key.build.referenceId());
    Console console = build.getConsole();
   
    if (destDir == null) {
      // use default output folder
      destDir = build.getConfig().getJavadocTargetDirectory();
      super.setDestdir(destDir);
    }
   
    if (!addedFileset) {
      // add all compile source folders from project
      for (File folder : build.getConfig().getSourceDirectories(Scope.compile)) {
        FileSet fs = new FileSet();
        fs.setProject(getProject());
        fs.setDir(folder);
        addFileset(fs);
      }
    }

    if (isShowTitle()) {
      console.title(getClass(), build.getPom().getCoordinates());
    }
   
    if (redirectorElement != null) {
      console.log(1, "Generating Javadoc... please wait");
      redirectedOutput = true;
      redirectorElement.configure(redirector);
      redirector.createStreams();
    }

    super.execute();

    try {
      if (redirectedOutput) {
        redirector.complete();
      }
    } catch (IOException e) {
      throw new MoxieException(e);
    }
   
    // create javadoc jar
    Zip jar = new Zip();
    jar.setProject(getProject());
    jar.setBasedir(destDir);
    jar.setDestFile(new File(build.getConfig().getTargetDirectory(),
        MessageFormat.format("{0}-{1}-javadoc.jar",
            build.getPom().artifactId, build.getPom().version)));
    jar.execute();
  }
View Full Code Here


    this.scope = Scope.fromString(value);
  }
 
  @Override
  public void execute() {
    Build build = (Build) getProject().getReference(Key.build.referenceId());
    Console console = build.getConsole();

    if (scope == null) {
      scope = Scope.compile;
    }

    if (isShowTitle()) {
      console.title(getClass(), build.getPom().getCoordinates() + ", " + scope.name());
    }

    if (StringUtils.isEmpty(getCommandLine().getClassname())) {
      getCommandLine().setClassname(build.getConfig().getProjectConfig().getMainclass());
    }

    Date start = new Date();
    console.key("started", start.toString());
    console.key("mainclass", getCommandLine().getClassname());
    console.log();
   
    Path classpath = createClasspath();
    // add project compiled output path
    classpath.createPathElement().setLocation(build.getConfig().getOutputDirectory(scope));
    if (!scope.isDefault()) {
      classpath.createPathElement().setLocation(build.getConfig().getOutputDirectory(Scope.compile));
    }
   
    // add resource directories
    for (File dir : build.getConfig().getResourceDirectories(scope)) {
      classpath.createPathElement().setLocation(dir);
    }
    if (!scope.isDefault()) {
      for (File dir : build.getConfig().getResourceDirectories(Scope.compile)) {
        classpath.createPathElement().setLocation(dir);
      }
    }
   
    // add jar classpaths
    for (File jarFile : build.getSolver().getClasspath(scope)) {
      classpath.createPathElement().setLocation(jarFile);
    }

    // add linked projects compiled output path, resource directories, and jar files
    for (Build linkedProject : build.getSolver().getLinkedModules()) {
      classpath.createPathElement().setLocation(linkedProject.getConfig().getOutputDirectory(Scope.compile));
     
      for (File dir : linkedProject.getConfig().getResourceDirectories(Scope.compile)) {
        classpath.createPathElement().setLocation(dir);
      }
View Full Code Here

    /**
     * Load the file and then execute it
     */
    public void execute() throws BuildException {
    Build build = (Build) getProject().getReference(Key.build.referenceId());
    MxTask.loadRuntimeDependencies(build, new Dependency("mx:groovy"));
   
    if (scope != null) {
      createProjectClasspath(build);
    }
   
    if (fork) {
      createForkClasspath();
    }

        if (srcFile == null && StringUtils.isEmpty(command) && filesets.isEmpty()) {
            throw new BuildException("Source file does not exist!", getLocation());
        }

        if (srcFile != null && !srcFile.exists()) {
            throw new BuildException(MessageFormat.format("Source file {0} does not exist!", srcFile), getLocation());
        }
       
        // if there are no groovy statements between the enclosing Groovy tags
        // then read groovy statements in from a text file using the src attribute
        if (StringUtils.isEmpty(command)) {
            createClasspath().add(new Path(getProject(), srcFile.getParentFile().getAbsolutePath()));
            command = FileUtils.readContent(srcFile, "\n");
        }

        if (StringUtils.isEmpty(command)) {
            throw new BuildException("No Groovy statements to execute!", getLocation());
        }

    if (isShowTitle()) {
      build.getConsole().title(getClass(), srcFile != null ? srcFile.getAbsolutePath() : subtitle);
    }

        PrintStream out = System.out;
        try {
            GroovyEngine groovy = new GroovyEngine();
          if (fork) {
            groovy.forkGroovy(this, command);
          } else {
            if (output != null) {
              build.getConsole().debug("Opening PrintStream to output file " + output);
              out = new PrintStream(
                  new BufferedOutputStream(
                      new FileOutputStream(output.getAbsolutePath(), append)));
            }
            groovy.execGroovy(this, command, out);
View Full Code Here

    skips = new ArrayList<String>();
    substitutions = new ArrayList<Substitute>();
  }
 
  public void execute() {
    Build build = getBuild();

    if (prototypeFile == null) {
      getConsole().error("Please specify a source web.xml file!");
      throw new RuntimeException();
    }

    if (destinationFile == null) {
      getConsole().error("Please specify a destination file!");
      throw new RuntimeException();
    }

    // read properties file
    StringBuilder parameters = new StringBuilder();
    if (propertiesFile != null) {
      try {
        BufferedReader propertiesReader = new BufferedReader(new FileReader(propertiesFile));

        Vector<Setting> settings = new Vector<Setting>();
        List<String> comments = new ArrayList<String>();
        String line = null;
        while ((line = propertiesReader.readLine()) != null) {
          if (line.length() == 0) {
            comments.clear();
          } else {
            if (line.charAt(0) == '#') {
              if (line.length() > 1) {
                comments.add(line.substring(1).trim());
              }
            } else {
              String[] kvp = line.split("=", 2);
              String key = kvp[0].trim();
              if (!skipKey(key)) {
                Setting s = new Setting(key, kvp[1].trim(), comments);
                settings.add(s);
              }
              comments.clear();
            }
          }
        }
        propertiesReader.close();

        for (Setting setting : settings) {
          for (String comment : setting.comments) {
            parameters.append(MessageFormat.format(COMMENT_PATTERN, comment));
          }
          parameters.append(MessageFormat.format(PARAM_PATTERN, setting.name,
              StringUtils.escapeForHtml(setting.value, false)));
        }
      } catch (Throwable t) {
        getConsole().error(t);
        throw new BuildException(t);
      }
    }

    titleClass();
    getConsole().key("source", prototypeFile.getAbsolutePath());
    if (propertiesFile != null) {
      build.getConsole().key("properties", propertiesFile.getAbsolutePath());
    }
    getConsole().key("generated", destinationFile.getAbsolutePath());
    try {
      // Read the prototype web.xml file
      char[] buffer = new char[(int) prototypeFile.length()];
      FileReader webxmlReader = new FileReader(prototypeFile);
      webxmlReader.read(buffer);
      webxmlReader.close();
      String webXmlContent = new String(buffer);

      // Insert the properties into the prototype web.xml
      for (String stripToken : STRIP_TOKENS) {
        webXmlContent = webXmlContent.replace(stripToken, "");
      }
      int idx = webXmlContent.indexOf(PARAMS);
      StringBuilder sb = new StringBuilder();
      sb.append(webXmlContent.substring(0, idx));
      sb.append(parameters.toString());
      sb.append(webXmlContent.substring(idx + PARAMS.length()));
     
      String content = sb.toString();
      for (Substitute sub : substitutions) {
        content = content.replace(sub.token, sub.value.toString());
      }

      // Save the merged web.xml to the destination file
      FileOutputStream os = new FileOutputStream(destinationFile, false);
      os.write(content.getBytes("UTF-8"));
      os.close();
    } catch (Throwable t) {
      build.getConsole().error(t);
      throw new BuildException(t);
    }
  }
View Full Code Here

    artifacts.add(artifact);
    return artifact;
  }

  public void execute() {
    Build build = (Build) getProject().getReference(Key.build.referenceId());
    if (zipFile == null) {
      // default output jar if file unspecified
      String name = build.getPom().artifactId;
      if (!StringUtils.isEmpty(build.getPom().version)) {
        name += "-" + build.getPom().version;
      }
      zipFile = new File(build.getConfig().getTargetDirectory(), name + ".zip");
    }
   
    if (zipFile.getParentFile() != null) {
      zipFile.getParentFile().mkdirs();
    }
   
    for (ZipArtifact artifact : artifacts) {
      ZipFileSet fs = new ZipFileSet();
      fs.setProject(getProject());
      File file = artifact.getFile();
      if (file == null) {
        file = build.getBuildArtifact(artifact.getClassifier());
      }
      fs.setDir(file.getParentFile());
      fs.setIncludes(file.getName());
      if (!StringUtils.isEmpty(artifact.getPrefix())) {
        fs.setPrefix(artifact.getPrefix());
      }
      addZipfileset(fs);
    }
   
    for (ZipDependencies deps : dependencies) {
      for (File jar : build.getSolver().getClasspath(deps.getScope(), deps.getTag())) {
        ZipFileSet fs = new ZipFileSet();
        fs.setProject(getProject());
        if (!StringUtils.isEmpty(deps.getPrefix())) {
          fs.setPrefix(deps.getPrefix());
        }
View Full Code Here

            super.zipFile(file, zOut, vPath, mode);
        }
    }

  public void execute() {
    Build build = (Build) getProject().getReference(Key.build.referenceId());
    if (zipFile == null) {
      // default output war if file unspecified
      String name = build.getPom().artifactId;
      if (!StringUtils.isEmpty(build.getPom().version)) {
        name += "-" + build.getPom().version;
      }
      zipFile = new File(build.getConfig().getTargetDirectory(), name + ".war");
    }
   
    if (zipFile.getParentFile() != null) {
      zipFile.getParentFile().mkdirs();
    }
   
    for (ZipArtifact artifact : artifacts) {
      ZipFileSet fs = new ZipFileSet();
      fs.setProject(getProject());
      File file = artifact.getFile();
      if (file == null) {
        file = build.getBuildArtifact(artifact.getClassifier());
      }
      fs.setPrefix("WEB-INF/lib");
      fs.setDir(file.getParentFile());
      fs.setIncludes(file.getName());
      if (!StringUtils.isEmpty(artifact.getPrefix())) {
        fs.setPrefix(artifact.getPrefix());
      }
      addZipfileset(fs);
    }
   
    for (ZipDependencies deps : dependencies) {
      for (File jar : build.getSolver().getClasspath(deps.getScope(), deps.getTag())) {
        ZipFileSet fs = new ZipFileSet();
        fs.setProject(getProject());
        if (!StringUtils.isEmpty(deps.getPrefix())) {
          fs.setPrefix(deps.getPrefix());
        }
View Full Code Here

  }
 
  @Override
  public void setProject(Project project) {
    super.setProject(project);
    Build build = (Build) getProject().getReference(Key.build.referenceId());
    if (build != null) {
      configure(build);
    }
  }
View Full Code Here

    setGeneratePom(true);
    setCalculatechecksums(true);
  }
 
  public void execute() {
    Build build = getBuild();
   
    Pom pom = build.getPom();
    if (!allowSnapshots && pom.isSnapshot()) {
      // do not install snapshots into the repository
      return;
    }
   
    Dependency asDependency = new Dependency(pom.getCoordinates());
    IMavenCache cache = getArtifactCache(pom.isSnapshot());
    File artifactFile = cache.getArtifact(asDependency, asDependency.extension);
    File artifactDir = artifactFile.getParentFile();
    File sourceDir = build.getConfig().getTargetDirectory();
   
    titleClass(pom.artifactId + "-" + pom.version);

    deployRelease(pom, sourceDir, artifactDir, false);
  }
View Full Code Here

  public void setOutput(String type) {
    this.output = type;
  }

  public void execute() {
    Build build = getBuild();
   
    if (destinationDirectory == null) {
      getConsole().error("Please specify a destination directory!");
      throw new RuntimeException();
    }

    if (maxDimension == 0) {
      getConsole().error("Please specify a maximum dimension!");
      throw new RuntimeException();
    }
   
    if (sourceDirectory == null) {
      getConsole().error("Please specify an source directory!");
      throw new RuntimeException();
    }

    destinationDirectory.mkdirs();
    File[] sourceFiles = sourceDirectory.listFiles(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        return name.toLowerCase().endsWith("." + input);
      }
    });
   
    if (sourceFiles != null) {
      build.getConsole().log("Generating {0} {1}", sourceFiles.length, sourceFiles.length == 1 ? "thumbnail" : "thumbnails");
      for (File sourceFile : sourceFiles) {
        String name = sourceFile.getName();
        name = name.substring(0, name.lastIndexOf('.') + 1) + output;
        File destinationFile = new File(destinationDirectory, name);
        try {
          Dimension sz = getImageDimensions(sourceFile);
          int w = 0;
          int h = 0;
          if (sz.width > maxDimension) {
            // Scale to Width
            w = maxDimension;
            float f = maxDimension;
            // normalize height
            h = (int) ((f / sz.width) * sz.height);
          } else if (sz.height > maxDimension) {
            // Scale to Height
            h = maxDimension;
            float f = maxDimension;
            // normalize width
            w = (int) ((f / sz.height) * sz.width);
          }
          build.getConsole().debug(1, "thumbnail for {0} as ({1,number,#}, {2,number,#})",
              sourceFile.getName(), w, h);
          BufferedImage image = ImageIO.read(sourceFile);
          Image scaledImage = image.getScaledInstance(w, h, BufferedImage.SCALE_SMOOTH);
          BufferedImage destImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
          destImage.createGraphics().drawImage(scaledImage, 0, 0, null);
          FileOutputStream fos = new FileOutputStream(destinationFile);
          ImageIO.write(destImage, output, fos);
          fos.flush();
          fos.getFD().sync();
          fos.close();
        } catch (Throwable t) {
          build.getConsole().error(t, "failed to generate thumbnail for {0}", sourceFile);
        }
      }
    }
  }
View Full Code Here

    this.obliterate = value;
  }

  @Override
  public void execute() throws BuildException {
    Build build = getBuild();
    titleClass();
    loadDependencies();

    if (sourceDir == null) {
      sourceDir = build.getConfig().getSiteTargetDirectory();
    }

    if (!sourceDir.exists()) {
      throw new MoxieException("Source folder does not exist!");
    }
View Full Code Here

TOP

Related Classes of org.moxie.Build

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.