Skip to content

Commit

Permalink
Merge branch 'master' into fix_#657_add_proxy_environment_variables_f…
Browse files Browse the repository at this point in the history
…or_npm_postinstalls
  • Loading branch information
eirslett authored Jun 27, 2023
2 parents d059da0 + 26740c8 commit 374f2be
Show file tree
Hide file tree
Showing 97 changed files with 12,432 additions and 485 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build

on: [push, pull_request, workflow_dispatch]

jobs:
build:
name: "Run build"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]

steps:
- name: Git checkout
uses: actions/checkout@v3
- name: Use cache
uses: actions/cache@v3
with:
path: ~/.m2
key: "${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}"
restore-keys: |
${{ runner.os }}-maven3-
- name: Configure Java
uses: actions/setup-java@v3
with:
java-version: "8"
distribution: temurin
- name: "Run Maven"
shell: bash
run: mvn clean install --batch-mode -PintegrationTests -DintegrationTestProfiles=it-${{ runner.os }}
- name: "Deploy"
if: github.repository_owner == 'eirslett' && github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-latest'
shell: bash
env:
GPG_KEY: ${{ secrets.GPG_KEY }}
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
OSSRH_JIRA_USERNAME: ${{ secrets.OSSRH_JIRA_USERNAME }}
OSSRH_JIRA_PASSWORD: ${{ secrets.OSSRH_JIRA_PASSWORD }}
run: |
export GPG_TTY=$(tty)
echo -e "$GPG_KEY" | gpg --import --passphrase $GPG_PASSPHRASE --batch --yes
mvn --settings settings-github.xml -B deploy -Prelease -DskipTests
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ target
.metadata
.recommenders
bin
travis/codesigning.asc
frontend-plugin-core/target
frontend-maven-plugin/target

#macOS
.DS_Store
.vscode
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

41 changes: 40 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,46 @@ Last public release: [![Maven Central](https://maven-badges.herokuapp.com/maven-

## Changelog

### 1.12.1

* update Dependency: Jackson (2.13.0), Mockito (4.1.0), JUnit (5.8.1), Hamcrest (2.2; now a direct dependency)
* remove Dependency: Powermock
* Added better support for Yarn 2.x and above (Berry)

### 1.11.4
* Support node arm64 binaries since v16 major release

### 1.11.1

* Fix wrong binary on AIX downloaded ([#839])

### 1.11.0

* Upgrade Jackson dependency to Jackson 2.9.10
* Support Apple Silicon

### 1.10.2

* Supports Alpine Linux

### 1.9.0

* Copy npm scripts, so they are available for execution ([#868](https://github.com/eirslett/frontend-maven-plugin/pull/868))
* Regression bug fix (tar files) ([#864](https://github.com/eirslett/frontend-maven-plugin/pull/864))
* Fix bug related to archive extraction on case-insensitive file systems ([#845](https://github.com/eirslett/frontend-maven-plugin/pull/843))
* Regression bug fix (tar files) ([#816](https://github.com/eirslett/frontend-maven-plugin/pull/816))
* Added support for Raspbian OS armv7l architecture ([#809](https://github.com/eirslett/frontend-maven-plugin/pull/809))

### 1.8.0

* The plugin always logs output from npm/runners as INFO, not WARN or ERROR.
* Support for quirky Windows handling of PATH environment variables.

### 1.7.6

* Fix #670: Plugin will no longer fail to install node.exe if node.exe already exists
* Fix #794: Plugin will self-repair if previous node/npm/yarn archive download was interrupted

### 1.5

* Revert support for the maven.frontend.failOnError flag ([#572](https://github.com/eirslett/frontend-maven-plugin/pull/572)), due to
Expand Down Expand Up @@ -58,4 +98,3 @@ failOnError-like behavior can be implemented by ignoring exit codes;
* Set paths in npm helper scripts so child node processes can be spawned
* Updated README with example for maven 2
* Fix #322: Use proxies more correctly

108 changes: 93 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ running common javascript tasks such as minification, obfuscation, compression,

## Requirements

* _Maven 3_ and _Java 1.7_
* _Maven 3.6_ and _Java 1.8_
* For _Maven 2_ support take a look at the [wiki](https://github.com/eirslett/frontend-maven-plugin/wiki#maven-2).

## Installation
Expand Down Expand Up @@ -85,15 +85,17 @@ present).
```xml
<plugin>
...
<execution>
<!-- optional: you don't really need execution ids, but it looks nice in your build log. -->
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<!-- optional: default phase is "generate-resources" -->
<phase>generate-resources</phase>
</execution>
<executions>
<execution>
<!-- optional: you don't really need execution ids, but it looks nice in your build log. -->
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<!-- optional: default phase is "generate-resources" -->
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<nodeVersion>v4.6.0</nodeVersion>

Expand All @@ -106,21 +108,23 @@ present).
</plugin>
```

You can also specify separate download roots for npm and node as they are stored in separate repos.
You can also specify separate download roots for npm and node as they are stored in separate repos. In case the root configured requires authentication, you can specify a server ID from your maven settings file:

```xml
<plugin>
...
<configuration>
<!-- optional: where to download node from. Defaults to https://nodejs.org/dist/ -->
<nodeDownloadRoot>http://myproxy.example.org/nodejs/</nodeDownloadRoot>
<!-- optional: credentials to use from Maven settings to download node -->
<serverId>server001</serverId>
<!-- optional: where to download npm from. Defaults to https://registry.npmjs.org/npm/-/ -->
<npmDownloadRoot>https://myproxy.example.org/npm/</npmDownloadRoot>
</configuration>
</plugin>
```

You can use Nexus repository Manager to proxy npm registries. See https://books.sonatype.com/nexus-book/reference/npm.html
You can use Nexus repository Manager to proxy npm registries. See https://help.sonatype.com/display/NXRM3/Npm+Registry

**Notice:** _Remember to gitignore the `node` folder, unless you actually want to commit it._

Expand All @@ -135,6 +139,10 @@ Node/Yarn will only be "installed" locally to your project.
It will not be installed globally on the whole system (and it will not interfere with any Node/Yarn installations already
present).

If your project is using Yarn Berry (2.x or above), the Yarn version is handled per project but a Yarn 1.x install is still needed as a "bootstrap".
The plugin will try to detect `.yarnrc.yml` file in the current Maven project/module folder, at the root of the multi-module project if relevant, and in the folder from which the `mvn` command was run.
If detected, the plugin will assume your project is using Yarn Berry. It will install the 1.x Yarn version you specify with `yarnVersion` as bootstrap, then hand over to your project-specific version.

Have a look at the example `POM` to see how it should be set up with Yarn:
https://github.com/eirslett/frontend-maven-plugin/blob/master/frontend-maven-plugin/src/it/yarn-integration/pom.xml

Expand Down Expand Up @@ -191,12 +199,29 @@ 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._

#### npx

You can also use [`npx` command](https://blog.npmjs.org/post/162869356040/introducing-npx-an-npm-package-runner), enabling you to execute the CLI of installed packages without a run-script, or even packages that aren't installed at all.

```xml
<execution>
<id>say hello</id>
<goals>
<goal>npx</goal>
</goals>

<phase>generate-resources</phase>

<configuration>
<arguments>cowsay hello</arguments>
</configuration>
</execution>
```

### Running yarn

As with npm above, all node packaged modules will be installed in the `node_modules` folder in your [working directory](#working-directory).


```xml
<execution>
<id>yarn install</id>
Expand All @@ -213,6 +238,42 @@ As with npm above, all node packaged modules will be installed in the `node_modu
</execution>
```

#### Yarn with Private Registry

NOTE: if you have a private npm registry that mirrors the npm registry, be aware that yarn.lock
includes URLs to the npmjs.org module registry and yarn install will use these paths when installing modules.

If you want yarn.lock to use your private npm registry, be sure to run these commands on your local machine before you generate yarn.lock:
```
yarn config set registry <your_registry_url>
yarn install
```
This will create URLs in your yarn.lock file that reference your private npm registry.

Another way to set a registry is to add a .npmrc file in your project's root directory that contains:
```
registry=<your_registry_url>
```

Also you can set a registry using a tag `npmRegistryURL`
```
<execution>
<id>yarn install</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<!-- optional: The default argument is actually
"install", so unless you need to run some other yarn command,
you can remove this whole <configuration> section.
-->
<arguments>install</arguments>
<!-- optional: where to download npm modules from. Defaults to https://registry.yarnpkg.com/ -->
<npmRegistryURL>http://myregistry.example.org/</npmRegistryURL>
</configuration>
</execution>
```

### Running bower

All bower dependencies will be installed in the `bower_components` folder in your working directory.
Expand Down Expand Up @@ -406,7 +467,7 @@ If you have [configured proxy settings for Maven](http://maven.apache.org/guides
in your settings.xml file, the plugin will automatically use the proxy for downloading node and npm, as well
as [passing the proxy to npm commands](https://docs.npmjs.com/misc/config#proxy).

**Non Proxy Hosts:** npm does not currently support non proxy hosts - if you are using a proxy and npm install is
**Non Proxy Hosts:** npm does not currently support non proxy hosts - if you are using a proxy and npm install
is not downloading from your repository, it may be because it cannot be accessed through your proxy.
If that is the case, you can stop the npm execution from inheriting the Maven proxy settings like this:

Expand All @@ -426,6 +487,22 @@ If that is the case, you can stop the bower execution from inheriting the Maven
</configuration>
```

If you want to disable proxy for Yarn you can use `yarnInheritsProxyConfigFromMaven`. When you have proxy settings in your settings.xml file if you don't use this param it will run code below with proxy settings, in some cases you don't want that. Adding this param into the configuration section will solve this issue

```xml
<execution>
<id>tests</id>
<goals>
<goal>yarn</goal>
</goals>
<phase>compile</phase>
<configuration>
<yarnInheritsProxyConfigFromMaven>false</yarnInheritsProxyConfigFromMaven>
<arguments>run test</arguments>
</configuration>
</execution>

```


#### Environment variables
Expand All @@ -452,7 +529,7 @@ tag of an execution like this:

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

Expand Down Expand Up @@ -502,3 +579,4 @@ You can find a full list of [contributors here](https://github.com/eirslett/fron
## License

[Apache 2.0](LICENSE)

32 changes: 32 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

version: '{build}'
skip_tags: true
clone_depth: 10
environment:
MAVEN_VERSION: 3.5.4
matrix:
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- JAVA_HOME: C:\Program Files\Java\jdk11
install:
- ps: |
Add-Type -AssemblyName System.IO.Compression.FileSystem
if (!(Test-Path -Path "C:\maven" )) {
Write-Host "Downloading Maven $env:MAVEN_VERSION"
(new-object System.Net.WebClient).DownloadFile("http://apache.rediris.es/maven/maven-3/$env:MAVEN_VERSION/binaries/apache-maven-$env:MAVEN_VERSION-bin.zip", 'C:\maven-bin.zip')
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\maven-bin.zip", "C:\maven")
}
- cmd: SET M2_HOME=C:\maven\apache-maven-%MAVEN_VERSION%
# Prepend Java entry, remove Ruby entry (C:\Ruby193\bin;) from PATH
- cmd: SET PATH=%M2_HOME%\bin;%JAVA_HOME%\bin;%PATH:C:\Ruby193\bin;=%;
# Required to avoid errors with JDK 8 because TSL 1.0 & 1.1 support was removed
- cmd: SET MAVEN_OPTS=-Xmx2g -Dhttps.protocols=TLSv1.2
- cmd: SET JAVA_OPTS=-Xmx2g
- cmd: mvn --version
- cmd: java -version
build_script:
- mvn clean package --batch-mode -DskipTest -Dhttps.protocols=TLSv1.2
test_script:
- mvn clean install --batch-mode
cache:
- C:\maven\ -> appveyor.yml
- C:\Users\appveyor\.m2\ -> pom.xml
Loading

0 comments on commit 374f2be

Please sign in to comment.