当前位置: 首页>>代码示例>>Java>>正文


Java Project.getFacet方法代码示例

本文整理汇总了Java中org.jboss.forge.addon.projects.Project.getFacet方法的典型用法代码示例。如果您正苦于以下问题:Java Project.getFacet方法的具体用法?Java Project.getFacet怎么用?Java Project.getFacet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.forge.addon.projects.Project的用法示例。


在下文中一共展示了Project.getFacet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCRUDRepository

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
private void createCRUDRepository(JavaClassSource entitySource, Project project) {
   // build interface declaration
   final String name = entitySource.getName();
   final String idFieldType = entitySource.getFields().stream()
         .filter(field -> field.hasAnnotation(Id.class))
         .findFirst()
         .orElseThrow(IllegalArgumentException::new)
         .getType()
         .getSimpleName();
   final String repoInterfaceDeclaration = "public interface " + name
            + "Repository extends PagingAndSortingRepository<"
         + name + "," + idFieldType + "> {}";

   JavaInterfaceSource repoSource = Roaster.parse(JavaInterfaceSource.class, repoInterfaceDeclaration)
         .setPackage(entitySource.getPackage());
   repoSource.addImport("org.springframework.data.repository.PagingAndSortingRepository");
   Roaster.format(repoSource.toString());

   // Create Java Classes Greeting and GreetingProperties
   JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
   facet.saveJavaSource(repoSource);
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:23,代码来源:CreateSpringBootJPASupportDecorator.java

示例2: modifyJavaClass

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
public static void modifyJavaClass(Project project, String className, Optional<String> packageName,
                                   JavaClassSourceDecorator decorator) {

   final String packageLocation = packageName.orElseGet(() -> project.getFacet(MetadataFacet.class).getProjectGroupName());
   final JavaSourceFacet sourceFacet = project.getFacet(JavaSourceFacet.class);
   final DirectoryResource targetPackage = sourceFacet.getPackage(packageLocation);

   final JavaResource sbAppResource = targetPackage.getChild(className).as(JavaResource.class);
   if (sbAppResource.exists()) {
      JavaClassSource sbApp = Roaster.parse(JavaClassSource.class, sbAppResource.getResourceInputStream());

      decorator.modify(sbApp);

      sourceFacet.saveJavaSource(sbApp);
   }
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:17,代码来源:SpringBootHelper.java

示例3: asRelativeFile

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
protected String asRelativeFile(UIContext context, String currentFile) {
    Project project = getSelectedProject(context);

    JavaSourceFacet javaSourceFacet = null;
    ResourcesFacet resourcesFacet = null;
    WebResourcesFacet webResourcesFacet = null;
    if (project.hasFacet(JavaSourceFacet.class)) {
        javaSourceFacet = project.getFacet(JavaSourceFacet.class);
    }
    if (project.hasFacet(ResourcesFacet.class)) {
        resourcesFacet = project.getFacet(ResourcesFacet.class);
    }
    if (project.hasFacet(WebResourcesFacet.class)) {
        webResourcesFacet = project.getFacet(WebResourcesFacet.class);
    }
    return asRelativeFile(currentFile, javaSourceFacet, resourcesFacet, webResourcesFacet);
}
 
开发者ID:fabric8io,项目名称:django,代码行数:18,代码来源:AbstractIPaaSProjectCommand.java

示例4: setupFabricMavenPlugin

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
public static MavenPluginBuilder setupFabricMavenPlugin(Project project) {
    MavenPluginBuilder pluginBuilder;
    MavenPlugin plugin = MavenHelpers.findPlugin(project, "io.fabric8", "fabric8-maven-plugin");
    if (plugin != null) {
        // if there is an existing then leave it as-is
        LOG.info("Found existing fabric8-maven-plugin");
        pluginBuilder = null;
    } else {
        LOG.info("Adding fabric8-maven-plugin");
        // add fabric8 plugin
        pluginBuilder = MavenPluginBuilder.create()
                .setCoordinate(MavenHelpers.createCoordinate("io.fabric8", "fabric8-maven-plugin", VersionHelper.fabric8MavenPluginVersion()))
                .addExecution(ExecutionBuilder.create().setId("fmp").addGoal("resource").addGoal("helm").addGoal("build"));
    }

    if (pluginBuilder != null) {
        MavenPluginFacet pluginFacet = project.getFacet(MavenPluginFacet.class);
        pluginFacet.addPlugin(pluginBuilder);
    }
    return pluginBuilder;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:22,代码来源:Fabric8SetupStep.java

示例5: isFunktionParentPom

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
@Deprecated
public static boolean isFunktionParentPom(Project project) {
    MavenFacet mavenFacet = project.getFacet(MavenFacet.class);
    if (mavenFacet != null) {
        Model model = mavenFacet.getModel();
        if (model != null) {
            Parent parent = model.getParent();
            if (parent != null) {
                String groupId = parent.getGroupId();
                if (groupId != null && groupId.startsWith("io.fabric8.funktion")) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:18,代码来源:SetupProjectHelper.java

示例6: createCurrentLineCompleter

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
protected CurrentLineCompleter createCurrentLineCompleter(int lineNumber, String file, UIContext context) throws Exception {
    Project project = getSelectedProject(context);

    JavaSourceFacet sourceFacet = null;
    ResourcesFacet resourcesFacet = null;
    WebResourcesFacet webResourcesFacet = null;
    if (project.hasFacet(JavaSourceFacet.class)) {
        sourceFacet = project.getFacet(JavaSourceFacet.class);
    }
    if (project.hasFacet(ResourcesFacet.class)) {
        resourcesFacet = project.getFacet(ResourcesFacet.class);
    }
    if (project.hasFacet(WebResourcesFacet.class)) {
        webResourcesFacet = project.getFacet(WebResourcesFacet.class);
    }

    String relativeFile = asRelativeFile(context, file);
    return new CurrentLineCompleter(lineNumber, relativeFile, sourceFacet, resourcesFacet, webResourcesFacet);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:20,代码来源:AbstractCamelProjectCommand.java

示例7: getXmlResourceFile

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
protected FileResource getXmlResourceFile(Project project, String xmlResourceName) {
    if (xmlResourceName == null) {
        return null;
    }

    ResourcesFacet facet = null;
    WebResourcesFacet webResourcesFacet = null;
    if (project.hasFacet(ResourcesFacet.class)) {
        facet = project.getFacet(ResourcesFacet.class);
    }
    if (project.hasFacet(WebResourcesFacet.class)) {
        webResourcesFacet = project.getFacet(WebResourcesFacet.class);
    }

    FileResource file = facet != null ? facet.getResource(xmlResourceName) : null;
    if (file == null || !file.exists()) {
        file = webResourcesFacet != null ? webResourcesFacet.getWebResource(xmlResourceName) : null;
    }
    return file;
}
 
开发者ID:fabric8io,项目名称:django,代码行数:21,代码来源:AbstractIPaaSProjectCommand.java

示例8: initializeUI

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
@Override
public void initializeUI(UIBuilder builder) throws Exception {
    Project project = getSelectedProject(builder.getUIContext());
    JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);

    targetPackage.setCompleter(new PackageNameCompleter(facet));
    targetPackage.addValidator(new PackageNameValidator());
    targetPackage.getFacet(HintsFacet.class).setInputType(InputType.JAVA_PACKAGE_PICKER);
    // if there is only one package then use that as default
    Set<String> packages = new RouteBuilderCompleter(facet).getPackages();
    if (packages.size() == 1) {
        targetPackage.setDefaultValue(first(packages));
    }

    name.addValidator(new ClassNameValidator(false));
    name.getFacet(HintsFacet.class).setInputType(InputType.JAVA_CLASS_PICKER);

    builder.add(targetPackage).add(name);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:20,代码来源:CamelNewRouteBuilderCommand.java

示例9: execute

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception
{
   final Result result = original.execute(context);

   final Project project = helper.getProject(context.getUIContext());
   final DependencyFacet facet = project.getFacet(DependencyFacet.class);

   // add dependencies
   facet.addDirectDependency(SpringBootFacet.SPRING_BOOT_STARTER_WEB);
   facet.addDirectDependency(SpringBootFacet.CXF_SPRING_BOOT);
   facet.addDirectDependency(SpringBootFacet.JACKSON_JAXRS_PROVIDER);

   // remove EE dependencies
   facet.removeDependency(SpringBootFacet.JBOSS_EJB_SPEC);
   facet.removeDependency(SpringBootFacet.JBOSS_JAXRS_SPEC);
   facet.removeDependency(SpringBootFacet.JBOSS_SERVLET_SPEC);
   facet.removeManagedDependency(SpringBootFacet.JBOSS_EE_SPEC);

   // add CXF properties to application.properties
   final Properties cxfProps = new Properties();
   cxfProps.put("cxf.jaxrs.component-scan", "true");
   cxfProps.put("cxf.path", "/rest");
   SpringBootHelper.writeToApplicationProperties(project, cxfProps);

   SpringBootHelper.modifySpringBootApplication(project, sbApp -> {
      sbApp.addImport("com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider");

      final MethodSource<JavaClassSource> method = sbApp.addMethod("public JacksonJsonProvider config() {\n" +
               "\t\treturn new JacksonJsonProvider();\n" +
               "\t}");
      method.addAnnotation("org.springframework.context.annotation.Bean");

      return sbApp;
   });

   return result;
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:39,代码来源:RestGenerateFromEntitiesCommand.java

示例10: addDependency

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
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;
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:10,代码来源:SpringBootHelper.java

示例11: testOnProjectThatHasAlreadyACoreDependency

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
@Test
public void testOnProjectThatHasAlreadyACoreDependency() throws Exception {
    File root = prepareRoot("target/tests/project-with-core-dependency");
    Project project = projectFactory.createProject(resourceFactory.create(root), projectProvider);

    DependencyFacet dependencies = project.getFacet(DependencyFacet.class);
    dependencies.addDirectDependency(DependencyBuilder.create("io.vertx:vertx-core:3.1.0"));
    checkDependency(dependencies, "io.vertx", "vertx-core", "3.1.0", null);

    facetFactory.install(project, VertxMavenFacet.class);
    MavenPluginFacet plugins = project.getFacet(MavenPluginFacet.class);
    MavenFacet maven = project.getFacet(MavenFacet.class);

    // Check vertx.version
    assertThat(maven.getProperties()).contains(entry(VertxMavenFacet.VERTX_VERSION_PROPERTY, config().getVersion()));

    // Check managed dependency
    checkVertxBom(dependencies);
    assertThat(dependencies.getManagedDependencies()).hasSize(1);

    // Check dependencies
    checkDependency(dependencies, "io.vertx", "vertx-core", "3.1.0", null);
    checkDependency(dependencies, "io.vertx", "vertx-unit", null, "test");
    checkDependency(dependencies, "junit", "junit", "4.12", "test");
    assertThat(dependencies.getDependencies()).hasSize(3);

    // Check maven compiler
    hasPlugin(plugins, "maven-compiler-plugin");
    hasPlugin(plugins, "vertx-maven-plugin");
}
 
开发者ID:cescoffier,项目名称:vertx-forge-addon,代码行数:31,代码来源:VertxFacetTest.java

示例12: getBasePackageName

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
protected String getBasePackageName(Project project) {
    if (project != null && project.hasFacet(JavaSourceFacet.class)) {
        JavaSourceFacet java = project.getFacet(JavaSourceFacet.class);
        String base = java.getBasePackage();
        return base;
    }
    return null;
}
 
开发者ID:fabric8io,项目名称:django,代码行数:9,代码来源:ConnectorSelectComponentStep.java

示例13: getMavenFacet

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
public MavenFacet getMavenFacet(UIContextProvider builder) {
    final Project project = getSelectedProject(builder);
    if (project != null) {
        MavenFacet maven = project.getFacet(MavenFacet.class);
        return maven;
    }
    return null;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:9,代码来源:AbstractDevOpsCommand.java

示例14: getOrAddDependency

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
public static Dependency getOrAddDependency(Project project, String groupId, String artifactId,
                                            String version, String classifier, String scope) {
  DependencyFacet dependencies = project.getFacet(DependencyFacet.class);
  Optional<Dependency> found = dependencies.getEffectiveDependencies().stream().filter(dep ->
      dep.getCoordinate().getGroupId().equalsIgnoreCase(groupId)
          && dep.getCoordinate().getArtifactId().equalsIgnoreCase(artifactId)
          && (version == null || version.equalsIgnoreCase(dep.getCoordinate().getVersion()))
          && Strings.isNullOrEmpty(dep.getCoordinate().getClassifier())
          && (Strings.isNullOrEmpty(dep.getCoordinate().getPackaging()) || dep.getCoordinate().getPackaging()
          .equalsIgnoreCase("jar"))
  ).findAny();
  if (found.isPresent()) {
    return found.get();
  }

  DependencyBuilder dependency = DependencyBuilder.create().setGroupId(groupId).setArtifactId(artifactId);
  if (version != null) {
    dependency.setVersion(version);
  }
  if (scope != null) {
    dependency.setScopeType(scope);
  }
  if (classifier != null  && ! classifier.isEmpty()) {
    dependency.setClassifier(classifier);
  }

  dependencies.addDirectDependency(dependency);

  return dependency;
}
 
开发者ID:cescoffier,项目名称:vertx-forge-addon,代码行数:31,代码来源:ForgeUtils.java

示例15: getProjectClassLoader

import org.jboss.forge.addon.projects.Project; //导入方法依赖的package包/类
public static URLClassLoader getProjectClassLoader(Project project) {
    if (project != null) {
        ClassLoaderFacet classLoaderFacet = project.getFacet(ClassLoaderFacet.class);
        if (classLoaderFacet != null) {
            return classLoaderFacet.getClassLoader();
        }
    }
    return null;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:10,代码来源:JavaHelper.java


注:本文中的org.jboss.forge.addon.projects.Project.getFacet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。