Home > Enterprise >  Node Build fail after upgrade to Gradle 7.3
Node Build fail after upgrade to Gradle 7.3

Time:01-12

We have upgrade gradle from 4.8 to 7.3 after that nodeSetup build gets fail with below error.

Could not find method layout() for arguments [pattern, com.moowork.gradle.node.task.SetupTask$_addRepository_closure5$_closure7@25995910] on object of type org.gradle.api.internal.artifacts.repositories.DefaultIvyArtifactRepository.

Below are code snippet of build.gradle.

buildscript {
repositories {
    maven {
        url "https://plugins.gradle.org/m2/"
    }   
}
dependencies {
    classpath "com.moowork.gradle:gradle-node-plugin:1.3.1"
    classpath "io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE"
}
}

apply plugin: "com.moowork.node"
apply plugin: "io.spring.dependency-management"
node {
    version = "16.13.12"
    npmVersion = "6.12.0"
    download = true
    nodeModulesDir = file("/XXX")
}

CodePudding user response:

Cause: There is a breaking change in gradle 6.8 which is you can checkout here: https://docs.gradle.org/current/userguide/upgrading_version_6.html#configuring_the_layout_of_an_ivy_repository

"The 'layout' method taking a configuration block has been removed and is replaced by 'patternLayout'

Your plugin "com.moowork.gradle:gradle-node-plugin:1.3.1" is using that method which not upgraded in this library.

Solution: You can use this gradle-node-plugin instead of "com.moowork.gradle:gradle-node-plugin:1.3.1"

Installation: https://github.com/node-gradle/gradle-node-plugin/blob/master/docs/installation.md Installing the node-related plugins can be done in multiple ways. The easiest is to use the plugins-closure in your build.gradle file:

plugins {
  id "com.github.node-gradle.node" version "3.1.1"
}

You can also install the plugins by using the traditional Gradle way:

buildscript {
  repositories {
    gradlePluginPortal()
  }

  dependencies {
    classpath "com.github.node-gradle:gradle-node-plugin:3.1.1"
  }
}

apply plugin: 'com.github.node-gradle.node'
  •  Tags:  
  • Related