static void normalizePaths(Collection<Artifact> arts) { if (arts != null) { for (Artifact aa : arts) { normalizePath(aa); } } }
/** * normalize all File references in the object tree. * @param project * @since 2.36 */ public static void normalizePaths(MavenProject project) { if (project == null) { return; } File f = project.getFile(); if (f != null) { project.setFile(FileUtil.normalizeFile(f)); } normalizePath(project.getArtifact()); normalizePaths(project.getAttachedArtifacts()); f = project.getParentFile(); if (f != null) { project.setParentFile(FileUtil.normalizeFile(f)); } normalizePath(project.getParentArtifact()); normalizePaths(project.getArtifacts()); normalizePaths(project.getDependencyArtifacts()); normalizePaths(project.getExtensionArtifacts()); normalizePaths(project.getPluginArtifacts()); normalizePath(project.getModel()); normalizePath(project.getOriginalModel()); }
/** * Creates a list of POM models in an inheritance lineage. * Each resulting model is "raw", so contains no interpolation or inheritance. * In particular beware that groupId and/or version may be null if inherited from a parent; use {@link Model#getParent} to resolve. * Internally calls <code>executeModelBuilder</code> so if you need to call both just use the execute method. * @param pom a POM to inspect * @param embedder an embedder to use * @return a list of models, starting with the specified POM, going through any parents, finishing with the Maven superpom (with a null artifactId) * @throws ModelBuildingException if the POM or parents could not even be parsed; warnings are not reported */ public List<Model> createModelLineage(File pom) throws ModelBuildingException { ModelBuildingResult res = executeModelBuilder(pom); List<Model> toRet = new ArrayList<Model>(); for (String id : res.getModelIds()) { Model m = res.getRawModel(id); normalizePath(m); toRet.add(m); } // for (ModelProblem p : res.getProblems()) { // System.out.println("problem=" + p); // if (p.getException() != null) { // p.getException().printStackTrace(); // } // } return toRet; } /**
/** * * @param sources * @param remoteRepositories - these instances need to be properly mirrored and proxied. Either by creating via EmbedderFactory.createRemoteRepository() * or by using instances from MavenProject * @param localRepository * @throws ArtifactResolutionException * @throws ArtifactNotFoundException */ public void resolve(Artifact sources, List<ArtifactRepository> remoteRepositories, ArtifactRepository localRepository) throws ArtifactResolutionException, ArtifactNotFoundException { setUpLegacySupport(); ArtifactResolutionRequest req = new ArtifactResolutionRequest(); req.setLocalRepository(localRepository); req.setRemoteRepositories(remoteRepositories); req.setArtifact(sources); req.setOffline(isOffline()); ArtifactResolutionResult result = repositorySystem.resolve(req); normalizePath(sources); // XXX check result for exceptions and throw them now? for (Exception ex : result.getExceptions()) { LOG.log(Level.FINE, null, ex); } }