Example #1
0
 @Override
 public String toPath(Artifact artifact) {
   Map<String, Object> attributes = toAttributes(artifact);
   if (attributes.containsKey("timestamp")) {
     final Object revisionValue = attributes.get("timestamp");
     String pattern = getPattern().replaceFirst("\\-\\[revision\\]", "-" + revisionValue);
     return IvyPatternHelper.substituteTokens(pattern, attributes);
   }
   return IvyPatternHelper.substituteTokens(getPattern(), attributes);
 }
  public void doExecute() throws BuildException {
    if (organisation == null) {
      throw new BuildException("no organisation provided for ivy listmodules task");
    }
    if (module == null) {
      throw new BuildException("no module name provided for ivy listmodules task");
    }
    if (revision == null) {
      throw new BuildException("no revision provided for ivy listmodules task");
    }
    if (property == null) {
      throw new BuildException("no property provided for ivy listmodules task");
    }
    if (value == null) {
      throw new BuildException("no value provided for ivy listmodules task");
    }

    Ivy ivy = getIvyInstance();
    IvySettings settings = ivy.getSettings();

    SearchEngine searcher = new SearchEngine(settings);
    PatternMatcher patternMatcher = settings.getMatcher(matcher);

    ModuleRevisionId[] mrids;
    if (resolver == null) {
      mrids =
          searcher.listModules(
              ModuleRevisionId.newInstance(organisation, module, branch, revision), patternMatcher);
    } else {
      DependencyResolver depResolver = settings.getResolver(resolver);
      if (depResolver == null) {
        throw new BuildException("Unknown resolver: " + resolver);
      }
      mrids =
          searcher.listModules(
              depResolver,
              ModuleRevisionId.newInstance(organisation, module, branch, revision),
              patternMatcher);
    }

    for (int i = 0; i < mrids.length; i++) {
      String name = IvyPatternHelper.substitute(settings.substitute(property), mrids[i]);
      String value = IvyPatternHelper.substitute(settings.substitute(this.value), mrids[i]);
      getProject().setProperty(name, value);
    }
  }
Example #3
0
 @Override
 public String toModulePath(Artifact artifact) {
   String pattern = getPattern();
   if (!pattern.endsWith(MavenPattern.M2_PATTERN)) {
     throw new UnsupportedOperationException("Cannot locate module for non-maven layout.");
   }
   String metaDataPattern =
       pattern.substring(0, pattern.length() - MavenPattern.M2_PER_MODULE_PATTERN.length() - 1);
   return IvyPatternHelper.substituteTokens(metaDataPattern, toAttributes(artifact));
 }
Example #4
0
 private String getResourceURL() {
   String baseURL =
       IvyPatternHelper.substitute(
           resourceURL,
           mr.getOrganisation(),
           mr.getName(),
           mr.getRevision(),
           null,
           null,
           null,
           null,
           mr.getQualifiedExtraAttributes(),
           null);
   int slash = baseURL.lastIndexOf('/');
   if (slash != -1) {
     baseURL = baseURL.substring(0, slash + 1);
   }
   return baseURL;
 }