toolsplus / nx-forge

Atlassian Forge plugin for Nx
https://toolsplus.github.io/nx-forge/
MIT License
17 stars 4 forks source link

Configurable build target name in the package executor #117

Open tbinna opened 4 months ago

tbinna commented 4 months ago

The package executor attempts to collect the build outputs from dependent resource projects to the Forge app output path. To do so, it currently requires that all dependent projects have a build target named build. We should make this configurable because, for example, the @nx/webpack plugin has started naming its generated build target webpack:build instead of build since Nx 19.

Technically, we must assume that each dependent resource project could have its own custom build target name configuration. If the build target names are inconsistent across dependent resource projects, we should require the user to configure the package executor's resourceOutputPathMap option directly. Or is there a case for adding a buildTargetNameMap to map resource projects to different build target names?

The implementation of this issue should include two things:

  1. Make the build target name configurable, i.e., add a buildTargetName configuration to the executor configuration.
  2. The package executor calls the getResourceOutputPath method which in turn calls the getOutputsForTargetAndConfiguration method from the @nx/devkit. The @nx/devkit method throws if it cannot find the specified target. At the moment, we assume the target must be called build. We should catch the thrown error and provide a helpful error message instead. The message could either suggest configuring the build target to match the configuration from 1. or manually mapping the output path using the resourceOutputPathMap option.