Package org.moxie.console

Examples of org.moxie.console.Console


  }

  @Override
  public void execute() {
    Build build = (Build) getProject().getReference(Key.build.referenceId());
    Console console = build.getConsole();

    if (!configured) {
      // called from moxie.compile
      configure(build);
    }

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

    if (builds == null) {
      // top-level mx:javac instantiates the build stack
      builds = new HashSet<Build>();
    }

    if (compileLinkedProjects) {
      for (Build linkedProject: build.getSolver().getLinkedModules()) {
        if (builds.contains(linkedProject)) {
          // already built, skip
          console.debug(1, "skipping {0}, already compiled", linkedProject.getPom().getManagementId());
          continue;
        }
        // add the build to the stack so we do not rebuild
        builds.add(linkedProject);

        try {
          // compile the linked project
          Project project = new Project();
          project.setBaseDir(linkedProject.getConfig().getProjectDirectory());
          project.addReference(Key.build.referenceId(), linkedProject);

          MxJavac subCompile = new MxJavac(builds);
          subCompile.setProject(project);
          subCompile.setShowtitle(false);
          subCompile.perform();
        } catch (Exception e) {
          console.error(e);
          throw new MoxieException(e);
        }
      }
    }

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

    console.debug("mxjavac configuration");

    // display specified mxjavac attributes
    MaxmlMap attributes = build.getConfig().getTaskAttributes(getTaskName());
    AttributeReflector.logAttributes(this, attributes, console);

    // project folder
    console.debug(1, "projectdir = {0}", build.getConfig().getProjectDirectory());

    // create sourcepath
    Path sources = createSrc();
    for (File file : build.getConfig().getSourceDirectories(scope, tag)) {
      PathElement element = sources.createPathElement();
      element.setLocation(file);
    }
    console.debug(1, "sources = {0}", sources);

    // set output folder
    setDestdir(build.getConfig().getOutputDirectory(scope));
    console.debug(1, "destdir = {0}", getDestdir());

    // create classpath
    Path classpath = createClasspath();
    if (Scope.test.equals(scope)) {
      // add the compile output folder
      PathElement element = classpath.createPathElement();
      element.setLocation(build.getConfig().getOutputDirectory(Scope.compile));
    }
    for (File file : build.getSolver().getClasspath(scope)) {
      PathElement element = classpath.createPathElement();
      element.setLocation(file);
    }
    for (Build subbuild : build.getSolver().getLinkedModules()) {
      PathElement element = classpath.createPathElement();
      element.setLocation(subbuild.getConfig().getOutputDirectory(Scope.compile));
    }
    console.debug(1, "classpath = {0}", classpath);

    for (SourceDirectory sd : build.getConfig().getSourceDirectories()) {
      // clean apt source directories before compiling
      if (sd.apt) {
        console.log("Cleaning apt source directory {0}", sd.name);
        FileUtils.delete(sd.getSources());
        sd.getSources().mkdirs();
      }
    }

    if (clean) {
      // clean the output folder before compiling
      console.log("Cleaning output directory {0}", getDestdir().getAbsolutePath());
      FileUtils.delete(getDestdir());
    }

    getDestdir().mkdirs();

    // set the update property name so we know if nothing compiled
    String prop = build.getPom().getCoordinates().replace(':', '.') + ".compiled";
    setUpdatedProperty(prop);
    super.execute();
    if (getProject().getProperty(prop) == null) {
      console.log(1, "compiled classes are up-to-date");
    }

    Copy copy = new Copy();
    copy.setTaskName(getTaskName());
    copy.setProject(getProject());
    copy.setTodir(getDestdir());
    copy.setVerbose(getVerbose());

    if (getVerbose()) {
      console.log("copying resources => {0}", getDestdir());
    }

    if (excludes == null) {
      // default exclusions
      excludes = Toolkit.DEFAULT_CODE_EXCLUDES;
    }

    for (String path : getSrcdir().list()) {
      File file = new File(path);
      if (file.isDirectory()) {
        FileSet set = prepareResourceSet(file);
        copy.addFileset(set);
        if (getVerbose()) {
          console.log("adding resource path {0}", path);
        }
      }
    }

    copy.execute();
View Full Code Here


  }

  @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();
    }
View Full Code Here

  }
 
  @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);
      }
     
      for (File jarFile : linkedProject.getSolver().getClasspath(Scope.compile)) {
        classpath.createPathElement().setLocation(jarFile);
      }
    }

    console.debug(getCommandLine().describeCommand());
   
    super.execute();
    Date end = new Date();
    console.key("finished", MessageFormat.format("{0} ({1} secs)", end, (end.getTime() - start.getTime())/1000L));
  }
View Full Code Here

  protected Console getConsole() {
    if (console == null) {
      Build build = getBuild();
      if (build == null) {
        console = new Console();
      } else {
        console = build.getConsole();
      }
    }
    return console;
View Full Code Here

  private final Date buildDate;

  public Build(File configFile, File basedir) throws MaxmlException, IOException {
    this.config = new BuildConfig(configFile, basedir);

    this.console = new Console(config.isColor());
    this.console.setDebug(config.isDebug());

    this.solver = new Solver(console, config);
    this.buildDate = new Date();
  }
View Full Code Here

    this.requiredDependencies = new HashMap<Scope, Collection<Dependency>>();
    this.solutions = new HashMap<Scope, Set<Dependency>>();
    this.classpaths = new HashMap<Scope, List<File>>();
    this.linkedModuleBuilds = new ArrayList<Build>();
    this.registeredUrls = new HashSet<String>();
    this.console = console == null ? new Console(config.isColor()) : console;
   
    this.moxieCache.setMavenCacheStrategy(config.getMavenCacheStrategy());
    this.moxieCache.setLogger(console);
   
    // define required dependencies
View Full Code Here

    }
    folder.mkdirs();
    System.setProperty("mx.root", folder.getAbsolutePath());
    System.out.println("mx.root=" + folder.getAbsolutePath());
    BuildConfig config = new BuildConfig(new File("test.moxie"), null);
    Solver solver = new Solver(new Console(), config);
    return solver;
  }
View Full Code Here

TOP

Related Classes of org.moxie.console.Console

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.