nxrocks: [Bug] Nx fails to cache all the logs generated by @nxrocks/nx-spring-boot

Plugin Name

@nxrocks/nx-spring-boot

Plugin Version

4.1.0

Nx Version

13.8.1

Expected Behaviour

Running an nx-cacheable task twice should render the same logs in the terminal when using the executor @nxrocks/nx-spring-boot:*.

Actual Behaviour

Logs generated by @nxrocks/nx-spring-boot:build are not cached.

Steps to reproduce the behaviour

Using the executor @nxrocks/nx-spring-boot:build

Consider this Nx task:

    "build": {
      "executor": "@nxrocks/nx-spring-boot:build",
      "options": {
        "root": "libs/shared/data-access-java"
      }
    },
  1. Clear the nx cache: nx clear-cache
  2. Run the task
$ nx run shared-data-access-java:build

> nx run shared-data-access-java:build

Executing command: ./mvnw package 
Warning: JAVA_HOME environment variable is not set.
plop
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------< org.sagebionetworks.challenge:data-access-java >-----------
[INFO] Building data-access-java 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ data-access-java ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ data-access-java ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ data-access-java ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /workspaces/challenge-registry/libs/shared/data-access-java/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ data-access-java ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ data-access-java ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) @ data-access-java ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.823 s
[INFO] Finished at: 2022-06-26T16:52:49Z
[INFO] ------------------------------------------------------------------------

 —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target build for project shared-data-access-java (2s)
  1. Run the task again:
$ nx run shared-data-access-java:build

> nx run shared-data-access-java:build  [existing outputs match the cache, left as is]

Executing command: ./mvnw package 

 —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target build for project shared-data-access-java (15ms)
 
   Nx read the output from the cache instead of running the command for 1 out of 1 tasks.

The logs generated by the Maven wrapper have not been captured by Nx.

Building using Maven directly (without using @nxrocks/nx-spring-boot)

Consider this Nx task that builds the same project as above:

    "build": {
      "executor": "@nrwl/workspace:run-commands",
      "options": {
        "command": "./mvnw package",
        "cwd": "libs/shared/data-access-java"
      }
    },
  1. Clear the nx cache: nx clear-cache
  2. Run the task
$ nx run shared-data-access-java:build

> nx run shared-data-access-java:build

Warning: JAVA_HOME environment variable is not set.
plop
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------< org.sagebionetworks.challenge:data-access-java >-----------
[INFO] Building data-access-java 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ data-access-java ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ data-access-java ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ data-access-java ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /workspaces/challenge-registry/libs/shared/data-access-java/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ data-access-java ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ data-access-java ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) @ data-access-java ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.761 s
[INFO] Finished at: 2022-06-26T16:56:43Z
[INFO] ------------------------------------------------------------------------

 —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target build for project shared-data-access-java (2s)
  1. Run the task again.
$ nx run shared-data-access-java:build

> nx run shared-data-access-java:build  [existing outputs match the cache, left as is]

Warning: JAVA_HOME environment variable is not set.
plop
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------< org.sagebionetworks.challenge:data-access-java >-----------
[INFO] Building data-access-java 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ data-access-java ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ data-access-java ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ data-access-java ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory /workspaces/challenge-registry/libs/shared/data-access-java/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ data-access-java ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ data-access-java ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) @ data-access-java ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.761 s
[INFO] Finished at: 2022-06-26T16:56:43Z
[INFO] ------------------------------------------------------------------------

 —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Successfully ran target build for project shared-data-access-java (16ms)
 
   Nx read the output from the cache instead of running the command for 1 out of 1 tasks.

This time the logs of the cached task have been properly captured by Nx.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (6 by maintainers)

Commits related to this issue

Most upvoted comments

I confirm that upgrading to the latest release of the plugin fixes the issue for tasks executed with Maven and Gradle.

FYI, as I suspected, that option did the trick:

One difference that I noticed that may be relevant, is that built-in run-command executor, uses a special option “outputCapture”: “pipe”, maybe something I will continue investigating…