コード例 #1
0
ファイル: SrampWagon.java プロジェクト: rnc/s-ramp
 /**
  * Ensures that the required ArtifactGrouping is present in the repository.
  *
  * @throws SrampAtomException
  * @throws SrampClientException
  */
 private BaseArtifactType ensureArtifactGrouping()
     throws SrampClientException, SrampAtomException {
   String groupingName = getParamFromRepositoryUrl("artifactGrouping"); // $NON-NLS-1$
   if (groupingName == null || groupingName.trim().length() == 0) {
     logger.warn(Messages.i18n.format("NO_ARTIFACT_GROUPING_NAME")); // $NON-NLS-1$
     return null;
   }
   QueryResultSet query =
       client
           .buildQuery("/s-ramp/ext/ArtifactGrouping[@name = ?]")
           .parameter(groupingName)
           .count(2)
           .query(); //$NON-NLS-1$
   if (query.size() > 1) {
     logger.warn(
         Messages.i18n.format("MULTIPLE_ARTIFACT_GROUPSING_FOUND", groupingName)); // $NON-NLS-1$
     return null;
   } else if (query.size() == 1) {
     ArtifactSummary summary = query.get(0);
     return client.getArtifactMetaData(summary.getType(), summary.getUuid());
   } else {
     ExtendedArtifactType groupingArtifact = new ExtendedArtifactType();
     groupingArtifact.setArtifactType(BaseArtifactEnum.EXTENDED_ARTIFACT_TYPE);
     groupingArtifact.setExtendedType("ArtifactGrouping"); // $NON-NLS-1$
     groupingArtifact.setName(groupingName);
     groupingArtifact.setDescription(
         Messages.i18n.format("ARTIFACT_GROUPING_DESCRIPTION")); // $NON-NLS-1$
     return client.createArtifact(groupingArtifact);
   }
 }
コード例 #2
0
 private void setDisableP2Mirrors(TargetPlatformConfiguration result, Xpp3Dom configuration) {
   Xpp3Dom disableP2mirrorsDom = configuration.getChild("disableP2Mirrors");
   if (disableP2mirrorsDom != null) {
     logger.warn(
         "Unsupported target-platform-configuration <disableP2Mirrors>. Use tycho.disableP2Mirrors -D command line parameter or settings.xml property.");
   }
 }
コード例 #3
0
 @Override
 public void mojoSkipped(ExecutionEvent event) {
   if (logger.isWarnEnabled()) {
     logger.warn(
         "Goal "
             + event.getMojoExecution().getGoal()
             + " requires online mode for execution but Maven is currently offline, skipping");
   }
 }
コード例 #4
0
 protected TargetEnvironment getDeprecatedTargetEnvironment(Xpp3Dom configuration) {
   Xpp3Dom environmentDom = configuration.getChild("environment");
   if (environmentDom != null) {
     logger.warn(
         "target-platform-configuration <environment> element is deprecated; use <environments> instead");
     return newTargetEnvironment(environmentDom);
   }
   return null;
 }
コード例 #5
0
ファイル: CourtHandler.java プロジェクト: sdgdsffdsfff/wdbc
  public void handle(ThreadContext ctx) throws ThreadException {
    Court court = ctx.getModel().getCourt();

    if (court != null && court.isEligible()) {
      try {
        startCourt(ctx);
        updateModel(ctx);
      } catch (Exception e) {
        m_logger.warn("Error when handling Court.", e);
      }
    }
  }
コード例 #6
0
  private void parseLifecyclePhaseDefinitions(
      Map<Plugin, Plugin> plugins, String phase, LifecyclePhase goals) {
    List<LifecycleMojo> mojos = goals.getMojos();
    if (mojos != null) {

      for (int i = 0; i < mojos.size(); i++) {
        LifecycleMojo mojo = mojos.get(i);

        GoalSpec gs = parseGoalSpec(mojo.getGoal());

        if (gs == null) {
          logger.warn(
              "Ignored invalid goal specification '"
                  + mojo.getGoal()
                  + "' from lifecycle mapping for phase "
                  + phase);
          continue;
        }

        Plugin plugin = new Plugin();
        plugin.setGroupId(gs.groupId);
        plugin.setArtifactId(gs.artifactId);
        plugin.setVersion(gs.version);

        Plugin existing = plugins.get(plugin);
        if (existing != null) {
          if (existing.getVersion() == null) {
            existing.setVersion(plugin.getVersion());
          }
          plugin = existing;
        } else {
          plugins.put(plugin, plugin);
        }

        PluginExecution execution = new PluginExecution();
        execution.setId(getExecutionId(plugin, gs.goal));
        execution.setPhase(phase);
        execution.setPriority(i - mojos.size());
        execution.getGoals().add(gs.goal);
        execution.setConfiguration(mojo.getConfiguration());

        plugin.setDependencies(mojo.getDependencies());
        plugin.getExecutions().add(execution);
      }
    }
  }
コード例 #7
0
  private void checkMultiArtifactOutputConfig(final DependencySet dependencySet) {
    String dir = dependencySet.getOutputDirectory();
    if (dir == null) {
      dir = defaultOutputDirectory;
    }

    String mapping = dependencySet.getOutputFileNameMapping();
    if (mapping == null) {
      mapping = defaultOutputFileNameMapping;
    }

    if ((dir == null || dir.indexOf("${") < 0) && (mapping == null || mapping.indexOf("${") < 0)) {
      logger.warn(
          "NOTE: Your assembly specifies a dependencySet that matches multiple artifacts, but specifies a concrete output format. "
              + "THIS MAY RESULT IN ONE OR MORE ARTIFACTS BEING OBSCURED!\n\nOutput directory: '"
              + dir
              + "'\nOutput filename mapping: '"
              + mapping
              + "'");
    }
  }
コード例 #8
0
 public void delegate() {
   switch (level) {
     case LEVEL_DEBUG:
       logger.debug(message, cause);
       break;
     case LEVEL_INFO:
       logger.info(message, cause);
       break;
     case LEVEL_WARN:
       logger.warn(message, cause);
       break;
     case LEVEL_ERROR:
       logger.error(message, cause);
       break;
     case LEVEL_FATAL:
       logger.fatalError(message, cause);
       break;
     default:
       throw new Error();
   }
 }
  /** Add jar files in libs into the project classpath. */
  private void addLibsJarsToClassPath(
      UnpackedLibHelper helper, MavenProject project, Artifact artifact)
      throws MavenExecutionException {
    try {
      final File unpackLibFolder = helper.getUnpackedLibFolder(artifact);
      final File artifactFile = helper.getArtifactToFile(artifact);
      ZipFile zipFile = new ZipFile(artifactFile);
      Enumeration enumeration = zipFile.entries();
      while (enumeration.hasMoreElements()) {
        ZipEntry entry = (ZipEntry) enumeration.nextElement();
        String entryName = entry.getName();

        // Only jar files under 'libs' directory to be processed.
        if (Pattern.matches("^libs/.+\\.jar$", entryName)) {
          final File libsJarFile = new File(unpackLibFolder, entryName);
          log.warn("Adding jar from libs folder to classpath: " + libsJarFile);

          // In order to satisfy the LifecycleDependencyResolver on execution up to a phase that
          // has a Mojo requiring dependency resolution I need to create a dummy classesJar here.
          if (!libsJarFile.getParentFile().exists()) {
            libsJarFile.getParentFile().mkdirs();
          }
          libsJarFile.createNewFile();

          // Add the jar to the classpath.
          final Dependency dependency =
              createSystemScopeDependency(artifact, libsJarFile, libsJarFile.getName());

          project.getModel().addDependency(dependency);
          addedJarFromLibs = true;
        }
      }
    } catch (MojoExecutionException e) {
      log.debug("Error extract jars");
    } catch (ZipException e) {
      log.debug("Error");
    } catch (IOException e) {
      log.debug("Error");
    }
  }
コード例 #10
0
  public TargetPlatformConfiguration getTargetPlatformConfiguration(
      MavenSession session, MavenProject project) {
    TargetPlatformConfiguration result = new TargetPlatformConfiguration();

    // Use org.eclipse.tycho:target-platform-configuration/configuration/environment, if provided
    Plugin plugin = project.getPlugin("org.eclipse.tycho:target-platform-configuration");

    if (plugin != null) {
      Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
      if (configuration != null) {
        if (logger.isDebugEnabled()) {
          logger.debug(
              "target-platform-configuration for "
                  + project.toString()
                  + ":\n"
                  + configuration.toString());
        }

        addTargetEnvironments(result, project, configuration);

        setTargetPlatformResolver(result, configuration);

        setTarget(result, session, project, configuration);

        setPomDependencies(result, configuration);

        setAllowConflictingDependencies(result, configuration);

        setDisableP2Mirrors(result, configuration);

        setExecutionEnvironment(result, configuration);

        readFilters(result, configuration);

        readExtraRequirements(result, configuration);

        setOptionalDependencies(result, configuration);

        setIncludePackedArtifacts(result, configuration);
      }
    }

    if (result.getEnvironments().isEmpty()) {
      TychoProject projectType = projectTypes.get(project.getPackaging());
      if (projectType != null) {
        TargetEnvironment env = projectType.getImplicitTargetEnvironment(project);
        if (env != null) {
          if (logger.isDebugEnabled()) {
            logger.debug(
                "Implicit target environment for " + project.toString() + ": " + env.toString());
          }

          result.addEnvironment(env);
        }
      }
    }

    if (result.getEnvironments().isEmpty()) {
      // applying defaults
      logger.warn(
          "No explicit target runtime environment configuration. Build is platform dependent.");

      // Otherwise, use project or execution properties, if provided
      Properties properties =
          (Properties) project.getContextValue(TychoConstants.CTX_MERGED_PROPERTIES);

      // Otherwise, use current system os/ws/nl/arch
      String os = PlatformPropertiesUtils.getOS(properties);
      String ws = PlatformPropertiesUtils.getWS(properties);
      String arch = PlatformPropertiesUtils.getArch(properties);

      result.addEnvironment(new TargetEnvironment(os, ws, arch));

      result.setImplicitTargetEnvironment(true);
    } else {
      result.setImplicitTargetEnvironment(false);
    }

    return result;
  }
コード例 #11
0
  protected Set<Artifact> resolveDependencyArtifacts(final DependencySet dependencySet)
      throws InvalidAssemblerConfigurationException {
    final Set<Artifact> dependencyArtifacts = new LinkedHashSet<Artifact>();
    if (resolvedArtifacts != null) {
      dependencyArtifacts.addAll(resolvedArtifacts);
    }

    if (dependencySet.isUseProjectArtifact()) {
      final Artifact projectArtifact = project.getArtifact();
      if ((projectArtifact != null) && (projectArtifact.getFile() != null)) {
        dependencyArtifacts.add(projectArtifact);
      } else {
        logger.warn(
            "Cannot include project artifact: "
                + projectArtifact
                + "; it doesn't have an associated file or directory.");
      }
    }

    if (dependencySet.isUseProjectAttachments()) {
      @SuppressWarnings("unchecked")
      final List<Artifact> attachments = project.getAttachedArtifacts();
      if (attachments != null) {
        for (final Iterator<Artifact> attachmentIt = attachments.iterator();
            attachmentIt.hasNext(); ) {
          final Artifact attachment = attachmentIt.next();

          if (attachment.getFile() != null) {
            dependencyArtifacts.add(attachment);
          } else {
            logger.warn(
                "Cannot include attached artifact: "
                    + project.getId()
                    + " for project: "
                    + project.getId()
                    + "; it doesn't have an associated file or directory.");
          }
        }
      }
    }

    if (dependencySet.isUseTransitiveFiltering()) {
      logger.debug("Filtering dependency artifacts USING transitive dependency path information.");
    } else {
      logger.debug(
          "Filtering dependency artifacts WITHOUT transitive dependency path information.");
    }

    final ScopeArtifactFilter filter = new ScopeArtifactFilter(dependencySet.getScope());

    FilterUtils.filterArtifacts(
        dependencyArtifacts,
        dependencySet.getIncludes(),
        dependencySet.getExcludes(),
        dependencySet.isUseStrictFiltering(),
        dependencySet.isUseTransitiveFiltering(),
        logger,
        filter);

    return dependencyArtifacts;
  }
コード例 #12
0
  protected void addDependencySet(
      final DependencySet dependencySet,
      final Archiver archiver,
      final AssemblerConfigurationSource configSource)
      throws AssemblyFormattingException, ArchiveCreationException,
          InvalidAssemblerConfigurationException {
    logger.debug("Processing DependencySet (output=" + dependencySet.getOutputDirectory() + ")");

    if (!dependencySet.isUseTransitiveDependencies() && dependencySet.isUseTransitiveFiltering()) {
      logger.warn(
          "DependencySet has nonsensical configuration: useTransitiveDependencies == false "
              + "AND useTransitiveFiltering == true. Transitive filtering flag will be ignored.");
    }

    final Set<Artifact> dependencyArtifacts = resolveDependencyArtifacts(dependencySet);

    boolean filterContents = false;
    final UnpackOptions opts = dependencySet.getUnpackOptions();
    if (dependencySet.isUnpack()
        && opts != null
        && (opts.isFiltered() || opts.getLineEnding() != null)) {
      filterContents = true;
    } else if (dependencyArtifacts.size() > 1) {
      checkMultiArtifactOutputConfig(dependencySet);
    }

    logger.debug("Adding " + dependencyArtifacts.size() + " dependency artifacts.");

    for (final Iterator<Artifact> j = dependencyArtifacts.iterator(); j.hasNext(); ) {
      final Artifact depArtifact = j.next();

      MavenProject depProject;
      try {
        depProject =
            projectBuilder.buildFromRepository(
                depArtifact,
                configSource.getRemoteRepositories(),
                configSource.getLocalRepository());
      } catch (final ProjectBuildingException e) {
        logger.debug(
            "Error retrieving POM of module-dependency: "
                + depArtifact.getId()
                + "; Reason: "
                + e.getMessage()
                + "\n\nBuilding stub project instance.");

        depProject = buildProjectStub(depArtifact);
      }

      if (NON_ARCHIVE_DEPENDENCY_TYPES.contains(depArtifact.getType())) {
        addNonArchiveDependency(depArtifact, depProject, dependencySet, archiver, configSource);
      } else {
        if (filterContents) {
          addFilteredUnpackedArtifact(
              dependencySet, depArtifact, depProject, archiver, configSource);
        } else {
          addNormalArtifact(dependencySet, depArtifact, depProject, archiver, configSource);
        }
      }
    }
  }
コード例 #13
0
  private void resolveOld(
      Artifact artifact,
      List<ArtifactRepository> remoteRepositories,
      RepositorySystemSession session)
      throws ArtifactResolutionException, ArtifactNotFoundException {
    if (artifact == null) {
      return;
    }

    if (Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) {
      File systemFile = artifact.getFile();

      if (systemFile == null) {
        throw new ArtifactNotFoundException(
            "System artifact: " + artifact + " has no file attached", artifact);
      }

      if (!systemFile.exists()) {
        throw new ArtifactNotFoundException(
            "System artifact: " + artifact + " not found in path: " + systemFile, artifact);
      }

      if (!systemFile.isFile()) {
        throw new ArtifactNotFoundException(
            "System artifact: " + artifact + " is not a file: " + systemFile, artifact);
      }

      artifact.setResolved(true);

      return;
    }

    if (!artifact.isResolved()) {
      ArtifactResult result;

      try {
        ArtifactRequest artifactRequest = new ArtifactRequest();
        artifactRequest.setArtifact(RepositoryUtils.toArtifact(artifact));
        artifactRequest.setRepositories(RepositoryUtils.toRepos(remoteRepositories));

        // Maven 2.x quirk: an artifact always points at the local repo, regardless whether resolved
        // or not
        LocalRepositoryManager lrm = session.getLocalRepositoryManager();
        String path = lrm.getPathForLocalArtifact(artifactRequest.getArtifact());
        artifact.setFile(new File(lrm.getRepository().getBasedir(), path));

        result = repoSystem.resolveArtifact(session, artifactRequest);
      } catch (org.eclipse.aether.resolution.ArtifactResolutionException e) {
        if (e.getCause() instanceof org.eclipse.aether.transfer.ArtifactNotFoundException) {
          throw new ArtifactNotFoundException(
              e.getMessage(),
              artifact.getGroupId(),
              artifact.getArtifactId(),
              artifact.getVersion(),
              artifact.getType(),
              artifact.getClassifier(),
              remoteRepositories,
              artifact.getDownloadUrl(),
              artifact.getDependencyTrail(),
              e);
        } else {
          throw new ArtifactResolutionException(e.getMessage(), artifact, remoteRepositories, e);
        }
      }

      artifact.selectVersion(result.getArtifact().getVersion());
      artifact.setFile(result.getArtifact().getFile());
      artifact.setResolved(true);

      if (artifact.isSnapshot()) {
        Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher(artifact.getVersion());
        if (matcher.matches()) {
          Snapshot snapshot = new Snapshot();
          snapshot.setTimestamp(matcher.group(2));
          try {
            snapshot.setBuildNumber(Integer.parseInt(matcher.group(3)));
            artifact.addMetadata(new SnapshotArtifactRepositoryMetadata(artifact, snapshot));
          } catch (NumberFormatException e) {
            logger.warn(
                "Invalid artifact version " + artifact.getVersion() + ": " + e.getMessage());
          }
        }
      }
    }
  }
  @Override
  public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
    log.debug("");
    log.debug("ClasspathModifierLifecycleParticipant#afterProjectsRead - start");
    log.debug("");

    log.debug("CurrentProject=" + session.getCurrentProject());
    final List<MavenProject> projects = session.getProjects();
    final DependencyResolver dependencyResolver =
        new DependencyResolver(log, dependencyGraphBuilder);
    final ArtifactResolverHelper artifactResolverHelper =
        new ArtifactResolverHelper(artifactResolver, log);

    for (MavenProject project : projects) {
      log.debug("");
      log.debug("project=" + project.getArtifact());

      if (!AndroidExtension.isAndroidPackaging(project.getPackaging())) {
        continue; // do not modify classpath if not an android project.
      }

      final UnpackedLibHelper helper = new UnpackedLibHelper(artifactResolverHelper, project, log);

      final Set<Artifact> artifacts;

      // If there is an extension ClassRealm loaded for this project then use that
      // as the ContextClassLoader so that Wagon extensions can be used to resolves dependencies.
      final ClassLoader projectClassLoader =
          (project.getClassRealm() != null)
              ? project.getClassRealm()
              : Thread.currentThread().getContextClassLoader();

      final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
      try {
        Thread.currentThread().setContextClassLoader(projectClassLoader);
        artifacts = dependencyResolver.getProjectDependenciesFor(project, session);
      } catch (DependencyGraphBuilderException e) {
        // Nothing to do. The resolution failure will be displayed by the standard resolution
        // mechanism.
        continue;
      } finally {
        Thread.currentThread().setContextClassLoader(originalClassLoader);
      }

      log.debug("projects deps: : " + artifacts);
      for (Artifact artifact : artifacts) {
        final String type = artifact.getType();
        if (type.equals(AndroidExtension.AAR)) {
          // An AAR lib contains a classes jar that needs to be added to the classpath.
          // Create a placeholder classes.jar and add it to the compile classpath.
          // It will replaced with the real classes.jar by GenerateSourcesMojo.
          addClassesToClasspath(helper, project, artifact);

          if (includeLibsJarsForAar) {
            // Add jar files in 'libs' into classpath.
            addLibsJarsToClassPath(helper, project, artifact);
          }
        } else if (type.equals(AndroidExtension.APK)) {
          // The only time that an APK will likely be a dependency is when this an an APK test
          // project.
          // So add a placeholder (we cannot resolve the actual dep pre build) to the compile
          // classpath.
          // The placeholder will be replaced with the real APK jar later.
          addClassesToClasspath(helper, project, artifact);
        } else if (type.equals(AndroidExtension.APKLIB) && includeLibsJarsForApklib) {
          // Add jar files in 'libs' into classpath.
          addLibsJarsToClassPath(helper, project, artifact);
        }
      }
    }

    if (addedJarFromLibs) {
      log.warn(
          "Transitive dependencies should really be provided by Maven dependency management.\n"
              + "          We suggest you to ask the above providers to package their component properly.\n"
              + "          Things may break at compile and/or runtime due to multiple copies of incompatible libraries.");
    }
    log.debug("");
    log.debug("ClasspathModifierLifecycleParticipant#afterProjectsRead - finish");
  }