在 lein 构建中集成 node.js 项目
Integrate node.js project in lein build
我有一个单独的 javascript 前端项目,它有自己的 package.json。我想以不需要额外设置(例如安装节点和 npm)的方式将这个项目集成到我的 leiningen 构建中。通常构建工具,如 Maven 或 gradle 提供下载特定节点版本 + npm 的插件,安装所有依赖项,然后 运行 一个脚本来构建 javascript 项目。 leiningen有这样的插件吗?
由于没人愿意回答,我最终使用 mvn 将 node.js 和 leiningen 项目粘合在一起。我的 leiningen 项目使用 immutant war
构建,我的 node.js 项目使用 npm run build
。它使用 maven-frontend-plugin
安装节点和 npm 并执行节点构建。它使用 exec-maven-plugin
在单独的 VM 中执行 leiningen。这里是pom.xml
不包括项目信息。
<repositories>
<repository>
<id>clojars</id>
<name>Clojars</name>
<url>http://clojars.org/repo</url>
</repository>
</repositories>
<dependencies>
<!-- Taken from http://www.elangocheran.com/blog/2015/12/compiling-a-leiningen-project-from-maven/ -->
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>leiningen</groupId>
<artifactId>leiningen</artifactId>
<version>2.8.1</version>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>clojars</id>
<name>Clojars</name>
<url>http://clojars.org/repo</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v8.2.1</nodeVersion>
<npmVersion>5.3.0</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm build</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<id>lein war</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>clojure.main</argument>
<argument>-m</argument>
<argument>leiningen.core.main</argument>
<argument>immutant</argument>
<argument>war</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我有一个单独的 javascript 前端项目,它有自己的 package.json。我想以不需要额外设置(例如安装节点和 npm)的方式将这个项目集成到我的 leiningen 构建中。通常构建工具,如 Maven 或 gradle 提供下载特定节点版本 + npm 的插件,安装所有依赖项,然后 运行 一个脚本来构建 javascript 项目。 leiningen有这样的插件吗?
由于没人愿意回答,我最终使用 mvn 将 node.js 和 leiningen 项目粘合在一起。我的 leiningen 项目使用 immutant war
构建,我的 node.js 项目使用 npm run build
。它使用 maven-frontend-plugin
安装节点和 npm 并执行节点构建。它使用 exec-maven-plugin
在单独的 VM 中执行 leiningen。这里是pom.xml
不包括项目信息。
<repositories>
<repository>
<id>clojars</id>
<name>Clojars</name>
<url>http://clojars.org/repo</url>
</repository>
</repositories>
<dependencies>
<!-- Taken from http://www.elangocheran.com/blog/2015/12/compiling-a-leiningen-project-from-maven/ -->
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>leiningen</groupId>
<artifactId>leiningen</artifactId>
<version>2.8.1</version>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>clojars</id>
<name>Clojars</name>
<url>http://clojars.org/repo</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<nodeVersion>v8.2.1</nodeVersion>
<npmVersion>5.3.0</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm build</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<id>lein war</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
<argument>clojure.main</argument>
<argument>-m</argument>
<argument>leiningen.core.main</argument>
<argument>immutant</argument>
<argument>war</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>