Skip to content

[MNG-8535] Embedded launcher can't capture Maven 4 output #9907

@jira-importer

Description

@jira-importer

Stefan Oehme opened MNG-8535 and commented

We have a lot of tests capturing and validating the output of Maven builds and use an embedded launcher by default to make our tests fast. With Maven 4 and CliNG, our embedder can no longer capture Maven's output. At first I thought there was something wrong with our embedder, but I can reproduce this with the EmbeddedMavenExecutor provided by the Maven team as well:

 

public static void main(String[] args) {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    new EmbeddedMavenExecutor(false).execute(ExecutorRequest
        .mavenBuilder(Paths.get("/path/to/apache-maven-4.0.0-rc-3-SNAPSHOT"))
        .cwd(Paths.get("/path/to/simple-project"))
        .argument("package")
        .stdoutConsumer(out)
        .build()
    );
    System.out.println("Output was: " + out);
} 

The above program should capture Maven's output, but actually the output is dumped directly to the console and the out variable remains empty.

 

This puzzled me, because the embedded launcher does replace System.out and System.err, so it looks like it should work. After some digging I found out that this is because of JLine. It doesn't use System.out or System.err, but instead writes directly to the underlying filedescriptors 

Please provide a way to capture Maven 4's output with the embedded launcher, like we used to be able with Maven 3.


Affects: 4.0.0-rc-3

Remote Links:

1 votes, 4 watchers

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpriority:majorMajor loss of function

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions