本文整理汇总了Java中org.jboss.forge.addon.projects.Project类的典型用法代码示例。如果您正苦于以下问题:Java Project类的具体用法?Java Project怎么用?Java Project使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Project类属于org.jboss.forge.addon.projects包,在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
final UIContext uiContext = context.getUIContext();
final Project project = helper.getProject(uiContext);
final Map<Object, Object> attributeMap = uiContext.getAttributeMap();
final JPADataSource dataSource = (JPADataSource) attributeMap.get(JPADataSource.class);
persistenceOperations.setup(SpringBootJPAFacet.PERSISTENCE_UNIT_NAME, project, dataSource, false);
// if we're using H2, Derby or HSQL embedded databases, we need to remove any previously set data
// source properties
if (!SpringBootPersistenceContainer.isNotEmbeddedDB(dataSource.getDatabase())) {
SpringBootHelper.removeSpringDataPropertiesFromApplication(project);
}
return null;
}
示例2: 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);
}
示例3: execute
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
@Override
public Result execute(final UIExecutionContext context) throws Exception
{
final UIContext uiContext = context.getUIContext();
applyUIValues(uiContext);
// add driver dependency
final Project project = helper.getProject(uiContext);
final DatabaseType database = dbType.getValue();
final Coordinate driverCoordinate = database.getDriverCoordinate();
SpringBootHelper.addDependency(project, driverCoordinate.getGroupId(), driverCoordinate.getArtifactId())
.setScopeType("runtime");
SpringBootHelper.addSpringBootDependency(project, SpringBootFacet.SPRING_BOOT_STARTER_DATA_JPA_ARTIFACT)
.setScopeType("runtime");
return Results.success("Spring Boot JPA successfully set up!");
}
示例4: applyUIValues
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
private JPADataSource applyUIValues(final UIContext context)
{
Map<Object, Object> attributeMap = context.getAttributeMap();
final Project project = helper.getProject(context);
helper.installJPAFacet(project);
final SpringBootPersistenceContainer container = new SpringBootPersistenceContainer();
attributeMap.put(PersistenceContainer.class, container);
final PersistenceProvider provider = jpaProvider.getValue();
attributeMap.put(PersistenceProvider.class, provider);
final DatabaseType database = dbType.getValue();
attributeMap.put(DatabaseType.class, database);
final JPADataSource dataSource = new JPADataSource();
dataSource.setDatabase(database);
dataSource.setContainer(container);
dataSource.setProvider(provider);
dataSource.setJndiDataSource(dataSourceName.getValue());
dataSource.setDatabaseURL(databaseURL.getValue());
attributeMap.put(JPADataSource.class, dataSource);
return dataSource;
}
示例5: 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);
}
}
示例6: loadCamelConnectionDto
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
protected ConnectionCatalogDto loadCamelConnectionDto(Project project) {
if (project.hasFacet(ResourcesFacet.class)) {
ResourcesFacet facet = project.getFacet(ResourcesFacet.class);
FileResource file = facet.getResource("camel-connector.json");
String json = file.getContents();
try {
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(json, ConnectionCatalogDto.class);
} catch (IOException e) {
// error
}
}
return null;
}
示例7: createJavaSourceForComponent
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
private void createJavaSourceForComponent(Project project, String schemeName, String packageName, String className) {
JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
String fqn = packageName + "." + className;
JavaResource existing = facet.getJavaResource(fqn);
if (existing != null && existing.exists()) {
// override existing
existing.delete();
}
// need to parse to be able to extends another class
final JavaClassSource javaClass = Roaster.create(JavaClassSource.class);
javaClass.setName(className);
javaClass.setPackage(packageName);
javaClass.setSuperType("DjangoComponent");
javaClass.addImport("io.fabric8.django.component.connector.DjangoComponent");
// add public no-arg constructor
javaClass.addMethod().setPublic().setConstructor(true).setBody("super(\"" + schemeName + "\", \"" + fqn + "\");");
facet.saveJavaSource(javaClass);
}
示例8: execute
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
StopWatch watch = new StopWatch();
log.debug("Starting to setup fabric8 project");
Project project = getSelectedProject(context.getUIContext());
if (project == null) {
return Results.fail("No pom.xml available so cannot edit the project!");
}
// setup fabric8-maven-plugin
setupFabricMavenPlugin(project);
log.debug("fabric8-maven-plugin now setup");
// make sure we have resources as we need it later
facetFactory.install(project, ResourcesFacet.class);
log.info("execute took " + watch.taken());
return Results.success();
}
示例9: testAddEndpoint
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
protected void testAddEndpoint(Project project) throws Exception {
String key = "_camelContext1/myNewRoute/_from1";
WizardCommandController command = testHarness.createWizardController(CamelAddEndpointXmlCommand.class, project.getRoot());
command.initialize();
command.setValueFor("xml", "META-INF/spring/camel-context.xml");
setNodeValue(key, command);
command.setValueFor("componentName", "log");
command = command.next();
command.initialize();
command.setValueFor("loggerName", "myLog");
assertExecutes(command);
List<ContextDto> contexts = getRoutesXml(project);
assertFalse("Should have loaded a camelContext", contexts.isEmpty());
String expectedKey = "_camelContext1/myNewRoute/_to1";
assertNodeWithKey(contexts, expectedKey);
}
示例10: isEnabled
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
@Override
public boolean isEnabled(UIContext context) {
// TODO: Allow to add in GUI from current cursor position
boolean enabled = super.isEnabled(context);
if (enabled) {
// we should only be enabled in non gui
boolean gui = isRunningInGui(context);
enabled = !gui;
}
if (enabled) {
// must have xml files with camel routes to be enabled
Project project = getSelectedProject(context);
String currentFile = getSelectedFile(context);
String selected = configureXml(project, xml, currentFile);
return selected != null;
}
return false;
}
示例11: testAddJavaScript
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
@Test
public void testAddJavaScript() throws Exception {
File root = prepareRoot("target/tests/add-javascript-verticle-0");
Project project = projectFactory.createProject(resourceFactory.create(root), projectProvider);
facetFactory.install(project, VertxMavenFacet.class);
String js1 = verticles.createNewVerticle(project, "my-verticle", null, "js", false);
assertThat(js1).endsWith("src/main/javascript/my-verticle.js");
assertThat(new File(root, "src/main/javascript/my-verticle.js")).isFile();
assertThat(project.getFacet(MavenFacet.class).getProperties())
.contains(entry("vertx.verticle", "unknown.MainVerticle"));
String js2 = verticles.createNewVerticle(project, "my-main-verticle.js", null, "javascript", true);
assertThat(js2).endsWith("src/main/javascript/my-main-verticle.js");
assertThat(new File(root, "src/main/javascript/my-main-verticle.js")).isFile();
assertThat(project.getFacet(MavenFacet.class).getProperties())
.contains(entry("vertx.verticle", "my-main-verticle.js"));
}
示例12: initializeUI
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
@Override
public void initializeUI(UIBuilder builder) throws Exception {
InputComponentFactory factory = builder.getInputComponentFactory();
dependencies = factory.createSelectMany("dependencies", VertxDependency.class)
.setLabel("Dependency List")
.setDescription("Dependency list");
UIContext uiContext = builder.getUIContext();
if (uiContext.getProvider().isGUI()) {
dependencies.setItemLabelConverter(VertxDependency::getName);
} else {
dependencies.setItemLabelConverter(VertxDependency::getArtifactId);
}
Project project = Projects.getSelectedProject(getProjectFactory(), uiContext);
final Collection<VertxDependency> deps;
if (project != null && project.hasFacet(VertxMavenFacet.class)) {
deps = project.getFacet(VertxMavenFacet.class).getUsedDependencies();
} else {
deps = VertxMavenFacet.getAllDependencies();
}
dependencies.setValueChoices(deps);
builder.add(dependencies);
}
示例13: initializeUI
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
@Override
public void initializeUI(UIBuilder builder) throws Exception {
InputComponentFactory factory = builder.getInputComponentFactory();
dependencies = factory.createSelectMany("dependencies", VertxDependency.class)
.setLabel("Dependency List")
.setDescription("Dependency list");
UIContext uiContext = builder.getUIContext();
if (uiContext.getProvider().isGUI()) {
dependencies.setItemLabelConverter(VertxDependency::getName);
} else {
dependencies.setItemLabelConverter(VertxDependency::getArtifactId);
}
Project project = Projects.getSelectedProject(getProjectFactory(), uiContext);
final Collection<VertxDependency> deps;
if (project != null && project.hasFacet(VertxMavenFacet.class)) {
deps = project.getFacet(VertxMavenFacet.class).getNotUsedDependencies();
} else {
deps = VertxMavenFacet.getAllDependencies();
}
dependencies.setValueChoices(deps);
builder.add(dependencies);
}
示例14: testDeleteRoute
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
protected void testDeleteRoute(Project project) throws Exception {
String key = "_camelContext1/cbr-route/_choice1/_when1/_to1";
CommandController command = testHarness.createCommandController(CamelDeleteNodeXmlCommand.class, project.getRoot());
command.initialize();
command.setValueFor("xml", "META-INF/spring/camel-context.xml");
setNodeValue(key, command);
assertValidAndExecutes(command);
List<ContextDto> contexts = getRoutesXml(project);
assertFalse("Should have loaded a camelContext", contexts.isEmpty());
assertNoNodeWithKey(contexts, key);
assertNodeWithKey(contexts, NEW_ROUTE_KEY);
}
示例15: testOnEmptyProject
import org.jboss.forge.addon.projects.Project; //导入依赖的package包/类
@Test
public void testOnEmptyProject() throws Exception {
Project project = projectFactory.createTempProject(projectProvider);
facetFactory.install(project, VertxMavenFacet.class);
DependencyFacet dependencies = project.getFacet(DependencyFacet.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", null, 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");
}