private Properties getSystemProperties() { Properties props = new Properties(); getEnvProperties(props); props.putAll(System.getProperties()); ConverterUtils.addProperties(props, project.getProperties()); return props; }
public RepositorySystemSession getSession(Task task, LocalRepository localRepo) { DefaultRepositorySystemSession session = new MavenRepositorySystemSession(); Map<Object, Object> configProps = new LinkedHashMap<Object, Object>(); configProps.put(ConfigurationProperties.USER_AGENT, getUserAgent()); configProps.putAll(System.getProperties()); configProps.putAll((Map<?, ?>) project.getProperties()); configProps.putAll((Map<?, ?>) project.getUserProperties()); session.setConfigProps(configProps); session.setNotFoundCachingEnabled(false); session.setTransferErrorCachingEnabled(false); session.setOffline(isOffline()); session.setUserProps(project.getUserProperties()); session.setLocalRepositoryManager(getLocalRepoMan(localRepo)); session.setProxySelector(getProxySelector()); session.setMirrorSelector(getMirrorSelector()); session.setAuthenticationSelector(getAuthSelector()); session.setCache(new DefaultRepositoryCache()); session.setRepositoryListener(new AntRepositoryListener(task)); session.setTransferListener(new AntTransferListener(task)); session.setWorkspaceReader(ProjectWorkspaceReader.getInstance()); return session; }
/** * get all properties, when project is there got all project Properties * * @return properties */ public Map getProperties() { Project currentProject = getProject(); if (currentProject != null) { return currentProject.getProperties(); } else { return properties; } }
/** * Bind the runner to a project component. Properties, targets and references are all added as * beans; project is bound to project, and self to the component. * * @param component to become <code>self</code> */ public void bindToComponent(ProjectComponent component) { project = component.getProject(); addBeans(project.getProperties()); addBeans(project.getUserProperties()); addBeans(project.getCopyOfTargets()); addBeans(project.getCopyOfReferences()); addBean("project", project); addBean("self", component); }
private IStatus executeOperation(final Project antProject, final IProgressMonitor monitor) { try { final Map<String, Object> properties = new HashMap<String, Object>(); if (antProject != null) { final Hashtable<String, Object> antProperties = antProject.getProperties(); properties.putAll(antProperties); } final IStringResolver variables = new PropertiesStringResolver(properties, "${", "}"); updateRcmGml(variables); final IRainfallModelProvider provider = new UrlRainfallModellProvider(m_rcmUrl); final RainfallGenerationOperation operation = new RainfallGenerationOperation(provider, variables); return operation.execute(monitor); } catch (final CoreException ce) { final IStatus status = ce.getStatus(); antProject.log(this, status.getMessage(), status.getException(), Project.MSG_ERR); return Status.OK_STATUS; } catch (final InvocationTargetException e) { e.printStackTrace(); throw new BuildException(e.getTargetException()); } }
/** Runs the given targets for the test project specified */ public Map run( File buildFile, List targets, Properties projectProperties, Properties pluginState) { Project project = new Project(); project.setCoreLoader(getClass().getClassLoader()); antListener = new AntRunner.AntListener(); project.addBuildListener( createLogger(projectProperties.getProperty("quokka.debugger.logLevel"))); project.addBuildListener(antListener); // project.setInputHandler(new DefaultInputHandler()); project.setInputHandler( new InputHandler() { public void handleInput(InputRequest request) throws BuildException { System.out.println(request.getPrompt()); try { String line = new BufferedReader(new InputStreamReader(System.in)).readLine(); request.setInput(line); } catch (IOException e) { e.printStackTrace(); } } }); project.setKeepGoingMode(false); // PrintStream err = System.err; // PrintStream out = System.out; // InputStream in = System.in; project.setDefaultInputStream(System.in); // System.setIn(new DemuxInputStream(project)); // System.setOut(new PrintStream(new DemuxOutputStream(project, false))); // System.setErr(new PrintStream(new DemuxOutputStream(project, true))); for (Iterator i = projectProperties.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); project.setUserProperty((String) entry.getKey(), (String) entry.getValue()); } Exception exception = null; try { project.fireBuildStarted(); project.init(); project.setUserProperty("ant.version", "1.7.0"); project.setUserProperty("ant.file", buildFile.getAbsolutePath()); // Remove hard dependency on core.main to allow integration tests to be // done within the core.main package. This is ok as AntRunner is loaded via the integration // test class loader. org.apache.tools.ant.ProjectHelper helper = (org.apache.tools.ant.ProjectHelper) getClass() .getClassLoader() .loadClass("ws.quokka.core.main.ant.ProjectHelper") .newInstance(); project.addReference("ant.projectHelper", helper); helper.parse(project, buildFile); // Add any plugin state PluginState state = (PluginState) project.getReference("quokka.pluginState"); for (Iterator i = pluginState.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); state.put((String) entry.getKey(), entry.getValue()); } Vector targetsVector = new Vector(); targetsVector.addAll(targets); // make sure that we have a target to execute if (targets.size() == 0) { if (project.getDefaultTarget() != null) { targetsVector.add(project.getDefaultTarget()); } } project.executeTargets(targetsVector); Map results = antListener.toMap(); results.put("antProperties", new HashMap(project.getProperties())); return results; } catch (Exception e) { exception = e; if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { throw new BuildException(e); } } finally { // System.setOut(out); // System.setErr(err); // System.setIn(in); project.fireBuildFinished(exception); } }
public Map<String, Object> getBuildProperties(final boolean reload) throws CoreException { final Project project = new Project(); Map<String, Object> sdkProperties = buildPropertiesCache.get(getLocation().toPortableString()); try { if (sdkProperties == null || reload == true) { project.setBaseDir(new File(getLocation().toPortableString())); project.setSystemProperties(); final Property envTask = new Property(); envTask.setProject(project); envTask.setEnvironment("env"); envTask.execute(); loadPropertiesFile(project, "build." + project.getProperty("user.name") + ".properties"); loadPropertiesFile( project, "build." + project.getProperty("env.COMPUTERNAME") + ".properties"); loadPropertiesFile(project, "build." + project.getProperty("env.HOST") + ".properties"); loadPropertiesFile(project, "build." + project.getProperty("env.HOSTNAME") + ".properties"); loadPropertiesFile(project, "build.properties"); if (project.getProperty("app.server.type") == null) { throw new CoreException( SDKCorePlugin.createErrorStatus( "Missing ${app.server.type} setting in build.properties file.")); } final Map<String, String> propertyCopyList = new HashMap<String, String>(); propertyCopyList.put( "app.server." + project.getProperty("app.server.type") + ".dir", "app.server.dir"); propertyCopyList.put( "app.server." + project.getProperty("app.server.type") + ".deploy.dir", "app.server.deploy.dir"); propertyCopyList.put( "app.server." + project.getProperty("app.server.type") + ".lib.global.dir", "app.server.lib.global.dir"); propertyCopyList.put( "app.server." + project.getProperty("app.server.type") + ".portal.dir", "app.server.portal.dir"); for (String key : propertyCopyList.keySet()) { AntPropertyCopy propertyCopyTask = new AntPropertyCopy(); propertyCopyTask.setOverride(true); propertyCopyTask.setProject(project); String from = key; String to = propertyCopyList.get(from); propertyCopyTask.setFrom(from); propertyCopyTask.setName(to); propertyCopyTask.execute(); } sdkProperties = project.getProperties(); for (String propertyKey : APP_SERVER_PROPERTIES_KEYS) { if (!sdkProperties.keySet().contains(propertyKey)) { throw new CoreException( SDKCorePlugin.createErrorStatus( "Missing ${" + propertyKey + "} setting in build.properties file.")); } } buildPropertiesCache.put(getLocation().toPortableString(), sdkProperties); } } catch (Exception e) { throw new CoreException(SDKCorePlugin.createErrorStatus(e.getMessage())); } return sdkProperties; }