1

I use the frontend-maven-plugin to run a grunt build with maven.

I have the following pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.a.b</groupId>
    <artifactId>kuku</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <!-- NB! Set <version> to the latest released version of frontend-maven-plugin, like in README.md -->
                <version>0.0.19</version>

                <executions>

                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v0.10.33</nodeVersion>
                            <npmVersion>1.4.28</npmVersion>
                        </configuration>
                    </execution>

                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <!-- Optional configuration which provides for running any npm command -->
                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                    </execution>

                    <execution>
                        <id>grunt build</id>
                        <goals>
                            <goal>grunt</goal>
                        </goals>
                        <configuration>
                            <arguments>build-nightly --no-color</arguments>
                        </configuration>
                    </execution>


                </executions>
            </plugin>
        </plugins>
    </build>
</project>

The grunt task creates a zip file which is called kuku.zip. I want to deploy this zip file to a maven repository.

There are questions on deploying zip files to maven:

Jenkins "Post Build Action" to deploy zip on Maven repository

But here the situation is different because there already a jar is created and i want to attach an additional zip file and here i don't have another artifact.

How can i achieve this task with maven?

Community
  • 1
  • 1
David Michael Gang
  • 7,107
  • 8
  • 53
  • 98

1 Answers1

0

I followed the approach of maven-assembly-plugin.

First i defined an assembly descriptor.xml

<assembly>
<formats>
    <format>zip</format>
</formats>

<fileSets>
    <fileSet>
        <directory>kuku</directory>
        <includes>
            <include>**/*</include>
        </includes>
    </fileSet>
</fileSets>
</assembly>

and here is the changed pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>a.b</groupId>
    <artifactId>kuku</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <!-- NB! Set <version> to the latest released version of frontend-maven-plugin, like in README.md -->
                <version>0.0.19</version>

                <executions>

                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v0.10.33</nodeVersion>
                            <npmVersion>1.4.28</npmVersion>
                        </configuration>
                    </execution>

                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <!-- Optional configuration which provides for running any npm command -->
                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                    </execution>

                    <execution>
                        <id>grunt build</id>
                        <goals>
                            <goal>grunt</goal>
                        </goals>
                        <configuration>
                            <arguments>build-nightly --no-color</arguments>
                        </configuration>
                    </execution>


                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptor>descriptor.xml</descriptor>
                </configuration>
                <executions> 
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
David Michael Gang
  • 7,107
  • 8
  • 53
  • 98