Example output for a normal build on Travis CI using Gradle:
https://travis-ci.org/2m/gradle-travis-test/builds/8579228
Gradle seems to think that the console has the same capabilities as a normal ANSI console, while in reality it only supports some of those features. Specifically, it seems to support colors, but not updating/replacing text (it's append-only).
How can I tell Gradle to use "plain" console output?
Gradle automatically detects the terminal type based on the $TERM environment variable (and a few other layers in between). Setting TERM=dumb causes Gradle to use plain console output.
In your .travis.yml file, you should now have something like the following (assuming the Gradle wrapper is used):
install:
- TERM=dumb ./gradlew assemble
script:
- TERM=dumb ./gradlew check
For sample output, see this build:
https://travis-ci.org/embarkmobile/zxing-android-minimal/builds/9639517
The solution of Ralf stopped working for me. Instead I'm now doing:
env:
- TERM=dumb
script:
- ./gradlew assemble -x test
Related
I've started a new project of SprintBoot and Kotlin and I wanted to use Travis-CI as my CI server.
I also wanted to use codecov to collect the reports about my code coverage
Everything seems to work perfectly beside one thing, My project currently is an empty SpringBoot project that contains (and no tests) and the build itself takes up to 2m (mostly due to the time it takes to install Gradle).
I checked on their site and saw some optimizations to the build, but they're looked to early for this stage of the project (e.g. parallel tests execution).
Am I missing something? is 2m is the baseline for Travis-CI building time?
My current configurations for Travis :
# This enables the 'defaults' to test java applications:
language: java
# We can specify a list of JDKs to be used for testing
# A list of available JDKs in Trusty can be seed in:
# https://docs.travis-ci.com/user/reference/xenial/#jvm-clojure-groovy-java-scala-support
jdk:
- openjdk11
before_script:
# makes sure that gradle commands can be executed on build
- chmod +x gradlew
script:
# Makes sure that gradle can be executed.
- ./gradlew check
# Generates the reports for codecov
- ./gradlew jacocoTestReport
# This is to enable CodeCov's coverage
# If a build is successful, the code is submitted for coverage analysis
after_success:
- bash <(curl -s https://codecov.io/bash)
You'll want to cache to improve speeds of your build on Travis. Gradle has a dedicated guide on building on Travis: https://guides.gradle.org/executing-gradle-builds-on-travisci/
For caching, scroll down to Enable caching of downloaded artifacts
On my Linux machine in my root project directory I have the Gradle Wrapper
Project
|
+ src
|
+ gradlew
and when I run any command with gradlew there is no output, like for example when I print the version, there is no version printed
./gradlew --version
or when I check tasks, no tasks are displayed
./gradlew --tasks
or when I try to build the project, no out/ directory is created
./gradlew deploy
but when I click
Build > Build Project
in my Intellij IDE, the project does build, just not when I try to use Gradle from the command line.
So I have no idea what's going on with my gradle wrapper. Am I using the wrapper incorrectly?
My gradle wrapper which is just a Bash script, was empty ... somehow it's contents were deleted, so the script was running and nothing was happening. Good times.
It happened to me as well, the script was totally empty. The fix for me was to go to the gradle tab in IntelliJ and click on "Wrapper" under "Build setup".
After this my gradlew script got properly initialized.
I am trying to build a console based application but whenver I run
./gradlew run
I get thr progress bar which looks like this:
<=========----> 75% EXECUTING [29s]
Is there anyway I can remove this bar (which hangs out until the application ends)? Or is there a better way to write console base applications with gradle?
The version is 4.3.1
You can configure the Gradle log format using console command line parameter, as described here : https://docs.gradle.org/current/userguide/command_line_interface.html#rich_console
Try with : ./gradlew run --console=plain
Another way of doing this seems to be by setting the TERM environment variable to dumb.
Try TERM=dumb ./gradlew run
To make it a default behavior, add org.gradle.console=plain to gradle.properties file (prerequisite Gradle version is more than 4.x).
For one time execution add --console=plain flag to your command.
I know your question is specific to using the gradle wrapper, but if you're using the Gradle Tooling API, you can control the color output via
setColorOutput. Combined with the --quiet argument (set via withArguments), this results in plain-text output.
Along the lines of this answer (which works for me, BTW) and the javadocs, I tried
gradle.startParameter.consoleOutput = org.gradle.api.logging.configuration.ConsoleOutput.Rich
in my ~/.gradle/init.gradle. However, I still need --console=rich to get color output. Why?
Tested with Gradle 2.14.1 and 3.2.1.
Terminal is cygwin urxvt with TERM variable set to rxvt-unicode-256color.
Since Gradle 4.3 you can use org.gradle.console property in gradle.properties:
org.gradle.console=rich
A new console verbose mode will print outcomes of all tasks (like UP-TO-DATE) like Gradle 3.5 and earlier did. You can set this via --console=verbose or by a new Gradle property org.gradle.console=(plain rich verbose).
I am not sure if you can force the rich console from a gradle script, as the detection happens likely before the script is interpreted.
NativeServices class provides the integration with the console. If you look at the source code, there are two messages possibly printed in log:
Native-platform terminal integration is not available. Continuing with fallback.
Unable to load from native-platform backed ConsoleDetector. Continuing with fallback.
The latter might give you more information why. Try running the gradle script with --debug. You will likely find out that you are missing a native library that is either not available in cygwin or it is, but is not on library path.
I believe it works when you specify the rich console from the command line, because gradle forces the colours even though the console doesn't indicate it supports them.
Does it work if you don't use the cygwin console in Windows native command line or maybe GitBash?
There is a workaround how you can make this work. You can create an alias in cygwin that will always add the --console=rich.
If you are using gradle wrapper, you can edit the gradlew script and add the command line parameter. To make it automated, you can change the wrapper task to alter your script in the doLast part.
Create a file called gradle.properties inside your ~/.gradle/ folder.
Inside gradle.properties, add the line org.gradle.console=rich.
Each builds will run under --console=rich automatically because the new gradle.properties will be merged with the gradle.properties of your project.
If your project's gradle.properties contains the same tag as the local file, your project's will be used overriding the local file's
If you are on Linux/Mac set
alias gradle='gradle --console rich'
in your ~/.bashrc.
In Gradle Wrapper, add the following line:
org.gradle.console=rich
to ./gradle.properties in the root folder, where the gradlew script is located.
No matter what I write to .travis.yml Travis CI always executes ./gradlew assemble. I would like to run ./gradlew test instead.
Contents of my .travis.yml:
language: java
script:
- ./gradlew test
Feel free to fix my failed build:
https://github.com/RadoBuransky/scala-struct
The script ./gradle assemble is run as part of the install section of your build, it's the default.
If you want to skip this step, you can override it like so:
install: true
Docs: https://docs.travis-ci.com/user/customizing-the-build/#Skipping-the-Installation-Step