DefaultPraxisProject(FileObject directory, FileObject projectFile, ProjectState state) throws IOException { this.directory = directory; this.projectFile = projectFile; this.state = state; properties = parseProjectFile(projectFile); propsListener = new PropertiesListener(); properties.addPropertyChangeListener(propsListener); Lookup base = Lookups.fixed( new Object[] { this, properties, new Info(), new ActionImpl(), state, new PraxisCustomizerProvider(this), new PraxisLogicalViewProvider(this), new BaseTemplates(), UILookupMergerSupport.createPrivilegedTemplatesMerger() }); this.lookup = LookupProviderSupport.createCompositeLookup(base, LOOKUP_PATH); helperListener = new HelperListener(); ProjectHelper.getDefault() .addPropertyChangeListener( WeakListeners.propertyChange(helperListener, ProjectHelper.getDefault())); }
@Override public void propertyChange(PropertyChangeEvent evt) { if (ProjectHelper.PROP_HUB_CONNECTED.equals(evt.getPropertyName())) { if (ProjectHelper.getDefault().isConnected()) { actionsEnabled = true; executedBuildFiles.clear(); } } }
public MonitoredBuild(File buildFile, String target) { myBuildFile = buildFile; this.target = target; project = new Project(); project = new Project(); project.init(); project.setUserProperty("ant.file", myBuildFile.getAbsolutePath()); ProjectHelper.configureProject(project, myBuildFile); }
public void execute() { if (this.nestedTask == null) { throw new BuildException("Missing nested element"); } if (this.name == null) { throw new BuildException("Name not specified"); } this.name = ProjectHelper.genComponentName(this.getURI(), this.name); final ComponentHelper helper = ComponentHelper.getComponentHelper(this.getProject()); final String componentName = ProjectHelper.genComponentName(this.nestedTask.getNamespace(), this.nestedTask.getTag()); final AntTypeDefinition def = helper.getDefinition(componentName); if (def == null) { throw new BuildException("Unable to find typedef " + componentName); } final PreSetDefinition newDef = new PreSetDefinition(def, this.nestedTask); newDef.setName(this.name); helper.addDataTypeDefinition(newDef); this.log("defining preset " + this.name, 3); }
private static IClasspathContainer allocateContainer( IJavaProject javaProject, List<IClasspathEntry> entries, IPath id, String description) { if (AndmoreAndroidPlugin.getDefault() == null) { // This is totally weird, but I've seen it happen! return null; } // First check that the project has a library-type container. try { IClasspathEntry[] rawClasspath = javaProject.getRawClasspath(); final IClasspathEntry[] oldRawClasspath = rawClasspath; boolean foundContainer = false; for (IClasspathEntry entry : rawClasspath) { // get the entry and kind final int kind = entry.getEntryKind(); if (kind == IClasspathEntry.CPE_CONTAINER) { String path = entry.getPath().toString(); String idString = id.toString(); if (idString.equals(path)) { foundContainer = true; break; } } } // if there isn't any, add it. if (foundContainer == false) { // add the android container to the array rawClasspath = ProjectHelper.addEntryToClasspath( rawClasspath, JavaCore.newContainerEntry(id, true /*isExported*/)); } // set the new list of entries to the project if (rawClasspath != oldRawClasspath) { javaProject.setRawClasspath(rawClasspath, new NullProgressMonitor()); } } catch (JavaModelException e) { // This really shouldn't happen, but if it does, simply return null (the calling // method will fails as well) return null; } return new AndroidClasspathContainer( entries.toArray(new IClasspathEntry[entries.size()]), id, description, IClasspathContainer.K_APPLICATION); }
/** * Cleanup all allocated resources (if any) from the instance attached to the given request. * * @param sr request to check, cleanup. Ignored if {@code null}. * @see PageConfig#get(HttpServletRequest) */ public static void cleanup(ServletRequest sr) { if (sr == null) { return; } PageConfig cfg = (PageConfig) sr.getAttribute(ATTR_NAME); if (cfg == null) { return; } sr.removeAttribute(ATTR_NAME); cfg.env = null; cfg.req = null; if (cfg.eftarReader != null) { cfg.eftarReader.close(); } ProjectHelper.cleanup(); }
@Override public void execute() throws MojoExecutionException, MojoFailureException { super.execute(); compiler.setOutputDirectory(outputDirectory); try { String outputDirectoryName = OutputNamesHelper.getHarValidationOutput(project.getArtifact()); File outputBase = new File(outputDirectory, outputDirectoryName); if (!outputBase.exists()) outputBase.mkdirs(); if (!skipValidation) { validateTargets(outputBase); } else { getLog().warn("Validation skipped"); } File metadata = createHarMetadata(outputBase); ZipArchiver archiver = new ZipArchiver(); archiver.addFile(metadata, HarMetadata.METADATA_FILE_NAME); for (String compileRoot : project.getCompileSourceRoots()) { archiver.addDirectory(new File(compileRoot)); } for (File resourceDir : ProjectHelper.getResourceDirectories(project)) { archiver.addDirectory(resourceDir); } File destFile = new File( outputDirectory, project.getBuild().getFinalName() + "." + HaxeFileExtensions.HAR); archiver.setDestFile(destFile); archiver.createArchive(); project.getArtifact().setFile(destFile); } catch (IOException e) { throw new MojoFailureException("Error occurred during `har` package creation", e); } catch (Exception e) { throw new MojoFailureException("Har validation failed", e); } }
public ProjectHelper getProjectHelper() { return ProjectHelper.getInstance(this); }
private void handleProject(final Element projectElement) throws CruiseControlException { final String projectName = getProjectName(projectElement); if (projects.containsKey(projectName)) { final String duplicateEntriesMessage = "Duplicate entries in config file for project name " + projectName; throw new CruiseControlException(duplicateEntriesMessage); } // property handling is a little bit dirty here. // we have a set of properties mostly resolved in the rootProperties // and a child set of properties // it is possible that the rootProperties contain references to child // properties // in particular the project.name one final MapWithParent nonFullyResolvedProjectProperties = new MapWithParent(rootProperties); // Register the project's name as a built-in property LOG.debug("Setting property \"project.name\" to \"" + projectName + "\"."); nonFullyResolvedProjectProperties.put("project.name", projectName); // handle project templates properties final List projectTemplateProperties = templatePluginProperties.get(projectElement.getName()); if (projectTemplateProperties != null) { for (final Object projectTemplateProperty : projectTemplateProperties) { final Element element = (Element) projectTemplateProperty; ProjectXMLHelper.registerProperty( nonFullyResolvedProjectProperties, element, FAIL_UPON_MISSING_PROPERTY); } } // Register any project specific properties for (final Object o : projectElement.getChildren("property")) { final Element propertyElement = (Element) o; ProjectXMLHelper.registerProperty( nonFullyResolvedProjectProperties, propertyElement, FAIL_UPON_MISSING_PROPERTY); } // add the resolved rootProperties to the project's properties final Map<String, String> thisProperties = nonFullyResolvedProjectProperties.thisMap; for (final String key : rootProperties.keySet()) { if (!thisProperties.containsKey(key)) { final String value = rootProperties.get(key); thisProperties.put(key, Util.parsePropertiesInString(thisProperties, value, false)); } } // Parse the entire element tree, expanding all property macros ProjectXMLHelper.parsePropertiesInElement( projectElement, thisProperties, FAIL_UPON_MISSING_PROPERTY); // Register any custom plugins final PluginRegistry projectPlugins = PluginRegistry.createRegistry(rootPlugins); for (final Object o : projectElement.getChildren("plugin")) { final Element element = (Element) o; // final PluginPlugin plugin = (PluginPlugin) new ProjectXMLHelper().configurePlugin(element, false); // projectPlugins.register(plugin); projectPlugins.register(element); // add(plugin); } projectElement.removeChildren("property"); projectElement.removeChildren("plugin"); LOG.debug("**************** configuring project " + projectName + " *******************"); ProjectHelper projectHelper = new ProjectXMLHelper(thisProperties, projectPlugins, fileResolver, controller); final ProjectInterface project; try { project = (ProjectInterface) projectHelper.configurePlugin(projectElement, false); } catch (CruiseControlException e) { throw new CruiseControlException("error configuring project " + projectName, e); } // Why call method that is a no-op, and exists only for gendoc purposes? // add(project); project.validate(); LOG.debug("**************** end configuring project " + projectName + " *******************"); this.projects.put(projectName, project); this.projectPluginRegistries.put(projectName, projectPlugins); }
@Override public boolean isActionEnabled(String command, Lookup context) throws IllegalArgumentException { return ProjectHelper.getDefault().isConnected() && actionsEnabled; }