gpt4 book ai didi

gradle - 如何获得 “gradle”具有与 “ant”类似的输出详细信息?

转载 作者:行者123 更新时间:2023-12-03 06:01:22 26 4
gpt4 key购买 nike

我的问题对How can I get Gradle ant logging to work?Gradle: Get Ant Task Output问题没有答案。

我的 Ant 脚本build.xml

<project>
<target name="build">
<mkdir dir="dest"/>
<javac srcdir="src" destdir="dest" includeAntRuntime="false"/>
<copy todir="dest" >
<fileset dir="src" casesensitive="no">
<include name="**/*.properties"/>
</fileset>
</copy>
<jar destfile="MyJar.jar">
<fileset dir="dest"/>
</jar>
</target>
</project>

命令 ant build的输出有一些不错的细节
Buildfile: /some/path/build.xml

build:
[mkdir] Created dir: /some/path/dest
[javac] Compiling 25 source files to /some/path/dest
[copy] Copying 3 files to /some/path/dest
[jar] Building jar: /some/path/MyJar.jar

BUILD SUCCESSFUL
Total time: 0 seconds

简单脚本 build.gradle
ant.importBuild 'build.xml'

命令 gradle build的输出缺少一些详细信息
:build

BUILD SUCCESSFUL

Total time: 1.638 secs

我们可以注意到有关命令 mkdirjavaccopyjar的缺少行。

选项 --info太冗长
> gradle --info build
Starting Build
Settings evaluated using settings file '/master/settings.gradle'.
Projects loaded. Root project using build file '/some/path/build.gradle'.
Included projects: [root project 'o']
Evaluating root project 'o' using build file '/some/path/build.gradle'.
Compiling build file '/some/path/build.gradle' using SubsetScriptTransformer.
Compiling build file '/some/path/build.gradle' using BuildScriptTransformer.
All projects evaluated.
Selected primary task 'build' from project :
Tasks to be executed: [task ':build']
:build (Thread[main,5,main]) started.
:build
Executing task ':build' (up-to-date check took 0.001 secs) due to:
Task has not declared any outputs.
[ant:mkdir] Created dir: /some/path/dest
[ant:javac] Compiling 25 source files to /some/path/dest
[ant:copy] Copying 3 files to /some/path/dest
[ant:jar] Building jar: /some/path/MyJar.jar
:build (Thread[main,5,main]) completed. Took 0.646 secs.

BUILD SUCCESSFUL

Total time: 1.947 secs

最佳答案

如果可以帮助别人,我在这里分享我的解决方案。

这取决于Gradle的版本!

使用Gradle 2.13

在脚本build.gradle中提升任务构建(Ant目标)的日志级别:

ant.importBuild 'build.xml'
build.logging.level = LogLevel.INFO
gradle build的输出现在类似于 ant build
:build
[ant:mkdir] Created dir: /some/path/dest
[ant:javac] Compiling 25 source files to /some/path/dest
[ant:copy] Copying 3 files to /some/path/dest
[ant:jar] Building jar: /some/path/MyJar.jar

BUILD SUCCESSFUL

Total time: 1.692 secs

使用Gradle 3.2

在脚本 ant.lifecycleLogLevel = "INFO"中添加 build.gradle:

ant.importBuild 'build.xml'
ant.lifecycleLogLevel = "INFO"

命令 gradle build的输出
:build
[ant:mkdir] Created dir: /some/path/dest
[ant:javac] Compiling 25 source files to /some/path/dest
[ant:copy] Copying 3 files to /some/path/dest
[ant:jar] Building jar: /some/path/MyJar.jar

BUILD SUCCESSFUL

Total time: 0.531 secs

关于gradle - 如何获得 “gradle”具有与 “ant”类似的输出详细信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41442543/

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