Examples of MaxmlMap


Examples of org.moxie.maxml.MaxmlMap

    apply = new TreeSet<String>();
    proxies = new ArrayList<Proxy>();
    modules = new ArrayList<Module>();
    dependencyAliases = new HashMap<String, Dependency>();
    dependencyOverrides = new HashMap<Scope, Map<String, Pom>>();
    tasks = new MaxmlMap();
    externalProperties = new HashMap<String, String>();
    updatePolicy = UpdatePolicy.defaultPolicy;
    revisionRetentionCount = 1;
    revisionPurgeAfterDays = 0;
  }
View Full Code Here

Examples of org.moxie.maxml.MaxmlMap

    return parse(content, defaultResource);
  }


  ToolkitConfig parse(String content, String defaultResource) throws IOException, MaxmlException {
    MaxmlMap map = Maxml.parse(content);

    if (map.containsKey(Key.requires.name())) {
      // enforce a required minimum Moxie version
      String req = map.getString(Key.requires.name(), null);
      ArtifactVersion requires = new ArtifactVersion(req);
      ArtifactVersion running = new ArtifactVersion(Toolkit.getVersion());
      if (running.compareTo(requires) == -1) {
        throw new MoxieException("Moxie {0} required for this script.", requires);
      }
    }

    if (!StringUtils.isEmpty(defaultResource)) {
      // build.moxie inheritance
      File parentConfig = readFile(map, Key.parent, null);
      if (parentConfig == null) {
        File defaultFile = new File(Toolkit.getMxRoot(), defaultResource);
        if (this.file == null || this.file.equals(defaultFile) || !defaultFile.exists()) {
          // Moxie-shipped default resource
          ToolkitConfig parent = new ToolkitConfig("/" + defaultResource);
          setDefaultsFrom(parent);
        } else {
          // local filesystem default is available
          ToolkitConfig parent = new ToolkitConfig(defaultFile, baseDirectory, defaultResource);
          setDefaultsFrom(parent);
        }
      } else {
        // parent has been specified
        ToolkitConfig parent = new ToolkitConfig(parentConfig, baseDirectory, defaultResource);
        setDefaultsFrom(parent);
      }
    }

    // metadata (partially preserve inherited defaults)
    pom.name = readString(map, Key.name, null);
    pom.version = readString(map, Key.version, pom.version);
    pom.groupId = readString(map, Key.groupId, pom.groupId);
    pom.artifactId = readString(map, Key.artifactId, null);
    pom.classifier = readString(map, Key.classifier, null);
    pom.description = readString(map, Key.description, null);
    pom.url = readString(map, Key.url, pom.url);
    pom.organization = readString(map, Key.organization, pom.organization);
    pom.organizationUrl = readString(map, Key.organizationUrl, pom.organizationUrl);
    pom.issuesUrl = readString(map, Key.issuesUrl, pom.issuesUrl);
    pom.inceptionYear = readString(map, Key.inceptionYear, pom.inceptionYear);
    pom.packaging = readString(map, Key.packaging, pom.packaging);
    pom.getDevelopers().addAll(readPersons(map, Key.developers));
    pom.getContributors().addAll(readPersons(map, Key.contributors));
    pom.getLicenses().addAll(readLicenses(map, Key.licenses));
    pom.forumUrl = readString(map, Key.forumUrl, pom.forumUrl);
    pom.socialNetworkUrl = readString(map, Key.socialNetworkUrl, pom.socialNetworkUrl);
    pom.blogUrl = readString(map, Key.blogUrl, pom.blogUrl);
    pom.ciUrl = readString(map, Key.ciUrl, pom.ciUrl);
    pom.mavenUrl = readString(map, Key.mavenUrl, pom.mavenUrl);

    String parentPom = map.getString(Key.parentPom.name(), null);
    if (!StringUtils.isEmpty(parentPom)) {
      // config specifies a parent pom
      Dependency parent = new Dependency(parentPom);
      pom.parentGroupId = parent.groupId;
      pom.parentArtifactId = parent.artifactId;
      pom.parentVersion = parent.version;
    }

    // scm metadata
    if (map.containsKey(Key.scm)) {
      MaxmlMap scm = map.getMap(Key.scm.name());
      pom.scm.connection = scm.getString(Key.connection.name(), null);
      pom.scm.developerConnection = scm.getString(Key.developerConnection.name(), null);
      pom.scm.url = scm.getString(Key.url.name(), null);
      pom.scm.tag = scm.getString(Key.tag.name(), null);
    }

    // set default name to artifact id
    if (StringUtils.isEmpty(pom.name)) {
      pom.name = pom.artifactId;
    }

    mainclass = readString(map, Key.mainclass, null);
    pom.releaseVersion = readString(map, Key.releaseVersion, pom.releaseVersion);
    pom.releaseDate = map.getDate(Key.releaseDate.name(), pom.releaseDate);

    // build parameters
    mavenCacheStrategy = MavenCacheStrategy.fromString(map.getString(Key.mavenCacheStrategy.name(), mavenCacheStrategy == null ? null : mavenCacheStrategy.name()));
    parallelDownloads = map.getBoolean(Key.parallelDownloads.name(), parallelDownloads);
    failFastOnArtifactResolution = map.getBoolean(Key.failFastOnArtifactResolution.name(), failFastOnArtifactResolution);
    apply = new TreeSet<String>(readStrings(map, Key.apply, new ArrayList<String>(apply), true));
    outputDirectory = readFile(map, Key.outputDirectory, new File(baseDirectory, "build"));
    targetDirectory = readFile(map, Key.targetDirectory, new File(baseDirectory, "build/target"));
    sourceDirectories = readSourceDirectories(map, Key.sourceDirectories, sourceDirectories);
    if (sourceDirectories.isEmpty()) {
      // container descriptors (e.g. POM) can define modules
      modules = readModules(map, Key.modules);
    } else {
      // standard project/modules can define linked modules which are
      // treated as extensions of this projects sourceDirectories and
      // dependencies
      linkedModules = readModules(map, Key.modules);
    }
    resourceDirectories = readSourceDirectories(map, Key.resourceDirectories, resourceDirectories);
    dependencyDirectory = readFile(map, Key.dependencyDirectory, null);
    dependencyNamePattern = map.getString(Key.dependencyNamePattern.name(), dependencyNamePattern);

    String policy = readString(map, Key.updatePolicy, null);
    if (!StringUtils.isEmpty(policy)) {
      int mins = 0;
      if (policy.indexOf(':') > -1) {
        mins = Integer.parseInt(policy.substring(policy.indexOf(':') + 1));
        policy = policy.substring(0, policy.indexOf(':'));
      }
      updatePolicy = UpdatePolicy.fromString(policy);
      if (UpdatePolicy.interval.equals(updatePolicy) && mins > 0) {
        updatePolicy.setMins(mins);
      }
    }

    // default snapshot purge policy
    revisionRetentionCount = Math.min(Toolkit.MAX_REVISIONS,
        Math.max(1, map.getInt(Key.revisionRetentionCount.name(), revisionRetentionCount)));
    revisionPurgeAfterDays = Math.min(Toolkit.MAX_PURGE_AFTER_DAYS,
        Math.max(0, map.getInt(Key.revisionPurgeAfterDays.name(), revisionPurgeAfterDays)));

    if (map.containsKey(Key.properties.name())) {
      MaxmlMap props = map.getMap(Key.properties.name());
      for (String key : props.keySet()) {
        pom.setProperty(key, props.getString(key, null));
      }
    }

    List<String> managedDependencies = readStrings(map, Key.dependencyManagement, new ArrayList<String>());
    for (String dependency : managedDependencies) {
      Dependency dep = new Dependency(dependency);
      pom.addManagedDependency(dep, null);
    }

    registeredRepositories = parseRemoteRepositories(map, Key.registeredRepositories, registeredRepositories);
    repositories = map.getStrings(Key.repositories.name(), repositories);
    parseDependencyAliases(map, Key.dependencyAliases);
    parseDependencies(map, Key.dependencies);
    parseDependencyOverrides(map, Key.dependencyOverrides);
    parseProxies(map, Key.proxies);

    pom.addExclusions(readStrings(map, Key.exclusions, new ArrayList<String>(), true));

    // all task attributes are inherited. individual attributes can be overridden
    if (map.containsKey("tasks")) {
      MaxmlMap taskOverrides = map.getMap("tasks");
      for (Map.Entry<String, Object> entry : taskOverrides.entrySet()) {
        String task = entry.getKey();
        MaxmlMap taskAttributes  = (MaxmlMap) entry.getValue();
        if (tasks.containsKey(task)) {
          // update existing entry with attribute overrides
          tasks.getMap(task).putAll(taskAttributes);
        } else {
          // new entry
View Full Code Here

Examples of org.moxie.maxml.MaxmlMap

    return this;
  }

  void parseDependencyAliases(MaxmlMap map, Key key) {
    if (map.containsKey(key.name())) {
      MaxmlMap aliases = map.getMap(key.name());
      for (Map.Entry<String, Object> entry : aliases.entrySet()) {
        String definition = entry.getValue().toString();
        Dependency dep = new Dependency(definition);
        dependencyAliases.put(entry.getKey(), dep);
      }
    }
View Full Code Here

Examples of org.moxie.maxml.MaxmlMap

    }
  }

  void parseDependencyOverrides(MaxmlMap map, Key key) {
    if (map.containsKey(key.name())) {
      MaxmlMap poms = map.getMap(key.name());
      for (Map.Entry<String, Object> entry: poms.entrySet()) {
        String definition = entry.getKey();
        if (entry.getValue() instanceof MaxmlMap) {
          Dependency dep = new Dependency(definition);
          Pom override = new Pom();
          override.groupId = dep.groupId;
          override.artifactId = dep.artifactId;
          override.version = dep.version;

          if (StringUtils.isEmpty(override.version)) {
            throw new RuntimeException(MessageFormat.format("{0} setting for {1} must specify a version!", Key.dependencyOverrides.name(), definition));
          }

          MaxmlMap depMap = (MaxmlMap) entry.getValue();
          for (String def : depMap.getStrings(Key.dependencies.name(), new ArrayList<String>())) {
            processDependency(def, override);
          }

          if (depMap.containsKey(Key.scope.name())) {
            // scopes specified
            for (String value : depMap.getStrings(Key.scope.name(), new ArrayList<String>())) {
              Scope scope = Scope.fromString(value);
              if (scope == null) {
                scope = Scope.defaultScope;
              }
              if (!dependencyOverrides.containsKey(scope)) {
View Full Code Here

Examples of org.moxie.maxml.MaxmlMap

    if (map.containsKey(key.name())) {
      for (Object o : map.getList(key.name(), Collections.emptyList())) {
        if (o instanceof String) {
          remotes.add(new RemoteRepository("", o.toString(), false));
        } else if (o instanceof MaxmlMap) {
          MaxmlMap repoMap = (MaxmlMap) o;
          String id = repoMap.getString("id", null);
          String url = repoMap.getString("url", null).replace('\\', '/');
          boolean allowSnapshots = repoMap.getBoolean("allowSnapshots", false);
          RemoteRepository repo = new RemoteRepository(id, url, allowSnapshots);
          repo.purgePolicy.retentionCount = Math.min(Toolkit.MAX_REVISIONS,
              Math.max(1, repoMap.getInt(Key.revisionRetentionCount.name(), revisionRetentionCount)));
          repo.purgePolicy.purgeAfterDays = Math.min(Toolkit.MAX_PURGE_AFTER_DAYS,
              Math.max(0, repoMap.getInt(Key.revisionPurgeAfterDays.name(), revisionPurgeAfterDays)));
          for (String value : repoMap.getStrings("affinity", new ArrayList<String>())) {
            repo.affinity.add(value.toLowerCase());
          }
          repo.connectTimeout = repoMap.getInt(Key.connectTimeout.name(), repo.connectTimeout);
          repo.readTimeout = repoMap.getInt(Key.readTimeout.name(), repo.readTimeout);
          repo.username = repoMap.getString(Key.username.name(), null);
          repo.password = repoMap.getString(Key.password.name(), null);
          remotes.add(repo);
        }
      }
      return remotes;
    }
View Full Code Here

Examples of org.moxie.maxml.MaxmlMap

                  }
                }
              }
            }
          } else if (value instanceof MaxmlMap) {
            MaxmlMap dirMap = (MaxmlMap) value;
            String dir = StringUtils.stripQuotes(readRequiredString(dirMap, Key.dir));
            Scope scope = Scope.fromString(readRequiredString(dirMap, Key.scope));
            List<String> tags = dirMap.getStrings("tags", new ArrayList<String>());
            if (scope == null) {
              scope = Scope.defaultScope;
            } else {
              if (!scope.isValidSourceScope()) {
                scope = Scope.defaultScope;
View Full Code Here

Examples of org.moxie.maxml.MaxmlMap

  List<Person> readPersons(MaxmlMap map, Key key) {
    List<Person> list = new ArrayList<Person>();
    if (map.containsKey(key)) {
      for (Object o : map.getList(key.name(), new ArrayList<Object>())) {
        if (o instanceof MaxmlMap) {
          MaxmlMap m = (MaxmlMap) o;
          Person p = new Person();
          p.id = m.getString(Key.id.name(), null);
          p.name = m.getString(Key.name.name(), null);
          p.email = m.getString(Key.email.name(), null);
          p.organization = m.getString(Key.organization.name(), null);
          p.organizationUrl = m.getString(Key.organizationUrl.name(), null);
          p.url = m.getString(Key.url.name(), null);
          p.roles = m.getStrings(Key.roles.name(), new ArrayList<String>());
          list.add(p);
        }
      }
    }
    return list;
View Full Code Here

Examples of org.moxie.maxml.MaxmlMap

  List<License> readLicenses(MaxmlMap map, Key key) {
    List<License> list = new ArrayList<License>();
    if (map.containsKey(key)) {
      for (Object o : map.getList(key.name(), new ArrayList<Object>())) {
        if (o instanceof MaxmlMap) {
          MaxmlMap m = (MaxmlMap) o;
          String name = m.getString(Key.name.name(), null);
          String url = m.getString(Key.url.name(), null);
          License license = new License(name, url);

          license.distribution = m.getString("distribution", null);
          license.comments = m.getString("comments", null);

          list.add(license);
        }
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.