org.jboss.forge.addon.projects.facets.DependencyFacet Java Examples

The following examples show how to use org.jboss.forge.addon.projects.facets.DependencyFacet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CamelProjectHelper.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
public static boolean hasDependency(Project project, String groupId, String artifactId, String version) {
    List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
    for (Dependency d : dependencies) {
        boolean match = d.getCoordinate().getGroupId().equals(groupId);
        if (match && artifactId != null) {
            match = d.getCoordinate().getArtifactId().equals(artifactId);
        }
        if (match && version != null) {
            match = d.getCoordinate().getVersion().equals(version);
        }
        if (match) {
            return match;
        }
    }
    return false;
}
 
Example #2
Source File: CamelProjectHelper.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
public static boolean hasManagedDependency(Project project, String groupId, String artifactId, String version) {
    List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getManagedDependencies();
    for (Dependency d : dependencies) {
        boolean match = d.getCoordinate().getGroupId().equals(groupId);
        if (match && artifactId != null) {
            match = d.getCoordinate().getArtifactId().equals(artifactId);
        }
        if (match && version != null) {
            match = d.getCoordinate().getVersion().equals(version);
        }
        if (match) {
            return match;
        }
    }
    return false;
}
 
Example #3
Source File: CreateTestClassCommand.java    From thorntail-addon with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Result execute(UIExecutionContext context) throws Exception {
    Project project = getSelectedProject(context);

    final DependencyFacet dependencyFacet = project.getFacet(DependencyFacet.class);
    if (!isArquillianWildflySwarmDependencyInstalled(dependencyFacet)) {
        installArquillianWildflySwarmDependency(dependencyFacet);
    }

    JavaClassSource test = Roaster.create(JavaClassSource.class)
            .setPackage(targetPackage.getValue())
            .setName(named.getValue());

    addArquillianRunner(test);
    addDefaultDeploymentAnnotation(test, project);
    addArquillianResourceEnricher(test);
    addTestMethod(test);

    JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
    facet.saveTestJavaSource(test);

    return Results.success(String.format("Test Class %s.%s was created", targetPackage.getValue(), named.getValue()));
}
 
Example #4
Source File: FunktionProjectType.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<Class<? extends ProjectFacet>> getRequiredFacets() {
    List<Class<? extends ProjectFacet>> result = new ArrayList<Class<? extends ProjectFacet>>(7);
    result.add(MetadataFacet.class);
    result.add(PackagingFacet.class);
    result.add(DependencyFacet.class);
    result.add(ResourcesFacet.class);
    result.add(WebResourcesFacet.class);
    result.add(JavaSourceFacet.class);
    result.add(JavaCompilerFacet.class);
    return result;
}
 
Example #5
Source File: SpringBootProjectType.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<Class<? extends ProjectFacet>> getRequiredFacets() {
    List<Class<? extends ProjectFacet>> result = new ArrayList<Class<? extends ProjectFacet>>(7);
    result.add(MetadataFacet.class);
    result.add(PackagingFacet.class);
    result.add(DependencyFacet.class);
    result.add(ResourcesFacet.class);
    result.add(WebResourcesFacet.class);
    result.add(JavaSourceFacet.class);
    result.add(JavaCompilerFacet.class);
    return result;
}
 
Example #6
Source File: CamelProjectHelper.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public static Dependency findCamelArtifactDependency(Project project, String artifactId) {
    List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
    for (Dependency d : dependencies) {
        if ("org.apache.camel".equals(d.getCoordinate().getGroupId()) && artifactId.equals(d.getCoordinate().getArtifactId())) {
            return d;
        }
    }
    return null;
}
 
Example #7
Source File: CamelProjectHelper.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public static Set<Dependency> findCamelArtifacts(Project project) {
    Set<Dependency> answer = new LinkedHashSet<Dependency>();

    List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
    for (Dependency d : dependencies) {
        if ("org.apache.camel".equals(d.getCoordinate().getGroupId())) {
            answer.add(d);
        }
    }
    return answer;
}
 
Example #8
Source File: CamelProjectHelper.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public static Set<Dependency> findCustomCamelArtifacts(Project project) {
    Set<Dependency> answer = new LinkedHashSet<Dependency>();

    List<Dependency> dependencies = project.getFacet(DependencyFacet.class).getEffectiveDependencies();
    for (Dependency d : dependencies) {
        if (isCamelComponentArtifact(d)) {
            answer.add(d);
        }
    }
    return answer;
}
 
Example #9
Source File: MavenHelpers.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #10
Source File: ThorntailProjectType.java    From thorntail-addon with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Same as JavaWebProjectType
 */
@Override
public Iterable<Class<? extends ProjectFacet>> getRequiredFacets()
{
   List<Class<? extends ProjectFacet>> result = new ArrayList<Class<? extends ProjectFacet>>(7);
   result.add(MetadataFacet.class);
   result.add(PackagingFacet.class);
   result.add(DependencyFacet.class);
   result.add(ResourcesFacet.class);
   result.add(WebResourcesFacet.class);
   result.add(JavaSourceFacet.class);
   result.add(JavaCompilerFacet.class);
   return result;
}
 
Example #11
Source File: ThorntailFacet.java    From thorntail-addon with Eclipse Public License 1.0 5 votes vote down vote up
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);
      }
   }
}
 
Example #12
Source File: CreateTestClassCommand.java    From thorntail-addon with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isArquillianWildflySwarmDependencyInstalled(DependencyFacet dependencyFacet) {
    return dependencyFacet.getDependencies().stream()
            .map(dependency -> dependency.getCoordinate())
            .anyMatch(coordinate ->
                    "io.thorntail".equals(coordinate.getGroupId()) &&
                            "arquillian".equals(coordinate.getArtifactId()));
}
 
Example #13
Source File: AngularScaffoldProvider.java    From angularjs-addon with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public boolean isSetup(ScaffoldSetupContext setupContext)
{
   Project project = setupContext.getProject();
   String targetDir = setupContext.getTargetDirectory();
   targetDir = targetDir == null ? "" : targetDir;
   if (project.hasAllFacets(WebResourcesFacet.class, DependencyFacet.class, JPAFacet.class, EJBFacet.class,
            CDIFacet.class, RestFacet.class))
   {
      WebResourcesFacet web = project.getFacet(WebResourcesFacet.class);
      boolean areResourcesInstalled = web.getWebResource(targetDir + GLYPHICONS_SVG).exists()
               && web.getWebResource(targetDir + GLYPHICONS_EOT).exists()
               && web.getWebResource(targetDir + GLYPHICONS_SVG).exists()
               && web.getWebResource(targetDir + GLYPHICONS_TTF).exists()
               && web.getWebResource(targetDir + GLYPHICONS_WOFF).exists()
               && web.getWebResource(targetDir + GLYPHICONS_WOFF2).exists()
               && web.getWebResource(targetDir + FORGE_LOGO_PNG).exists()
               && web.getWebResource(targetDir + ANGULAR_RESOURCE_JS).exists()
               && web.getWebResource(targetDir + ANGULAR_ROUTE_JS).exists()
               && web.getWebResource(targetDir + ANGULAR_JS).exists()
               && web.getWebResource(targetDir + MODERNIZR_JS).exists()
               && web.getWebResource(targetDir + JQUERY_JS).exists()
               && web.getWebResource(targetDir + BOOTSTRAP_JS).exists()
               && web.getWebResource(targetDir + OFFCANVAS_JS).exists()
               && web.getWebResource(targetDir + MAIN_CSS).exists()
               && web.getWebResource(targetDir + BOOTSTRAP_CSS).exists()
               && web.getWebResource(targetDir + BOOTSTRAP_THEME_CSS).exists()
               && web.getWebResource(targetDir + LANDING_VIEW).exists();
      return areResourcesInstalled;
   }
   return false;
}
 
Example #14
Source File: ThorntailFacet.java    From thorntail-addon with Eclipse Public License 1.0 4 votes vote down vote up
private void addSwarmBOM()
{
   DependencyFacet dependencyFacet = getFaceted().getFacet(DependencyFacet.class);
   dependencyFacet.addDirectManagedDependency(BOM_DEPENDENCY);
}
 
Example #15
Source File: CreateTestClassCommand.java    From thorntail-addon with Eclipse Public License 1.0 4 votes vote down vote up
private void installArquillianWildflySwarmDependency(DependencyFacet dependencyFacet) {
    dependencyFacet.addDirectDependency(SWARM_ARQUILLIAN_DEPENDENCY);
}