我有一个单独的javascript前端项目,它带有自己的package.json。我希望将这个项目集成到我的leiningen构建中,这样就不需要额外的设置(例如安装node和npm)。通常构建工具(如Maven或gradle)提供下载某个节点版本+ npm的插件,安装所有依赖项,然后运行脚本来构建javascript项目。 leiningen有这样的插件吗?
答案 0 :(得分:1)
由于没有人愿意回答,我最终使用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>