private Artifact unify(Artifact dependent, Artifact dependency) {
    for (Entry<String, String> unification : unified.entrySet()) {
      String groupFilter = unification.getKey();
      String version = unification.getValue();
      String artifactId = dependency.toString();

      if ("".equals(version)) {
        version = dependent.getVersion();
      }
      if (artifactId.startsWith(groupFilter) && (!"".equals(version))) {
        Artifact retVal =
            new DefaultArtifact(
                dependency.getGroupId(),
                dependency.getArtifactId(),
                dependency.getClassifier(),
                dependency.getExtension(),
                // The important one
                version);
        retVal.setProperties(dependency.getProperties());
        return retVal;
      }
    }

    return dependency;
  }
  public DependentLoaderImplementation findOverride(Artifact artifactId) {
    if (overridingLoaders.size() == 0) return null;
    String asString = artifactId.toString();
    for (Wildcards wild : overridingLoaders) {
      if (asString.startsWith(wild.what)) return wild.loader;
    }

    return null;
  }
  private File findOverrideFile(Artifact artifactId) {
    if (overridingLoaders.size() == 0) return null;
    String asString = artifactId.toString();
    for (Wildcards wild : overridingLoaders) {

      if (wild.where.length > 0 && asString.startsWith(wild.what)) {
        return wild.where[0];
      }
    }

    return null;
  }
Exemplo n.º 4
0
 @Override
 public String toString() {
   return delegate.toString();
 }
 private String toString(Artifact artifactId) {
   return artifactId.toString();
   //		return
   // artifactId.getGroupId()+":"+artifactId.getArtifactId()+":"+artifactId.getClassifier()+":"+artifactId.getBaseVersion();
 }
  public DependentLoaderImplementation enshureJarLoaded(Artifact _artifactId) {
    Artifact artifactId = unify(_artifactId);

    if ("dependent".equals(artifactId.getArtifactId())
        && "no.dbwatch".equals(artifactId.getGroupId())) {
      return null;
    }
    DependentLoaderImplementation theLoader = findOverride(artifactId);
    if (theLoader != null) {
      visitLoader(theLoader);
      return theLoader;
    }
    if (loaderMap.containsKey(toString(artifactId))) return loaderMap.get(toString(artifactId));
    // Fetch jar and dependencies.
    OutputBouble bouble = OutputBouble.push();

    try {
      Result<File> localFileName = dependencyManager.getLocalFile(artifactId);

      if (localFileName.success())
        theLoader =
            new DependentLoaderImplementation(
                artifactId,
                localFileName.val.getAbsoluteFile().toURI().toURL(),
                exposed,
                parentLoader);
      else theLoader = new DependentLoaderImplementation(artifactId, exposed, parentLoader);
      setLoader(theLoader);

      List<Artifact> dependencies = dependencyManager.getDirectDependencies(artifactId);

      DependentLoaderImplementation[] actualDependencies =
          new DependentLoaderImplementation[dependencies.size() + theLoader.dependencies.length];
      int i = 0;
      for (DependentLoaderImplementation dependencyFromConf : theLoader.dependencies) {
        actualDependencies[i++] = dependencyFromConf;
      }
      for (Artifact dependencyId : dependencies) {

        DependentLoaderImplementation loader = enshureDependencyJarLoaded(artifactId, dependencyId);
        if (loader == null) {
          OutputBouble.logFile.println(artifactId.toString() + ":");
          OutputBouble.logFile.println("\t Missing dependency " + dependencyId.toString());
          OutputBouble.logFile.println("\t Ignoring");
        } else {
          actualDependencies[i++] = loader;
        }
      }
      if (actualDependencies.length > i) {
        actualDependencies = Arrays.copyOf(actualDependencies, i);
      }

      theLoader.setDependencies(actualDependencies);

      extraDependencies.loaderAdded(theLoader);

      visitLoader(theLoader);
      return theLoader;
    } catch (Exception e) {
      OutputBouble.reportError(e);
      return theLoader;
    } finally {
      bouble.pop();
      if (bouble.isError) bouble.writeToParent();
    }
    // return null;
  }
Exemplo n.º 7
0
 private static String atrifactToString(Artifact artifact) {
   return artifact.toString() + " < " + artifact.getFile();
 }