Skip to content

Commit

Permalink
snapshot support
Browse files Browse the repository at this point in the history
refactored invoker tests
  • Loading branch information
chonton committed Feb 18, 2022
1 parent 7545f37 commit a50c102
Show file tree
Hide file tree
Showing 78 changed files with 1,164 additions and 1,433 deletions.
73 changes: 44 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,41 @@ for details on making your build reproducible.

## Goals

There are two goals: [local](https://chonton.github.io/exists-maven-plugin/0.6.0/local-mojo.html)
There are two goals: [local](https://chonton.github.io/exists-maven-plugin/0.7.0/local-mojo.html)
checks if the just built artifact is already in the local repository;
and [remote](https://chonton.github.io/exists-maven-plugin/0.6.0/remote-mojo.html) checks if the
and [remote](https://chonton.github.io/exists-maven-plugin/0.7.0/remote-mojo.html) checks if the
just built artifact is already in the remote repository.

Mojo details at [plugin info](https://chonton.github.io/exists-maven-plugin/0.6.0/plugin-info.html)
Mojo details at [plugin info](https://chonton.github.io/exists-maven-plugin/0.7.0/plugin-info.html)

## Parameters

Every parameter can be set with a maven property **exists.**_<parameter_name\>_. e.g. skip parameter
can be set from command line -Dexists.skip=true

| Parameter | Default | Description |
|--------------------|-------------------------------------------------------------|-----------------------------------------------------------------------------------------|
| artifact | ${project.artifactId}-${project.version}.{packaging} | The artifact within the project to query |
| cmpChecksum | false | Compare checksums of artifacts |
| failIfExists | false | Fail the build if the artifact already exists |
| failIfNotExists | false | Fail the build if the artifact does not exist |
| failIfNotMatch | false | Fail the build if the artifact exists and cmpChecksum is set and checksums do not match |
| project | ${project.groupId}:${project.artifactId}:${project.version} | The project within the repository to query |
| property | ${maven.deploy.skip} _or_ ${maven.install.skip} | The property to receive the result of the query |
| repository | ${project.distributionManagement.repository.url} | For remote goal, the repository to query for artifacts |
| requireGoal | | Execute goal only if requireGoal value matches one of the maven command line goals |
| serverId | ${project.distributionManagement.repository.id} | For remote goal, the server ID to use for authentication and proxy settings |
| skip | false | Skip executing the plugin |
| skipIfSnapshot | true | Skip the query if the project ends with -SNAPSHOT |
| snapshotRepository | ${project.distributionManagement.snapshotRepository.url} | For remote goal, the repository to query for snapshot artifacts |
| snapshotServerId | ${project.distributionManagement.snapshotRepository.id} | For remote goal, the server ID to use for snapshot authentication and proxy settings |
| userProperty | false | If the property should be set as a user property, to be available in child projects |
can be set from command line -Dexists.skip=true.

In the following table `p:` indicates the default constituent properties are prefixed with
`project.` and `dm:` indicates the default constituent properties are prefixed with
`project.distributionManagement.` e.g. for artifact parameter, the full default is
`${project.artifactId}-${project.version}.${project.packaging}`

| Parameter | Default | Description |
|--------------------|-----------------------------------------------------|-----------------------------------------------------------------------------------------|
| artifact | p: ${artifactId}-${version}.${packaging} | The artifact within the project to query |
| cmpChecksum | false | Compare checksums of artifacts |
| failIfExists | false | Fail the build if the artifact already exists |
| failIfNotExists | false | Fail the build if the artifact does not exist |
| failIfNotMatch | false | Fail the build if the artifact exists and cmpChecksum is set and checksums do not match |
| lastSnapshotTime | | The property to set with the timestamp of the last snapshot install / deploy |
| project | p: ${groupId}:${artifactId}:${packaging}:${version} | The project within the repository to query |
| property | ${maven.deploy.skip} _or_ ${maven.install.skip} | The property to receive the result of the query |
| repository | dm: ${repository.url} | For remote goal, the repository to query for artifacts |
| requireGoal | | Execute goal only if requireGoal value matches one of the maven command line goals |
| serverId | dm: ${repository.id} | For remote goal, the server ID to use for authentication and proxy settings |
| skip | false | Skip executing the plugin |
| skipIfSnapshot | true | Skip the query if the project ends with -SNAPSHOT |
| snapshotRepository | dm: ${snapshotRepository.url} | For remote goal, the repository to query for snapshot artifacts |
| snapshotServerId | dm: ${snapshotRepository.id} | For remote goal, the server ID to use for snapshot authentication and proxy settings |
| userProperty | false | If the property should be set as a user property, to be available in child projects |

## Requirements

Expand All @@ -63,7 +69,7 @@ can be set from command line -Dexists.skip=true
<plugin>
<groupId>org.honton.chas</groupId>
<artifactId>exists-maven-plugin</artifactId>
<version>0.6.0</version>
<version>0.7.0</version>
<executions>
<execution>
<goals>
Expand All @@ -77,14 +83,21 @@ can be set from command line -Dexists.skip=true
</build>
```

## Snapshot builds

When checking snapshot builds against a remote/local repository, the last deployed/installed
snapshot of the correct version will be matched. Optionally, you can configure a property with
the `lastSnapshotTime` parameter which will receive the build timestamp. If you need additional date
math on the timestamp value, open a feature request with your use case.

## Preventing failures of `remote` goal

Consider the scenario where there is an artifact that can only be deployed from a specific build
server to a corporate repository with a specialized workflow that ensures various security and
license policies. The exists-maven-plugin remote goal is also used to avoid duplicate deployments.

Running maven with the `install` phase will cause the exists-maven-plugin to execute the `remote`
goal. This might fail for various reasons; including the developer laptop is not connected to the
task. This might fail for various reasons; including the developer laptop is not connected to the
internet, or the corporate repository is only available to specific build machines.

We could change the binding of the `remote` goal to the `deploy` phase. However, the
Expand All @@ -94,9 +107,11 @@ specified in the POM, with inherited executions running first."](https://maven.a

The solution is to leave the `remote` goal bound to the `install` phase and add a `requireGoal`
configuration:

```xml
<configuration>
<!-- run only if deploy goal is specified in maven command ling -->
<requireGoal>deploy</requireGoal>
</configuration>
```

<configuration>
<!-- run only if deploy goal is specified in maven command ling -->
<requireGoal>deploy</requireGoal>
</configuration>
```
Loading

0 comments on commit a50c102

Please sign in to comment.