Refine search
private Collection<DependencyBuilder> createDependencies() { final Collection<DependencyBuilder> dependencies = new ArrayList<DependencyBuilder>(); dependencies.add(DependencyBuilder.create(DependencyArtifact.ErraiBom.toString()) .setVersion(Property.ErraiVersion.invoke()).setScopeType("import").setPackaging("pom")); final String erraiVersion = getProject().getFacet(ProjectConfig.class).getProjectProperty(ERRAI_VERSION, String.class); if (erraiVersion.startsWith("3.0")) { dependencies.add(DependencyBuilder.create(DependencyArtifact.ErraiVersionMaster.toString()) .setVersion(Property.ErraiVersion.invoke()).setScopeType("import").setPackaging("pom")); dependencies.add(DependencyBuilder.create(DependencyArtifact.ErraiParent.toString()) .setVersion(Property.ErraiVersion.invoke()).setScopeType("import").setPackaging("pom")); } return dependencies; }
@Override public Dependency toDependency(AddonId addon) { String[] mavenCoords = addon.getName().split(":"); Dependency dependency = DependencyBuilder.create().setGroupId(mavenCoords[0]) .setArtifactId(mavenCoords[1]) .setVersion(addon.getVersion().toString()).setClassifier(FORGE_ADDON_CLASSIFIER); return dependency; }
@Override public boolean install() { final DependencyFacet depFacet = getProject().getFacet(DependencyFacet.class); final VersionFacet versionFacet = getProject().getFacet(VersionFacet.class); for (final DependencyBuilder dep : createDependencies()) { if (dep.getCoordinate().getVersion() == null || dep.getCoordinate().getVersion().equals("")) { dep.setVersion(versionFacet.resolveVersion(dep.getGroupId(), dep.getCoordinate().getArtifactId())); } if (!depFacet.hasDirectManagedDependency(dep)) { depFacet.addDirectManagedDependency(dep); } } return true; }
@Override protected DependencyBuilder buildFrameworkDependency() { return DependencyBuilder.create() .setGroupId(TEST_NG_GROUP_ID) .setArtifactId(TEST_NG_ARTIFACT_ID) .setScopeType(TEST_NG_SCOPE); } }
private void addVertxBom() { DependencyBuilder dependency = DependencyBuilder.create() .setGroupId("io.vertx") .setArtifactId("vertx-dependencies") .setVersion("${" + VERTX_VERSION_PROPERTY + "}") .setScopeType("import") .setPackaging("pom"); DependencyFacet facet = getDependencyFacet(); facet.addManagedDependency(dependency); }
private Dependency getUnversioned(Dependency dependency) { return DependencyBuilder.create(dependency).setVersion(null).setOptional(dependency.isOptional()); }
@Override public Dependency resolveProperties(final Dependency dependency) { MavenFacet mvn = getFaceted().getFacet(MavenFacet.class); DependencyBuilder builder = DependencyBuilder.create(dependency); builder.setGroupId(mvn.resolveProperties(dependency.getCoordinate().getGroupId())); builder.setArtifactId(mvn.resolveProperties(dependency.getCoordinate().getArtifactId())); builder.setVersion(mvn.resolveProperties(dependency.getCoordinate().getVersion())); builder.setClassifier(mvn.resolveProperties(dependency.getCoordinate().getClassifier())); builder.setPackaging(mvn.resolveProperties(dependency.getCoordinate().getPackaging())); builder.setScopeType(mvn.resolveProperties(dependency.getScopeType())); return builder; }
/** * Returns true if the dependency was added or false if its already there */ public static boolean ensureMavenDependencyAdded(Project project, DependencyInstaller dependencyInstaller, String groupId, String artifactId, String scope) { List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies(); for (Dependency d : dependencies) { if (groupId.equals(d.getCoordinate().getGroupId()) && artifactId.equals(d.getCoordinate().getArtifactId())) { getLOG().debug("Project already includes: " + groupId + ":" + artifactId + " for version: " + d.getCoordinate().getVersion()); return false; } } DependencyBuilder component = DependencyBuilder.create(). setGroupId(groupId). setArtifactId(artifactId); if (scope != null) { component.setScopeType(scope); } String version = MavenHelpers.getVersion(groupId, artifactId); if (Strings.isNotBlank(version)) { component = component.setVersion(version); getLOG().debug("Adding pom.xml dependency: " + groupId + ":" + artifactId + " version: " + version + " scope: " + scope); } else { getLOG().debug("No version could be found for: " + groupId + ":" + artifactId); } dependencyInstaller.install(project, component); return true; }
final DependencyFacet deps = project.getFacet(DependencyFacet.class); for (String gav : arguments.getValue()) DependencyBuilder dep = DependencyBuilder.create(gav); Dependency existingDep = deps.getEffectiveManagedDependency(DependencyBuilder.create(dep).setVersion(null)); if (existingDep != null) "Dependency [%s:%s] is currently managed. " + "Reference the existing managed dependency [%s:%s:%s]?", dep.getCoordinate().getArtifactId(), dep.getCoordinate().getGroupId(), existingDep.getCoordinate().getGroupId(), existingDep.getCoordinate().getArtifactId(), existingDep.getCoordinate().getVersion()))) dep = DependencyBuilder.create(existingDep).setScopeType(dep.getScopeType());
final DependencyFacet deps = project.getFacet(DependencyFacet.class); Dependency existingDep = deps.getEffectiveManagedDependency(DependencyBuilder.create(dependency) .setVersion( null)); if (existingDep != null) existingDep.getCoordinate().getGroupId(), existingDep.getCoordinate().getArtifactId(), existingDep.getCoordinate().getVersion())))
public static Dependency convertToDependency(ResourceFactory factory, DependencyNode node) { org.eclipse.aether.graph.Dependency artifactDependency = node.getDependency(); Artifact artifact = artifactDependency.getArtifact(); File file = artifact.getFile(); @SuppressWarnings("unchecked") FileResource<?> artifactResource = factory.create(FileResource.class, file); Dependency d = DependencyBuilder.create().setArtifactId(artifact.getArtifactId()) .setGroupId(artifact.getGroupId()).setVersion(artifact.getBaseVersion()) .setPackaging(artifact.getExtension()).setArtifact(artifactResource) .setOptional(artifactDependency.isOptional()) .setClassifier(artifact.getClassifier()) .setScopeType(artifactDependency.getScope()); return d; }
project.getFacet(PackagingFacet.class).setPackagingType("pom"); Dependency spiProjectDependency = DependencyBuilder.create( spiProject.getFacet(MetadataFacet.class).getOutputDependency()) .setClassifier(FORGE_ADDON_CLASSIFIER); Dependency addonProjectDependency = DependencyBuilder.create( addonProject.getFacet(MetadataFacet.class).getOutputDependency()) .setClassifier(FORGE_ADDON_CLASSIFIER); DependencyBuilder.create(addonProjectDependency).setVersion("${project.version}")); dependencyInstaller.installManaged(project, DependencyBuilder.create(apiProjectDependency).setVersion("${project.version}")); dependencyInstaller.installManaged(project, DependencyBuilder.create(implProjectDependency).setVersion("${project.version}")); dependencyInstaller.installManaged(project, DependencyBuilder.create(spiProjectDependency).setVersion("${project.version}")); dependencyInstaller.install(addonProject, DependencyBuilder.create(apiProjectDependency)); dependencyInstaller.install(addonProject, DependencyBuilder.create(implProjectDependency) .setOptional(true) .setScopeType("runtime")); dependencyInstaller.install(addonProject, DependencyBuilder.create(spiProjectDependency)); dependencyInstaller.install(implProject, DependencyBuilder.create(apiProjectDependency).setScopeType("provided")); dependencyInstaller.install(implProject, DependencyBuilder.create(spiProjectDependency).setScopeType("provided")); dependencyInstaller.install(apiProject, DependencyBuilder.create(spiProjectDependency).setScopeType("provided"));
private void addProcessorPlugin(MetaModelProvider provider) MavenPluginFacet facet = getFaceted().getFacet(MavenPluginFacet.class); CoordinateBuilder processorDependency = createProcessorCoordinate(); if (facet.hasPlugin(processorDependency)) if (Strings.isNullOrEmpty(aptDependency.getVersion())) .setCoordinate(versioned) .addExecution(execution) .addPluginDependency(DependencyBuilder.create().setCoordinate(aptDependency)); facet.addPlugin(processorPlugin); getFaceted().getFacet(DependencyFacet.class).addDirectDependency( DependencyBuilder.create().setCoordinate(aptDependency).setScopeType("provided"));
public void installFractions(Iterable<FractionDescriptor> selectedFractions) { DependencyFacet facet = getFaceted().getFacet(DependencyFacet.class); addSwarmBOM(); for (FractionDescriptor descriptor : selectedFractions) { Dependency dependency = DependencyBuilder.create() .setGroupId(descriptor.getGroupId()) .setArtifactId(descriptor.getArtifactId()); if (!facet.hasEffectiveDependency(dependency)) { facet.addDirectDependency(dependency); } } }
@Override public Dependency resolveArtifact(DependencyQuery query) { RepositorySystem system = container.getRepositorySystem(); Settings settings = container.getSettings(); List<RemoteRepository> remoteRepos = MavenConvertUtils.convertToMavenRepos(query.getDependencyRepositories(), settings); remoteRepos.addAll(MavenRepositories.getRemoteRepositories(container, settings)); DefaultRepositorySystemSession session = container.setupRepoSession(system, settings); Artifact queryArtifact = MavenConvertUtils.coordinateToMavenArtifact(query.getCoordinate()); ArtifactRequest request = new ArtifactRequest(queryArtifact, remoteRepos, null); try { ArtifactResult resolvedArtifact = system.resolveArtifact(session, request); Artifact artifact = resolvedArtifact.getArtifact(); @SuppressWarnings("unchecked") FileResource<?> artifactResource = getResourceFactory().create(FileResource.class, artifact.getFile()); return DependencyBuilder.create() .setArtifact(artifactResource) .setGroupId(artifact.getGroupId()) .setArtifactId(artifact.getArtifactId()) .setClassifier(artifact.getClassifier()) .setPackaging(artifact.getExtension()) .setVersion(artifact.getBaseVersion()); } catch (ArtifactResolutionException e) { throw new MavenOperationException(e); } }
DependencyBuilder dependencyBuilder = new DependencyBuilder(); if (split.length > 0) dependencyBuilder.setGroupId(split[0].trim()); dependencyBuilder.setArtifactId(split[1].trim()); dependencyBuilder.setVersion(split[2].trim()); dependencyBuilder.setScopeType(trimmed); dependencyBuilder.setPackaging(trimmed);
@Override public boolean install() { final DependencyFacet depFacet = getProject().getFacet(DependencyFacet.class); final MavenFacet coreFacet = getProject().getFacet(MavenFacet.class); final VersionFacet versionFacet = getProject().getFacet(VersionFacet.class); final org.jboss.forge.addon.dependencies.Dependency existing = depFacet.getEffectiveDependency(dep); if (!versionFacet.isManaged(dep)) dep.setVersion(existing.getCoordinate().getVersion()); dep.setScopeType("provided"); if (!blacklistProfileDependencies.containsKey(profileId)) blacklistProfileDependencies.put(profileId, new ArrayList<DependencyBuilder>());
@Override public Dependency install(final Project project, final Dependency request) DependencyFacet deps = project.getFacet(DependencyFacet.class); final Dependency dependency = deps.resolveProperties(request); if (!Strings.isNullOrEmpty(existing.getCoordinate().getVersion()) && (existing.getCoordinate().getVersion().equals(dependency.getCoordinate().getVersion()) || Strings.isNullOrEmpty(dependency.getCoordinate().getVersion()))) toInstall = DependencyBuilder.create(dependency).setVersion( versions.get(versions.size() - 1).getVersion()); else
private String getHighestStableVersion(String groupId, String artifactId) { final Dependency dep = DependencyBuilder.create(groupId + ":" + artifactId); final DependencyFacet depFacet = getFaceted().getFacet(DependencyFacet.class); final List<Coordinate> availVersions = depFacet.resolveAvailableVersions(dep); String maxVersion = null; for (final Coordinate versionCoord : availVersions) { // FIXME needs a more reliable way of comparing versions if (!versionCoord.isSnapshot() && (maxVersion == null || versionCoord.getVersion().compareTo(maxVersion) > 0)) { maxVersion = versionCoord.getVersion(); } } return maxVersion; }
public static DependencyBuilder addDependency(Project project, Dependency dependency) { final DependencyFacet dependencyFacet = project.getFacet(DependencyFacet.class); final DependencyBuilder builder = dependency instanceof DependencyBuilder ? (DependencyBuilder) dependency : DependencyBuilder.create(dependency); dependencyFacet.addDirectDependency(builder); return builder; }