Gradle, JS, resolver: return null if npm dependency being resolved before kotlinNpmInstall

This commit is contained in:
Sergey Rostov
2019-07-07 16:34:20 +03:00
parent 8b0dffe182
commit bcf894aba3
@@ -40,7 +40,9 @@ import java.io.File
* be treated as `packageJson` task inputs. * be treated as `packageJson` task inputs.
* *
* **package-json-created**. This state also compilation local. Initiated by executing `packageJson` * **package-json-created**. This state also compilation local. Initiated by executing `packageJson`
* task for particular compilation. * task for particular compilation. If `packageJson` task is up-to-date, this state is reached by
* first calling [KotlinCompilationNpmResolver.getResolutionOrResolveIfForced] which may be called
* by compilation that depends on this compilation.
* *
* Note that package.json will be executed only for required compilations, while other may be missed. * Note that package.json will be executed only for required compilations, while other may be missed.
* *
@@ -66,7 +68,7 @@ import java.io.File
* and [getNpmDependencyResolvedCompilation] will be called. In the [forceFullResolve] mode * and [getNpmDependencyResolvedCompilation] will be called. In the [forceFullResolve] mode
* project will be fully resolved: all `package.json` files will be created, and package manager * project will be fully resolved: all `package.json` files will be created, and package manager
* will be called. We are manually tracking package.json files contents to avoid calling package manager * will be called. We are manually tracking package.json files contents to avoid calling package manager
* is nothing was changes. * if nothing was changes.
* *
* Note that in this case resolution process will be performed outside of task execution. * Note that in this case resolution process will be performed outside of task execution.
*/ */
@@ -140,7 +142,7 @@ class KotlinNpmResolutionManager(val nodeJsSettings: NodeJsRootExtension) {
return resolution return resolution
} }
internal fun getNpmDependencyResolvedCompilation(npmDependency: NpmDependency): KotlinCompilationNpmResolution { internal fun getNpmDependencyResolvedCompilation(npmDependency: NpmDependency): KotlinCompilationNpmResolution? {
val project = npmDependency.project val project = npmDependency.project
val resolvedProject = val resolvedProject =
@@ -153,7 +155,10 @@ class KotlinNpmResolutionManager(val nodeJsSettings: NodeJsRootExtension) {
val state0 = state val state0 = state
when (state0) { when (state0) {
is ResolutionState.Installed -> state0.resolved[project] is ResolutionState.Installed -> state0.resolved[project]
is ResolutionState.Configuring -> error("Cannot use NpmDependency before :kotlinNpmInstall task execution") is ResolutionState.Configuring -> {
return null
//error("Cannot use NpmDependency before :kotlinNpmInstall task execution")
}
} }
} }