Migrate frontend-maven-plugin from maven to gradle

前端 未结 2 1138
自闭症患者
自闭症患者 2021-02-05 12:07

I have a com.github.eirslett:frontend-maven-plugin in my maven project.


    com.github.eirslett         


        
2条回答
  •  盖世英雄少女心
    2021-02-05 12:36

    You may not find any example on how to use the frontend-maven-plugin in Gradle, as it is dedicated to Maven. But you may take a look at the Siouan Frontend Gradle plugin, which is an equivalent solution for Gradle, and allows to (from official website):

    Integrate your frontend NPM/Yarn build into Gradle.

    The usage and configuration seems close to your Maven configuration. Define the Node/NPM/Yarn version in your build.gradle file, link the scripts you want to be run depending on the Gradle lifecycle task (clean/assemble/check), and that's all. Below is a typical usage under Gradle 5.4 with NPM, taken from the docs:

    // build.gradle
    plugins {
        id 'org.siouan.frontend' version '1.1.0'
    }
    
    frontend {
        nodeVersion = '10.15.3'
        // See 'scripts' section in your 'package.json file'
        cleanScript = 'run clean'
        assembleScript = 'run assemble'
        checkScript = 'run check'
    }
    

    You'll notice:

    • Contrary to the frontend-maven-plugin, there's no declaration/configuration to trigger the frontend build with Gradle, as it is already provided out of the box. The download, installation of Node/NPM/Yarn requires no declaration/configuration - except the version numbers, as well as the build tasks. Just provide the NPM/Yarn command line to clean/assemble/check your frontend.
    • The mimimum supported version of Node shall be 6.2.1. So your initial configuration with 4.2.4 will require to migrate Node.
    • The plugin does not support Bower, and I don't think it will be supported in the future, as Bower now encourages migration to Yarn. You'll find a migration guide on Bower's website.
    • The plugin does not support the use of a specific NPM release. NPM being now packaged with Node, the plugin uses the version embedded in the downloaded Node distribution.

    Regards

提交回复
热议问题