本文整理了Java中org.apache.tools.ant.Project.setProperty()
方法的一些代码示例,展示了Project.setProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.setProperty()
方法的具体详情如下:
包路径:org.apache.tools.ant.Project
类名称:Project
方法名:setProperty
[英]Set a property. Any existing property of the same name is overwritten, unless it is a user property.
[中]设置一个属性。任何同名的现有属性都将被覆盖,除非它是用户属性。
代码示例来源:origin: apache/groovy
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;
}
}
代码示例来源:origin: robolectric/robolectric
@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));
代码示例来源:origin: org.testng/testng
/** 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();
}
}
}
代码示例来源:origin: cbeust/testng
/** 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();
}
}
}
代码示例来源:origin: spotbugs/spotbugs
@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);
}
}
代码示例来源:origin: spotbugs/spotbugs
@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;
}
}
}
代码示例来源:origin: pmd/pmd
@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);
}
}
代码示例来源:origin: spotbugs/spotbugs
@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);
}
}
}
}
代码示例来源:origin: checkstyle/checkstyle
+ " warnings.";
if (failureProperty != null) {
getProject().setProperty(failureProperty, failureMsg);
代码示例来源:origin: org.apache.ant/ant
getProject().setProperty(name, value);
addedAttributes.put(name, value);
} else if (getProject().getProperty(name) == null) {
代码示例来源:origin: groovy/groovy-core
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
}
}
代码示例来源:origin: pmd/pmd
project.setProperty(failuresPropertyName, String.valueOf(problemCount));
project.log("Setting property " + failuresPropertyName + " to " + problemCount, Project.MSG_VERBOSE);
代码示例来源:origin: checkstyle/checkstyle
@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);
}
}
代码示例来源:origin: org.kuali.maven.common/maven-kuali-common
/**
* 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());
}
}
代码示例来源:origin: org.apache.ivy/ivy
private void setProperty(String propertyName, String value) {
if (value != null) {
getProject().setProperty(prefix + propertyName, value);
}
}
代码示例来源:origin: biz.aQute/bnd
protected void addProperty(String n, String v) {
// System.out.println(" Adding property: " + n + " = " + v);
if (v != null)
getProject().setProperty(n, v);
}
代码示例来源:origin: net.exogeni.orca.core/shirako
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);
}
}
}
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
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;
}
}
代码示例来源:origin: lookfirst/sardine
/**
* {@inheritDoc}
*/
@Override
protected void execute() throws Exception {
if (getSardine().exists(url))
getProject().setProperty(property, "true");
}
代码示例来源:origin: org.apache.servicemix.jbi/org.apache.servicemix.jbi.deployer
/**
* 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);
}
内容来源于网络,如有侵权,请联系作者删除!