public synchronized Object put(Object key, Object value) { Object oldValue = null; if (containsKey(key)) { oldValue = get(key); } project.setProperty(key.toString(), value.toString()); return oldValue; } }
@Override public Void answer(InvocationOnMock invocationOnMock) throws Throwable { invocationOnMock.callRealMethod(); Object[] args = invocationOnMock.getArguments(); project = (Project) args[0]; project.setProperty("group1:artifact1:jar", "path1"); project.setProperty("group2:artifact2:jar", "path2"); project.setProperty("group3:artifact3:jar:classifier3", "path3"); return null; } }).when(dependenciesTask).setProject(any(Project.class));
/** Executes the target, if any, that user designates executing before failing the test */ private void executeHaltTarget(int exitValue) { if(m_onHaltTarget != null) { if(m_outputDir != null) { getProject().setProperty("testng.outputdir", m_outputDir.getAbsolutePath()); } getProject().setProperty("testng.returncode", String.valueOf(exitValue)); Target t= getProject().getTargets().get(m_onHaltTarget); if(t != null) { t.execute(); } } }
/** Executes the target, if any, that user designates executing before failing the test */ private void executeHaltTarget(int exitValue) { if (m_onHaltTarget != null) { if (m_outputDir != null) { getProject().setProperty("testng.outputdir", m_outputDir.getAbsolutePath()); } getProject().setProperty("testng.returncode", String.valueOf(exitValue)); Target t = getProject().getTargets().get(m_onHaltTarget); if (t != null) { t.execute(); } } }
@Override protected void afterExecuteJavaProcess(int rc) { if ((rc & ExitCodes.ERROR_FLAG) != 0) { throw new BuildException("Execution of SpotBugs failed."); } if ((rc & ExitCodes.MISSING_CLASS_FLAG) != 0) { log("Classes needed for analysis were missing"); } if (warningsProperty != null && (rc & ExitCodes.BUGS_FOUND_FLAG) != 0) { getProject().setProperty(warningsProperty, "true"); } if (outputFileName != null) { log("Output saved to " + outputFileName); } }
@Override public void execute() throws BuildException { checkParameters(); try { execFindbugs(); } catch (BuildException e) { // log("Oops: " + e.getMessage()); if (errorProperty != null) { getProject().setProperty(errorProperty, "true"); } if (failOnError) { throw e; } } }
@Before public void setUp() throws IOException { validatePostConstruct(); // initialize Ant buildRule.configureProject(pathToTestScript + separator + antTestScriptFilename); // Each test case gets one temp file name, accessible with ${tmpfile} final File newFile = tempFolder.newFile(); newFile.delete(); // It shouldn't exist yet, but we want a unique name buildRule.getProject().setProperty("tmpfile", newFile.getAbsolutePath()); Project project = buildRule.getProject(); if (!project.getBaseDir().toString().endsWith(mvnWorkaround)) { // when running from maven, the path needs to be adapted... // FIXME: this is more a workaround than a good solution... project.setBasedir(project.getBaseDir().toString() + separator + pathToTestScript); } }
@Override protected void afterExecuteJavaProcess(int rc) { if (rc == 0) { log("Success"); } else { if (errorProperty != null) { getProject().setProperty(errorProperty, "true"); } if ((rc & ExitCodes.ERROR_FLAG) != 0) { String message = "At least one error occurred!"; if (failIfBugFound) { throw new BuildException(message); } else { log(message, Project.MSG_ERR); } } if ((rc & ExitCodes.BUGS_FOUND_FLAG) != 0) { String message = "At least one unexpected bug is reported!"; if (failIfBugFound) { throw new BuildException(message); } else { log(message, Project.MSG_ERR); } } } }
+ " warnings."; if (failureProperty != null) { getProject().setProperty(failureProperty, failureMsg);
getProject().setProperty(name, value); addedAttributes.put(name, value); } else if (getProject().getProperty(name) == null) {
protected void setUp() throws Exception { super.setUp(); // Potentially throws Exception. project = new Project(); project.init(); ProjectHelper.getProjectHelper().parse(project, antFile); project.executeTarget("clean"); String altJavaHome = System.getProperty("java.home"); if (altJavaHome.lastIndexOf("jre") >= 0) { altJavaHome = altJavaHome.substring(0, altJavaHome.lastIndexOf("jre")); } else { altJavaHome = altJavaHome + File.separator + "jre"; } try { File altFile = new File(altJavaHome); if (altFile.exists()) { project.setProperty("alt.java.home", altJavaHome); } } catch (Exception e) { // could be security, io, etc. Ignore it. // End result is as if .exists() returned null } }
project.setProperty(failuresPropertyName, String.valueOf(problemCount)); project.log("Setting property " + failuresPropertyName + " to " + problemCount, Project.MSG_VERBOSE);
@Test public final void testFailureProperty() throws IOException { final CheckstyleAntTask antTask = new CheckstyleAntTask(); antTask.setConfig(getPath(CONFIG_FILE)); antTask.setFile(new File(getPath(VIOLATED_INPUT))); final Project project = new Project(); final String failurePropertyName = "myProperty"; project.setProperty(failurePropertyName, FAILURE_PROPERTY_VALUE); antTask.setProject(project); antTask.setFailureProperty(failurePropertyName); try { antTask.execute(); fail("Exception is expected"); } catch (BuildException ignored) { final Map<String, Object> hashtable = project.getProperties(); final Object propertyValue = hashtable.get(failurePropertyName); assertEquals("Number of errors is unexpected", "Got 2 errors and 0 warnings.", propertyValue); } }
/** * Set paths as properties on the Ant project */ public void setPathProperties(Project antProject, Map<String, Path> paths) { for (Map.Entry<String, ?> pair : paths.entrySet()) { antProject.setProperty(pair.getKey(), pair.getValue().toString()); } }
private void setProperty(String propertyName, String value) { if (value != null) { getProject().setProperty(prefix + propertyName, value); } }
protected void addProperty(String n, String v) { // System.out.println(" Adding property: " + n + " = " + v); if (v != null) getProject().setProperty(n, v); }
protected void setResult(int code) { if (exitCodeProperty != null) { getProject().setProperty(exitCodeProperty, Integer.toString(code)); getProject().setProperty(exitCodeMessageProperty, getErrorMessage(code)); } else { if (code != 0) { throw new RuntimeException("An error has occurred. Error code: " + code); } } }
public synchronized Object put(Object key, Object value) { Object oldValue = null; if (containsKey(key)) { oldValue = get(key); } project.setProperty(key.toString(), value.toString()); return oldValue; } }
/** * {@inheritDoc} */ @Override protected void execute() throws Exception { if (getSardine().exists(url)) getProject().setProperty(property, "true"); }
/** * execute the task * * @throws BuildException */ public void doExecute(AdminCommandsService acs) throws Exception { String result = acs.listComponents(true, false, false, getState(), getSharedLibraryName(), getServiceAssemblyName()); if (xmlOutput != null) { getProject().setProperty(xmlOutput, result); } log(result, Project.MSG_WARN); }