Skip to content

Instantly share code, notes, and snippets.

@peterhughesdev
Last active October 1, 2022 14:09
Show Gist options
  • Save peterhughesdev/f2274a9c9a5580fdfb7e to your computer and use it in GitHub Desktop.
Save peterhughesdev/f2274a9c9a5580fdfb7e to your computer and use it in GitHub Desktop.
A sample POM for building a Javascript project with Maven
<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.peterhughes.dev</groupId>
<artifactId>js-test-example</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<properties>
<compiled.name>js-example.js</compiled.name>
<src.dir>${basedir}/src/main/javascript</src.dir>
<release.dir>${basedir}/target/release</release.dir>
<jasmine.serverPort>8234</jasmine.serverPort>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>1.3.1.4</version>
</plugin>
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>1.7.2</version>
</plugin>
<plugin>
<groupId>com.github.phasebash</groupId>
<artifactId>jsdoc3-maven-plugin</artifactId>
<version>1.0.7</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>minify</goal>
</goals>
</execution>
</executions>
<configuration>
<jsEngine>CLOSURE</jsEngine>
<jsFinalFile>${compiled.name}</jsFinalFile>
<jsSourceDir>javascript</jsSourceDir>
<jsSourceIncludes>
<jsSourceInclude>**</jsSourceInclude>
</jsSourceIncludes>
<jsSourceExcludes>
<jsSourceExclude>**/*.min.js</jsSourceExclude>
</jsSourceExcludes>
<webappSourceDir>${basedir}/src/main</webappSourceDir>
<webappTargetDir>${release.dir}</webappTargetDir>
</configuration>
</plugin>
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
<configuration>
<keepServerAlive>true</keepServerAlive>
<jsSrcDir>${release.dir}</jsSrcDir>
<sourceExcludes>
<exclude>**/*.min.js</exclude>
</sourceExcludes>
<junitXmlReportFileName>TEST-jasmine.xml</junitXmlReportFileName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.phasebash</groupId>
<artifactId>jsdoc3-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jsdoc3</goal>
</goals>
</execution>
</executions>
<configuration>
<recursive>true</recursive>
<directoryRoots>
<directoryRoot>${src.dir}</directoryRoot>
</directoryRoots>
<outputDirectory>${release.dir}/doc</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>distribution-package</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${basedir}/descriptor.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment