Path getResourcePath() { return resource.getUnderlyingResourceObject().toPath(); }
protected File getResFile(final String relPath) { File file = new File(relPath); if (!file.isAbsolute()) file = new File(getProject().getRootDirectory().getUnderlyingResourceObject(), file.getPath()); return file; }
@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(), ""); }
private Result verifyProject(final Project project) { final Collection<String> problems = getProblems(project); if (problems.isEmpty()) { return Results.success(); } else { final StringBuilder messageBuilder = new StringBuilder(); messageBuilder.append(String.format( "There are some problems with your project (%s) preventing the installation of Errai with this Addon.", project.getRootDirectory().getUnderlyingResourceObject().getAbsolutePath())); for (final String problem : problems) { messageBuilder.append(problem); } return Results.fail(messageBuilder.toString()); } }
private File getUserProvidedRulesFolder() { if (supplementalRulesFolder.getValue() != null) { File userProvidedRulesFolderFile = supplementalRulesFolder.getValue().getUnderlyingResourceObject(); configuration.setProperty(KEY_SUPPLEMENTAL_RULES_DIRECTORY, userProvidedRulesFolderFile.getAbsolutePath()); return userProvidedRulesFolderFile; } else { String userProvidedRulesFolder = configuration.getString(KEY_SUPPLEMENTAL_RULES_DIRECTORY); if (StringUtils.isEmpty(userProvidedRulesFolder)) { Path windupConfigHomePath = SharedProperties.getWindupConfigurationDirectory(); return windupConfigHomePath.resolve(".windup").resolve("rules").toFile(); } else { return new File(userProvidedRulesFolder); } } }
private void produceConfigurationsFiles(final Project project) throws IOException { final File projectRootDirectory = project.getRootDirectory().getUnderlyingResourceObject(); testWebXmlTemplateWriter.writeTemplate(new File(projectRootDirectory, "war/WEB-INF/web.xml")); testJettyEnvTemplateWriter.writeTemplate(new File(projectRootDirectory, "war/WEB-INF/jetty-env.xml")); copyConfigurationFile(project, BeansXmlFacet.class, new File(projectRootDirectory, "war/WEB-INF/beans.xml")); copyConfigurationFile(project, ErraiAppPropertiesFacet.class, new File(projectRootDirectory, "src/test/resources/ErraiApp.properties")); }
public File getAbsoluteFilePath() { return new File(getProject().getRootDirectory().getUnderlyingResourceObject(), getRelFilePath()); }
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; }
@Override public Git git(final DirectoryResource dir) throws IOException { RepositoryBuilder db = new RepositoryBuilder().findGitDir(dir.getUnderlyingResourceObject()); return new Git(db.build()); }
@Override public Git clone(final DirectoryResource dir, final String repoUri) throws GitAPIException { CloneCommand clone = Git.cloneRepository().setURI(repoUri) .setDirectory(dir.getUnderlyingResourceObject()); Git git = clone.call(); return git; }
protected File getTestSourceDirectory(final Project project) { final MavenFacet mavenFacet = project.getFacet(MavenFacet.class); final Model pom = mavenFacet.getModel(); Build build = pom.getBuild(); if (build == null) { build = new Build(); pom.setBuild(build); } String testSourceDirectoryPath = build.getTestSourceDirectory(); if (testSourceDirectoryPath == null) { testSourceDirectoryPath = "src/test/java"; build.setSourceDirectory(testSourceDirectoryPath); } return new File(project.getRootDirectory().getUnderlyingResourceObject(), testSourceDirectoryPath).getAbsoluteFile(); }
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); }
@Override public void setCurrentResource(final Resource<?> resource) { Assert.notNull(resource, "Current resource should not be null"); this.currentResource = resource; Resource<?> temp = resource; while (!(temp instanceof DirectoryResource) && temp != null) { temp = temp.getParent(); } if (temp instanceof DirectoryResource) { // Workaround to prevent "Current working directory must be a directory" exceptions when running in a // transaction File dir = ((DirectoryResource) temp).getUnderlyingResourceObject(); if (dir.exists()) { console.getAeshContext().setCurrentWorkingDirectory(new org.jboss.aesh.io.FileResource(dir)); } } updatePrompt(); }
if (rootDirectory != null && rootDirectory.getUnderlyingResourceObject().exists())
@Override public Result execute(UIExecutionContext context) throws Exception { JavaSourceFacet java = getSelectedProject(context).getFacet(JavaSourceFacet.class); String catalog = databaseCatalog.getValue(); String schema = databaseSchema.getValue(); Collection<String> tables = Lists.toList(databaseTables.getValue()); EntityGenerator entityGenerator = new EntityGenerator(); Collection<String> entities = entityGenerator .exportSelectedEntities(java.getSourceDirectory().getUnderlyingResourceObject(), descriptor, catalog, schema, tables); return Results.success(entities.size() + " entities were generated in " + descriptor.getTargetPackage()); }
options.setOutputPath(output.getValue().getUnderlyingResourceObject()); options.setIncludeJavaPackageSignature((List<String>) packages.getValue());
@Override public boolean install() { Project project = getFaceted(); // init git repo DirectoryResource rootDirectory = project.getRoot().reify(DirectoryResource.class); FileResource<?> gitDir = rootDirectory.getChild(GIT_DIRECTORY).reify(FileResource.class); if (!gitDir.exists()) { InitCommand init = Git.init(); init.setDirectory(rootDirectory.getUnderlyingResourceObject()); try { init.call().close(); } catch (Exception e) { logger.log(Level.SEVERE, "Error while initializing directory", e); } } return true; }
@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(); }
@Override public Result execute(UIExecutionContext context) throws Exception { UIContext uiContext = context.getUIContext(); Project project = (Project) uiContext.getAttributeMap().get(Project.class); String coordinate = getArchetypeGroupId() + ":" + getArchetypeArtifactId() + ":" + getArchetypeVersion(); DependencyQueryBuilder depQuery = DependencyQueryBuilder.create(coordinate); String repository = getArchetypeRepository(); if (repository != null) { depQuery.setRepositories(new DependencyRepository("archetype", repository)); } DependencyResolver resolver = SimpleContainer .getServices(AbstractArchetypeSelectionWizardStep.class.getClassLoader(), DependencyResolver.class) .get(); Dependency resolvedArtifact = resolver.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(); }
@Override public Result execute(UIExecutionContext context) throws Exception { DirectoryResource cloneFolder = targetDirectory.getValue(); if (!cloneFolder.exists()) { cloneFolder.mkdirs(); } Git clone = null; try { CloneCommand cloneCommand = Git.cloneRepository().setURI(uri.getValue()) .setDirectory(cloneFolder.getUnderlyingResourceObject()); cloneCommand.setProgressMonitor(new ProgressMonitorAdapter(context.getProgressMonitor())); clone = cloneCommand.call(); } finally { getGitUtils().close(clone); } context.getUIContext().setSelection(cloneFolder); return Results.success(); }