本文整理了Java中org.jboss.forge.addon.projects.Project
类的一些代码示例,展示了Project
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project
类的具体详情如下:
包路径:org.jboss.forge.addon.projects.Project
类名称:Project
[英]Describes a set of Resource instances that represent a unit of work.
[中]描述一组表示工作单元的资源实例。
代码示例来源:origin: org.jboss.forge.addon/wildfly-swarm
private DirectoryResource getTargetDirectory(Project project)
{
MavenFacet mavenFacet = project.getFacet(MavenFacet.class);
Build build = mavenFacet.getModel().getBuild();
String targetFolderName;
if (build != null && build.getOutputDirectory() != null)
{
targetFolderName = mavenFacet.resolveProperties(build.getOutputDirectory());
}
else
{
targetFolderName = "target" + File.separator + "classes";
}
DirectoryResource projectRoot = project.getRoot().reify(DirectoryResource.class);
return projectRoot.getChildDirectory(targetFolderName);
}
代码示例来源:origin: org.jboss.forge.addon/parser-java-api
@Override
public Result execute(UIExecutionContext context) throws Exception
{
Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap();
Project project = (Project) attributeMap.get(Project.class);
if (project.hasFacet(JavaSourceFacet.class))
{
JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
MetadataFacet metadata = project.getFacet(MetadataFacet.class);
if (createMain.getValue())
{
JavaClassSource javaClass = Roaster
.create(JavaClassSource.class)
.setPackage(facet.getBasePackage())
.setName("Main")
.addMethod("public static void main(String[] args) {}")
.setBody("System.out.println(\"Hi there! I was forged as part of the project you call "
+ metadata.getProjectName()
+ ".\");")
.getOrigin();
facet.saveJavaSource(javaClass);
}
}
return null;
}
}
代码示例来源:origin: errai/errai
public static File moduleLogicalNameToFile(final String moduleName, final Project project) {
final String relModuleFile = moduleName.replace('.', File.separatorChar) + ".gwt.xml";
final MavenFacet coreFacet = project.getFacet(MavenFacet.class);
final Build build = coreFacet.getModel().getBuild();
final String relSrcRoot = (build == null || build.getSourceDirectory() == null) ?
DefaultValue.SourceDirectory.getDefaultValue() :
build.getSourceDirectory();
final File modulePath = new File(new File(project.getRootDirectory().getUnderlyingResourceObject(), relSrcRoot),
relModuleFile);
return modulePath;
}
代码示例来源:origin: errai/errai
@Override
public String getRelFilePath() {
final JavaSourceFacet sourceFacet = getProject().getFacet(JavaSourceFacet.class);
final File testSourceDirectory = sourceFacet.getTestSourceDirectory().getUnderlyingResourceObject().getAbsoluteFile();
final File projectRoot = getProject().getRootDirectory().getUnderlyingResourceObject().getAbsoluteFile();
final File absoluteResult = new File(testSourceDirectory, GWT_MOCKITO_RUNNER_REL_PATH)
.getAbsoluteFile();
return absoluteResult.getPath().replace(projectRoot.getPath(), "");
}
代码示例来源:origin: errai/errai
private File getSourceFolder() {
final MavenFacet mavenFacet = holder.getProject().getFacet(MavenFacet.class);
final Model model = mavenFacet.getModel();
Build build = model.getBuild();
if (build == null) {
build = new Build();
model.setBuild(build);
}
String srcDir = build.getSourceDirectory();
if (srcDir == null || srcDir.equals("")) {
srcDir = DefaultValue.SourceDirectory.getDefaultValue();
}
return new File(holder.getProject().getRootDirectory().getUnderlyingResourceObject(), srcDir);
}
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
@Override
public DirectoryResource getTestTargetDirectory()
{
MavenFacet mavenFacet = getFaceted().getFacet(MavenFacet.class);
Build build = mavenFacet.getModel().getBuild();
String targetFolderName;
if (build != null && build.getTestOutputDirectory() != null)
{
targetFolderName = mavenFacet.resolveProperties(build.getTestOutputDirectory());
}
else
{
targetFolderName = "target" + File.separator + "test-classes";
}
DirectoryResource projectRoot = getFaceted().getRoot().reify(DirectoryResource.class);
return projectRoot.getChildDirectory(targetFolderName);
}
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
@Override
public String getBasePackage()
{
Model model = getFaceted().getFacet(MavenFacet.class).getModel();
String groupId = model.getGroupId();
if (groupId == null)
{
groupId = model.getParent().getGroupId();
}
return Packages.toValidPackageName(groupId);
}
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
@Override
public void setFinalName(final String finalName)
{
MavenFacet mavenFacet = getFaceted().getFacet(MavenFacet.class);
Model pom = mavenFacet.getModel();
Build build = pom.getBuild();
if (build == null)
{
build = new Build();
pom.setBuild(build);
}
pom.getBuild().setFinalName(finalName);
mavenFacet.setModel(pom);
}
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
@Override
public DirectoryResource getTestSourceDirectory()
{
MavenFacet mavenFacet = getFaceted().getFacet(MavenFacet.class);
Build build = mavenFacet.getModel().getBuild();
String srcFolderName;
if (build != null && build.getTestSourceDirectory() != null)
{
srcFolderName = mavenFacet.resolveProperties(build.getTestSourceDirectory());
}
else
{
srcFolderName = "src" + File.separator + "test" + File.separator + "java";
}
DirectoryResource projectRoot = getFaceted().getRoot().reify(DirectoryResource.class);
return projectRoot.getChildDirectory(srcFolderName);
}
代码示例来源:origin: errai/errai
public static String getSourceDirectory(final Project project) {
final MavenFacet coreFacet = project.getFacet(MavenFacet.class);
return coreFacet.getModel().getBuild().getSourceDirectory();
}
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
@Override
public DirectoryResource getResourceDirectory()
{
MavenFacet mavenFacet = getFaceted().getFacet(MavenFacet.class);
Build build = mavenFacet.getModel().getBuild();
final String resFolderName;
if (build != null && !build.getResources().isEmpty() && build.getResources().get(0).getDirectory() != null)
{
resFolderName = build.getResources().get(0).getDirectory();
}
else
{
resFolderName = "src" + File.separator + "main" + File.separator + "resources";
}
DirectoryResource projectRoot = getFaceted().getRoot().reify(DirectoryResource.class);
return projectRoot.getChildDirectory(resFolderName);
}
代码示例来源:origin: io.fabric8.forge/funktion
@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();
}
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
@Override
public String getFinalName()
{
MavenFacet mavenFacet = getFaceted().getFacet(MavenFacet.class);
Model pom = mavenFacet.getModel();
Build build = pom.getBuild();
return build != null ? build.getFinalName() : getDefaultFinalName();
}
代码示例来源:origin: org.jboss.forge.addon/projects-impl
@Override
public Result execute(UIExecutionContext context)
{
final Result result;
Project project = getSelectedProject(context.getUIContext());
DependencyFacet deps = project.getFacet(DependencyFacet.class);
String name = named.getValue();
String urlValue = url.getValue();
if (deps.hasRepository(urlValue))
{
result = Results.fail("Repository exists [" + url + "]");
}
else
{
deps.addRepository(name, urlValue);
result = Results.success("Added repository [" + name + "->" + urlValue + "]");
}
return result;
}
代码示例来源:origin: org.jboss.forge.addon/addons-impl
@Override
public Result execute(UIExecutionContext context) throws Exception
UIContext uiContext = context.getUIContext();
Project project = getSelectedProject(uiContext);
JavaClassSource javaClass = Roaster.create(JavaClassSource.class).setName(named.getValue())
.setPackage(packageName.getValue());
javaClass.addImport("org.jboss.arquillian.container.test.api.Deployment");
javaClass.addImport("org.jboss.arquillian.junit.Arquillian");
javaClass.addImport("org.jboss.forge.arquillian.AddonDependency");
AnnotationSource<JavaClassSource> addonDependenciesAnn = getDeployment.addAnnotation("AddonDependencies");
if (!reuseProjectAddons.getValue())
.setBody("Assert.fail(\"Not yet implemented\");").addAnnotation("Test");
JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
JavaResource javaResource = facet.saveTestJavaSource(javaClass);
uiContext.setSelection(javaResource);
return Results.success("Test class " + javaClass.getQualifiedName() + " created");
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
@Override
public List<DependencyRepository> getRepositories()
{
List<DependencyRepository> results = new ArrayList<>();
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
List<Repository> repos = pom.getRepositories();
for (Repository repo : repos)
{
results.add(new DependencyRepository(repo.getId(), repo.getUrl()));
}
return Collections.unmodifiableList(results);
}
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
@Override
public void addRepository(final String name, final String url)
{
if (!hasRepository(url))
{
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
Repository repo = new Repository();
repo.setId(name);
repo.setUrl(url);
pom.getRepositories().add(repo);
maven.setModel(pom);
}
}
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
@Override
public List<DependencyRepository> getPluginRepositories()
{
List<DependencyRepository> results = new ArrayList<>();
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
List<Repository> repos = pom.getPluginRepositories();
if (repos != null)
{
for (Repository repo : repos)
{
results.add(new DependencyRepository(repo.getId(), repo.getUrl()));
}
}
return Collections.unmodifiableList(results);
}
代码示例来源:origin: org.jboss.forge.addon/maven-impl-projects
@Override
public void addPluginRepository(String id, String url, org.jboss.forge.addon.maven.profiles.Profile profileParam)
{
if (profileParam == null)
addPluginRepository(id, url);
else
{
if (!hasPluginRepository(url, profileParam))
{
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
Profile profile = getProfile(pom, profileParam);
if (profile == null)
{
profile = profileParam.getAsMavenProfile();
pom.getProfiles().add(profile);
}
Repository repo = new Repository();
repo.setId(id);
repo.setUrl(url);
profile.addPluginRepository(repo);
maven.setModel(pom);
}
}
}
代码示例来源:origin: me.escoffier.forge/vertx-forge-addon
@Override
public boolean install() {
if (!this.isInstalled()) {
getResourceDirectories().forEach(DirectoryResource::mkdirs);
}
// Update Maven model - main resource only
MavenFacet maven = getFaceted().getFacet(MavenFacet.class);
Model pom = maven.getModel();
Resource main = new Resource();
main.setDirectory("${project.basedir}/src/main/" + name);
pom.getBuild().getResources().add(main);
maven.setModel(pom);
return true;
}
内容来源于网络,如有侵权,请联系作者删除!