Skip to content

Commit

Permalink
Merge pull request #572 from jcarsique/master
Browse files Browse the repository at this point in the history
add failOnError and integration-test support
  • Loading branch information
eirslett committed Mar 1, 2017
2 parents db2e984 + 39bcb48 commit 7c7f71e
Show file tree
Hide file tree
Showing 11 changed files with 429 additions and 336 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -6,3 +6,4 @@ target
.project
.metadata
.recommenders
bin
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## Changelog

### 1.4

* Add maven.frontend.failOnError and maven.test.failure.ignore flags to best manage integration-test

### 1.3

* Fix `yarn` for Windows
Expand Down
28 changes: 26 additions & 2 deletions README.md
Expand Up @@ -52,7 +52,7 @@ Include the plugin as a dependency in your Maven project. Change `LATEST_VERSION

## Usage

Have a look at the [example project](https://github.com/eirslett/frontend-maven-plugin/tree/master/frontend-maven-plugin/src/it/example%20project),
Have a look at the [example project](frontend-maven-plugin/src/it/example%20project),
to see how it should be set up: https://github.com/eirslett/frontend-maven-plugin/blob/master/frontend-maven-plugin/src/it/example%20project/pom.xml

- [Installing node and npm](#installing-node-and-npm)
Expand All @@ -71,6 +71,7 @@ to see how it should be set up: https://github.com/eirslett/frontend-maven-plugi
- [Installation Directory](#installation-directory)
- [Proxy Settings](#proxy-settings)
- [Environment variables](#environment-variables)
- [Ignoring Failure](#ignoring-failure)
- [Skipping Execution](#skipping-execution)

**Recommendation:** _Try to run all your tasks via npm scripts instead of running bower, grunt, gulp etc. directly._
Expand Down Expand Up @@ -191,6 +192,7 @@ By default, colors will be shown in the log.
**Notice:** _Remember to gitignore the `node_modules` folder, unless you actually want to commit it. Npm packages will
always be installed in `node_modules` next to your `package.json`, which is default npm behavior._


### Running yarn

As with npm above, all node packaged modules will be installed in the `node_modules` folder in your [working directory](#working-directory).
Expand Down Expand Up @@ -445,6 +447,28 @@ tag of an execution like this:
</configuration>
```

#### Ignoring Failure

**Ignoring failed tests:** If you want to ignore test failures in specific execution you can set that using the property `maven.test.failure.ignore` in configuration tag of an execution like this:

```xml
<configuration>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
</configuration>
```

If you want to generally ignore tests run maven with the `-Dmaven.test.failure.ignore=true` flag, test/integration-test results will not stop the build.

**Ignoring other failures:** If you need to ignore other failures you can set that using the property `maven.frontend.failOnError` in configuration tag of an execution like this:

```xml
<configuration>
<maven.frontend.failOnError>true</maven.frontend.failOnError>
</configuration>
```

If you want to ignore all failures run maven with the `-Dmaven.frontend.failOnError=true` flag.

#### Skipping Execution

Each frontend build tool and package manager allows skipping execution.
Expand Down Expand Up @@ -476,7 +500,7 @@ these are set they check for changes in your source files before being run. See
## Helper scripts

During development, it's convenient to have the "npm", "bower", "grunt", "gulp" and "karma" commands
available on the command line. If you want that, use [those helper scripts](https://github.com/eirslett/frontend-maven-plugin/tree/master/frontend-maven-plugin/src/it/example%20project/helper-scripts)!
available on the command line. If you want that, use [those helper scripts](frontend-maven-plugin/src/it/example%20project/helper-scripts)!

## To build this project:

Expand Down
261 changes: 132 additions & 129 deletions frontend-maven-plugin/pom.xml
@@ -1,149 +1,152 @@
<?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>
<parent>
<artifactId>frontend-plugins</artifactId>
<groupId>com.github.eirslett</groupId>
<version>1.4-SNAPSHOT</version>
</parent>
<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>
<parent>
<artifactId>frontend-plugins</artifactId>
<groupId>com.github.eirslett</groupId>
<version>1.4-SNAPSHOT</version>
</parent>

<artifactId>frontend-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<artifactId>frontend-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>

<name>Maven Frontend Plugin</name>
<prerequisites>
<maven>3.1.0</maven>
</prerequisites>
<name>Maven Frontend Plugin</name>
<prerequisites>
<maven>3.1.0</maven>
</prerequisites>

<description>
<description>
This Maven plugin lets you install Node/NPM locally
for your project, install dependencies with NPM,
install dependencies with bower or jspm, run Grunt or gulp tasks,
and/or run Karma tests.
</description>

<dependencies>
<dependency>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-plugin-core</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependencies>
<dependency>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-plugin-core</artifactId>
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.1.0</version>
</dependency>

<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
</dependency>

<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
</dependency>
</dependencies>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<phase>process-classes</phase>
<goals>
<goal>descriptor</goal>
</goals>
<configuration>
<goalPrefix>frontend</goalPrefix>
</configuration>
</execution>
</executions>
</plugin>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<id>mojo-descriptor</id>
<phase>process-classes</phase>
<goals>
<goal>descriptor</goal>
</goals>
<configuration>
<goalPrefix>frontend</goalPrefix>
</configuration>
</execution>
</executions>
</plugin>

<!-- For the integration test -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>mrm-maven-plugin</artifactId>
<version>1.0-beta-2</version>
<executions>
<execution>
<goals>
<goal>start</goal>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<propertyName>repository.proxy.url</propertyName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>2.0.0</version>
<!-- For the integration test -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>mrm-maven-plugin</artifactId>
<version>1.0-beta-2</version>
<executions>
<execution>
<goals>
<goal>start</goal>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<propertyName>repository.proxy.url</propertyName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>2.0.0</version>

<configuration>
<debug>true</debug>
<projectsDirectory>src/it</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<settingsFile>src/it/settings.xml</settingsFile>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<streamLogs>true</streamLogs>
<postBuildHookScript>verify</postBuildHookScript>
<filterProperties>
<repository.proxy.url>${repository.proxy.url}</repository.proxy.url>
</filterProperties>
</configuration>
<configuration>
<debug>true</debug>
<projectsDirectory>src/it</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<settingsFile>src/it/settings.xml</settingsFile>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<streamLogs>true</streamLogs>
<postBuildHookScript>verify</postBuildHookScript>
<filterProperties>
<repository.proxy.url>${repository.proxy.url}</repository.proxy.url>
</filterProperties>
</configuration>

<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>install</goal>
<goal>run</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>install</goal>
<goal>run</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>Skip tests</id>
<activation>
<property><name>skipTests</name></property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<skipInvocation>true</skipInvocation>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<profiles>
<profile>
<id>Skip tests</id>
<activation>
<property>
<name>skipTests</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<skipInvocation>true</skipInvocation>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
@@ -0,0 +1 @@
invoker.goals = clean verify
3 changes: 3 additions & 0 deletions frontend-maven-plugin/src/it/example project/package.json
Expand Up @@ -26,6 +26,9 @@
},
"scripts": {
"prebuild": "npm install",
"pre-test": "echo pre-integration-test-success",
"test": "return 1",
"post-test": "echo post-integration-test-success",
"build": "gulp"
}
}

0 comments on commit 7c7f71e

Please sign in to comment.