本文整理汇总了Java中org.jboss.forge.addon.projects.facets.MetadataFacet类的典型用法代码示例。如果您正苦于以下问题:Java MetadataFacet类的具体用法?Java MetadataFacet怎么用?Java MetadataFacet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetadataFacet类属于org.jboss.forge.addon.projects.facets包,在下文中一共展示了MetadataFacet类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: modifyJavaClass
import org.jboss.forge.addon.projects.facets.MetadataFacet; //导入依赖的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
示例2: addDependencies
import org.jboss.forge.addon.projects.facets.MetadataFacet; //导入依赖的package包/类
protected void addDependencies() {
Parent p = new Parent();
p.setGroupId(GRIFFON_GROUP_ID);
p.setArtifactId(GRIFFON_MASTERPOM_ARTIFACT_ID);
p.setVersion("1.0.0");
MavenFacet mavenFacet = getFaceted().getFacet(MavenFacet.class);
Model model = mavenFacet.getModel();
model.setParent(p);
mavenFacet.setModel(model);
DependencyFacet facet = getFaceted().getFacet(DependencyFacet.class);
facet.addRepository("jcenter","http://jcenter.bintray.com");
facet.addRepository("griffon-plugins","http://dl.bintray.com/griffon/griffon-plugins");
MetadataFacet mdfacet = getFaceted().getFacet(MetadataFacet.class);
mdfacet.setDirectProperty("griffon.version","2.2.0");
mdfacet.setDirectProperty("application.main.class",mdfacet.getProjectGroupName()+".Launcher");
mdfacet.setDirectProperty("maven.compiler.source","1.8");
mdfacet.setDirectProperty("maven.compiler.target","1.8");
builder = DependencyBuilder.create();
addDependency(LOG4J);
addDependency(SLF4J_LOG4J12);
addDependency(SPOCK_CORE);
addDependency(JUNIT);
}
开发者ID:jughyd,项目名称:griffon-forge-addon,代码行数:27,代码来源:AbstractGriffonFacet.java
示例3: getRequiredFacets
import org.jboss.forge.addon.projects.facets.MetadataFacet; //导入依赖的package包/类
@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;
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:13,代码来源:FunktionProjectType.java
示例4: execute
import org.jboss.forge.addon.projects.facets.MetadataFacet; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
UIContext uiContext = context.getUIContext();
Project project = (Project) uiContext.getAttributeMap().get(Project.class);
Archetype chosenArchetype = archetype.getValue();
String coordinate = chosenArchetype.getGroupId() + ":" + chosenArchetype.getArtifactId() + ":"
+ chosenArchetype.getVersion();
DependencyQueryBuilder depQuery = DependencyQueryBuilder.create(coordinate);
String repository = chosenArchetype.getRepository();
if (!Strings.isNullOrEmpty(repository)) {
if (repository.endsWith(".xml")) {
int lastRepositoryPath = repository.lastIndexOf('/');
if (lastRepositoryPath > -1)
repository = repository.substring(0, lastRepositoryPath);
}
if (!repository.isEmpty()) {
depQuery.setRepositories(new DependencyRepository("archetype", repository));
}
}
Dependency resolvedArtifact = dependencyResolver.resolveArtifact(depQuery);
FileResource<?> artifact = resolvedArtifact.getArtifact();
MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);
File fileRoot = project.getRoot().reify(DirectoryResource.class).getUnderlyingResourceObject();
ArchetypeHelper archetypeHelper = new ArchetypeHelper(artifact.getResourceInputStream(), fileRoot,
metadataFacet.getProjectGroupName(), metadataFacet.getProjectName(), metadataFacet.getProjectVersion());
JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
archetypeHelper.setPackageName(facet.getBasePackage());
archetypeHelper.execute();
return Results.success();
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:31,代码来源:FunktionArchetypeSelectionWizardStep.java
示例5: getRequiredFacets
import org.jboss.forge.addon.projects.facets.MetadataFacet; //导入依赖的package包/类
@Override
public Iterable<Class<? extends ProjectFacet>> getRequiredFacets() {
List<Class<? extends ProjectFacet>> result = new ArrayList<Class<? extends ProjectFacet>>(6);
result.add(MetadataFacet.class);
result.add(PackagingFacet.class);
result.add(DependencyFacet.class);
result.add(ResourcesFacet.class);
result.add(JavaSourceFacet.class);
result.add(JavaCompilerFacet.class);
return result;
}
开发者ID:fabric8io,项目名称:django,代码行数:12,代码来源:ConnectorProjectType.java
示例6: install
import org.jboss.forge.addon.projects.facets.MetadataFacet; //导入依赖的package包/类
@Override
public boolean install()
{
DependencyFacet dependencyFacet = getFaceted().getFacet(DependencyFacet.class);
MetadataFacet metadataFacet = getFaceted().getFacet(MetadataFacet.class);
if (!isInstalled())
{
createMigrationDirectory();
dependencyFacet.addDirectManagedDependency(createLiquibaseDependency());
metadataFacet
.setDirectProperty(Constants.LIQUIBASE_VERSION_PROPERTY_NAME, Constants.LIQUIBASE_DEFAULT_VERSION);
}
return true;
}
开发者ID:forge,项目名称:db-migration-addon,代码行数:16,代码来源:DatabaseMigrationFacetImpl.java
示例7: setPropertiesFile
import org.jboss.forge.addon.projects.facets.MetadataFacet; //导入依赖的package包/类
public void setPropertiesFile(ConnectionProfile connection)
{
String liquibaseVersion = getFaceted().getFacet(MetadataFacet.class).getDirectProperty(
Constants.LIQUIBASE_VERSION_PROPERTY_NAME);
ConnectionPropertiesBuilder pBuilder = ConnectionPropertiesBuilder.create();
pBuilder.setConnection(connection).setLiquibaseVersion(liquibaseVersion);
ResourcesFacet projectResourcesFacet = getFaceted().getFacet(ResourcesFacet.class);
DirectoryResource migrationDir = projectResourcesFacet.getResourceDirectory().getChildDirectory(
Constants.DEFAULT_MIGRATION_DIRECTORY);
FileResource<?> propertiesFile = migrationDir.getChild(Constants.PROPERTIES_FILE).reify(
FileResource.class);
propertiesFile.setContents(pBuilder.toString());
}
开发者ID:forge,项目名称:db-migration-addon,代码行数:16,代码来源:DatabaseMigrationFacetImpl.java
示例8: testAddLiquibaseSetup
import org.jboss.forge.addon.projects.facets.MetadataFacet; //导入依赖的package包/类
@Test
public void testAddLiquibaseSetup() throws Exception
{
try (CommandController commandController = testHarness.createCommandController(AddLiquibaseCommand.class,
project.getRoot()))
{
commandController.initialize();
commandController.setValueFor("liquibaseVersion", Constants.LIQUIBASE_DEFAULT_VERSION);
Assert.assertTrue(commandController.isValid());
Result result = commandController.execute();
Assert.assertTrue(project.getFacet(ResourcesFacet.class).getResourceDirectory()
.getChildDirectory(Constants.MIGRATION_DIRECTORY_NAME).exists());
DependencyFacet depFacet = project.getFacet(DependencyFacet.class);
Assert.assertTrue(depFacet.hasDirectManagedDependency(DependencyBuilder.create()
.setGroupId("org.liquibase")
.setArtifactId("liquibase-maven-plugin")
.setVersion(Constants.LIQUIBASE_DEFAULT_VERSION)
.setPackaging("pom")
.setScopeType("provided")));
MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);
Assert.assertEquals(metadataFacet.getDirectProperty(Constants.LIQUIBASE_VERSION_PROPERTY_NAME),
Constants.LIQUIBASE_DEFAULT_VERSION);
}
}
开发者ID:forge,项目名称:db-migration-addon,代码行数:29,代码来源:AddLiquibaseCommandTest.java
示例9: getRequiredFacets
import org.jboss.forge.addon.projects.facets.MetadataFacet; //导入依赖的package包/类
/**
* 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;
}
开发者ID:forge,项目名称:wildfly-swarm-addon,代码行数:17,代码来源:WildFlySwarmProjectType.java
示例10: execute
import org.jboss.forge.addon.projects.facets.MetadataFacet; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
UIContext uiContext = context.getUIContext();
Project project = (Project) uiContext.getAttributeMap().get(Project.class);
if (project == null) {
project = getSelectedProject(context.getUIContext());
}
MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class);
String projectName = metadataFacet.getProjectName();
String groupId = metadataFacet.getProjectGroupName();
String version = metadataFacet.getProjectVersion();
File folder = project.getRoot().reify(DirectoryResource.class).getUnderlyingResourceObject();
Map<String, SpringBootDependencyDTO> selectedDTOs = new HashMap<>();
int[] selected = dependencies.getSelectedIndexes();
CollectionStringBuffer csbSpringBoot = new CollectionStringBuffer(",");
CollectionStringBuffer csbFabric8 = new CollectionStringBuffer(",");
for (int val : selected) {
SpringBootDependencyDTO dto = choices.get(val);
if (isFabric8Dependency(dto.getId())) {
csbFabric8.append(dto.getId());
} else {
csbSpringBoot.append(dto.getId());
}
selectedDTOs.put(dto.getId(), dto);
}
String springBootDeps = csbSpringBoot.toString();
String fabric8Deps = csbFabric8.toString();
// boot version need the RELEASE suffix
String bootVersion = springBootVersion.getValue() + ".RELEASE";
String url = String.format("%s?bootVersion=%s&groupId=%s&artifactId=%s&version=%s&packageName=%s&dependencies=%s",
STARTER_URL, bootVersion, groupId, projectName, version, groupId, springBootDeps);
LOG.info("About to query url: " + url);
// use http client to call start.spring.io that creates the project
OkHttpClient client = createOkHttpClient();
Request request = new Request.Builder().url(url).build();
Response response = client.newCall(request).execute();
InputStream is = response.body().byteStream();
// some archetypes might not use maven or use the maven source layout so lets remove
// the pom.xml and src folder if its already been pre-created
// as these will be created if necessary via the archetype jar's contents
File pom = new File(folder, "pom.xml");
if (pom.isFile() && pom.exists()) {
pom.delete();
}
File src = new File(folder, "src");
if (src.isDirectory() && src.exists()) {
recursiveDelete(src);
}
File name = new File(folder, projectName + ".zip");
if (name.exists()) {
name.delete();
}
FileOutputStream fos = new FileOutputStream(name, false);
copyAndCloseInput(is, fos);
close(fos);
// unzip the download from spring starter
unzip(name, folder);
LOG.info("Unzipped file to folder: {}", folder.getAbsolutePath());
// and delete the zip file
name.delete();
if (!Strings.isEmpty(fabric8Deps)) {
addFabric8DependenciesToPom(project, fabric8Deps, selectedDTOs);
}
// are there any fabric8 dependencies to add afterwards?
return Results.success("Created new Spring Boot project in directory: " + folder.getName());
}
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:82,代码来源:SpringBootNewProjectCommand.java
示例11: getInstalledVersion
import org.jboss.forge.addon.projects.facets.MetadataFacet; //导入依赖的package包/类
public String getInstalledVersion()
{
MetadataFacet metadataFacet = getFaceted().getFacet(MetadataFacet.class);
return metadataFacet.getDirectProperty(Constants.LIQUIBASE_VERSION_PROPERTY_NAME);
}
开发者ID:forge,项目名称:db-migration-addon,代码行数:6,代码来源:DatabaseMigrationFacetImpl.java
注:本文中的org.jboss.forge.addon.projects.facets.MetadataFacet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论