gpt4 book ai didi

java - Ant .NET 库文档? (设置控制台记录器参数)

转载 作者:行者123 更新时间:2023-11-28 07:16:14 25 4
gpt4 key购买 nike

我正在构建一个项目,该项目使用 C++ 后端来提高处理速度和 Java UI,并使用 Apache .NET Ant 库中名为“msbuild”的 Ant 任务构建后端二进制文件:

http://ant.apache.org/antlibs/dotnet/

但我似乎无法找到“msbuild”任务支持的元素的任何文档。我想尝试不同的控制台记录器参数。

是否有一些我无法轻易找到的文档?或者有没有一种方法可以在不阅读文档的情况下确定“msbuild”任务支持的属性和嵌套元素?

最佳答案

它可能只是 Msbuild.exe 的包装器。每个版本的框架都有。

MSBuild 命令行引用

http://msdn.microsoft.com/en-us/library/vstudio/ms164311%28v=vs.80%29.aspx

屏幕截图(来自您的链接)显示“2.0”,这意味着它可能是一个包装器:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\msbuild.exe

................................

当您有一个包装 msbuild.exe 的自定义任务时......希望您能找到该自定义任务的源代码。这将讲述(自定义任务的)实现者实际“编码”的内容。

我在自定义任务中发现,实现者将放入大部分/部分整体属性,但不是全部。

哪个(如果你能掌握原始来源),你可以获得代码并根据需要添加额外的属性。

................................

如果您无法获得源代码.........然后使用反射器(我喜欢 ILSpy)查看可在您的任务中设置的属性。 (如果您的自定义任务是用 java 编写的,则为 java 等价物)

……请记住,归根结底,自定义任务只是命令行的 super 包装器。您在自定义任务上设置属性,任务代码将其放入命令行形式。对此持保留态度,但这通常是命令行工具包装器所做的。我没有看到原始源代码,但我强烈猜测这就是正在发生的事情。

编辑:

获取源码:

当前位置:

http://www.gtlib.gatech.edu/pub/apache//ant/antlibs/dotnet/source/apache-ant-dotnet-1.1-src.zip

或从这里:

http://ant.apache.org/antlibs/srcdownload.cgi

弄清楚源代码在做什么。

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.ant.dotnet.build;

import java.io.File;
import java.util.List;

import org.apache.ant.dotnet.util.CollectionUtils;

import org.w3c.dom.DocumentFragment;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
* Runs a MSBuild build process.
*/
public class MSBuildTask extends AbstractBuildTask {

private static final String TARGET = "generated-by-ant";
private static final String ROOT = "Project";
private static final String MSBUILD_NS =
"http://schemas.microsoft.com/developer/msbuild/2003";

public MSBuildTask() {
super();
}

protected String getExecutable() {
return "MSBuild.exe";
}

protected String[] getBuildfileArguments(File buildFile) {
if (buildFile != null) {
return new String[] {
buildFile.getAbsolutePath()
};
} else {
return new String[0];
}
}

protected String[] getTargetArguments(List targets) {
if (targets.size() > 0) {
StringBuffer sb = new StringBuffer("/target:");
sb.append(CollectionUtils.flattenToString(targets, ";"));
return new String[]{sb.toString()};
} else {
return new String[0];
}
}

protected String[] getPropertyArguments(List properties) {
if (properties.size() > 0) {
StringBuffer sb = new StringBuffer("/property:");
sb.append(CollectionUtils.flattenToString(properties, ";"));
return new String[]{sb.toString()};
} else {
return new String[0];
}
}

/**
* Turn the DocumentFragment into a DOM tree suitable as a build
* file when serialized.
*
* <p>If we have exactly one <Project> child, return that.
* Otherwise if we have only <Task> children, wrap them into a
* <Target> which in turn gets wrapped into a <Project>.
* Otherwise, fail.</p>
*/
protected Element makeTree(DocumentFragment f) {
NodeList nl = f.getChildNodes();
if (nl.getLength() == 1
&& nl.item(0).getNodeType() == Node.ELEMENT_NODE
&& nl.item(0).getNodeName().equals(ROOT)) {
return (Element) nl.item(0);
} else {
Element p = f.getOwnerDocument().createElementNS(MSBUILD_NS,
ROOT);
p.setAttribute("DefaultTargets", TARGET);

Element t = f.getOwnerDocument().createElementNS(MSBUILD_NS,
"Target");
t.setAttribute("Name", TARGET);

p.appendChild(t);
t.appendChild(f);
return p;
}
}
}

关于java - Ant .NET 库文档? (设置控制台记录器参数),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20207693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com