This spec describes some fixes for build progress reporting.
- Integration test coverage for artifact download and upload progress reporting.
- Correct rendering on terminals with limited width.
- Allow Gradle to work when native libraries are not present, to assist in porting Gradle to Linux distributions where these libraries do not exist.
- Progress reporting when uploading to Maven repositories.
- Add a test fixture class which, given a
GradleExecuter
, can configure the executer so that progress events are captured. - Change the implementation of
AbstractProgressLoggingHandler.logProgress()
so that progress event is generated only every n bytes (say 1k). - Add integration test cases listed below
One possible implementation for the test fixture is to have it generate an init script or build script that adds an OutputEventListener
to the
global logging manager. For example:
import org.gradle.logging.internal.*
gradle.services.get(LoggingOutputInternal).addOutputEventListener(new OutputEventListener() {
void onOutput(OutputEvent event) {
if (event instanceof ProgressStartEvent) {
println "[START $event.description]"
} else if (event instanceof ProgressEvent) {
println "[$event.status]"
} else if (event instanceof ProgressCompleteEvent) {
println "[END]"
}
}
})
This listener can write progress messages to a file and the test fixture can load these from the file.
- Change the existing test case that covers downloading from an Ivy HTTP repository to ensure progress is logged.
- Change the existing test case that covers uploading to an Ivy HTTP repository to ensure progress is logged.
- Change the existing test case that covers downloading from a Maven HTTP repository to ensure progress is logged.
- Change the existing test case that covers downloading from a custom Ivy resolver to ensure progress is logged.
- Change the existing test case that covers uploading to a custom Ivy resolver to ensure progress is logged.
- Change the existing test case that covers a failed download from a Maven HTTP repository to ensure progress is logged until the failure occurs.
Progress reporting for uploading to a Maven repository is currently not supported, so there is no test coverage for this.
For this story, the status bar text is simply trimmed at the right-hand edge of the terminal. This addresses the garbled output when the status bar text wraps at the right-hand edge, but can potentially lose useful information. Later stories will address this.
To implement this, we start migrating to the native-platform library as an eventual replacement for the jna, jna-posix and jansi libraries. The native-platform library will be used to detect the terminal and to determine the width of the terminal, falling back to jna where native-platform is not available. Jansi will continue to be used to generate the terminal output.
- Extract a
StatusBarFormatter
interface out ofConsoleBackedProgressRenderer.updateText()
, that is responsible for rendering the status bar contents. This formatter would take the stack ofOperation
objects and format this to a String for the status bar text. The formatter would be injected intoConsoleBackedProgressRenderer
. - Introduce a
ConsoleMetaData
interface that is responsible for determining the console width. Add an initial implementation for UNIX platforms that uses the$COLUMNS
environment variable, and an implementaiton for Windows that just returnsnull
. Make an instance available via theNativeServices
registry. - Change the
StatusBarFormatter
implementation to use theConsoleMetaData
service, to trim the status bar text at the console width. If the console width is not known, then do not trim the status bar text. - Add the native-platform library as a dependency for the native project. Change
NativeServices.initialize()
to initialize the native-plaformNative
class. - Add a
ConsoleDetector
implementation that is backed by native-platform'sTerminals
class. ChangeNativeServices
to use this in preference to the existing detectors whenTerminals
is available. - Add a
ConsoleMetaData
implementation that is backed by native-platforms'sTerminal
class. ChangeNativeServices
to use this in preference to the existing implementations whenTerminal
is available.
Manual testing:
- Windows. Check console is detected and status bar is trimmed when running under Windows command prompt. Check that console is not detected when running under the Cygwin terminal (this is not supported yet).
- Linux. Check terminal is detected and status bar is trimmed. Check that terminal is not used when not attached to a terminal (eg when piping output
to
cat
). - OS X. As for Linux.
- One platform currently not supported by native-platform, such as Solaris or FreeBSD.
TBD
TBD
- When the native-platform integration is stable:
- Switch to using native-platform to generate the terminal output and remove jansi.
- Switch to using native-platform for handling unix file permissions and remove jna-posix.
- Switch to using native-platform for handling the native integrations used by the daemon and remove jna.
- Improve formatting of status bar text on terminal with limited width.
- Handle terminal size changes. This will require improvements to the native-platform library.
- Handle runnng under Cygwin terminal. This will require improvements to the native-platform library.
Migration strategy for removing the existing native integrations.