GithubHelp home page GithubHelp logo

chonton / exists-maven-plugin Goto Github PK

View Code? Open in Web Editor NEW
45.0 3.0 16.0 731 KB

Check if artifact exists in remote maven repository

License: Apache License 2.0

Java 100.00%
exists maven-plugin up-for-adoption

exists-maven-plugin's Introduction

exists-maven-plugin

Check if a maven artifact exists. Designed around the use case of skipping deployment if the stable version already exists.

How This Plugin Determines if Builds are the "Same"

There are two strategies to determine if a maven artifacts are the "same" as what the project just built: version comparison, and checksum comparison. By default, this plugin uses version comparison. Version comparison simply checks if the group:artifact:version matches an artifact in the local or remote repository. This simple check will not catch the situation where the developer has failed to update the version in pom.xml.

Alternatively, when <cmpChecksum> is true, this plugin compares the checksum of the local or remote artifact with the just built artifact. Checksum comparison requires that the maven build be reproducible. Without specific configuration, maven builds are not reproducible. See Configuring for Reproducible Builds for details on making your build reproducible.

Goals

There are two goals: local checks if the just built artifact is already in the local repository; and remote checks if the just built artifact is already in the remote repository.

Mojo details at plugin info

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.

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
classifier The classifier to use for checking the repository, e.g. 'tests'
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

  • Maven 3.8.1 or later
  • Java 11 or later

Typical Use

<build>
  <plugins>

    <plugin>
      <groupId>org.honton.chas</groupId>
      <artifactId>exists-maven-plugin</artifactId>
      <version>0.13.0</version>
      <executions>
        <execution>
          <goals>
            <goal>remote</goal>
          </goals>
        </execution>
      </executions>
    </plugin>

  </plugins>
</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 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 maven-deploy-plugin's deploy goal will run before exists-maven-plugin's remote goal because "When multiple executions are given that match a particular phase, they are executed in the order specified in the POM, with inherited executions running first."

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

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

exists-maven-plugin's People

Contributors

chonton avatar chonton-elementum avatar dependabot[bot] avatar jkiddo avatar mseele avatar nowheresly avatar pascalgn avatar tobias-hammerschmidt avatar tomandegg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

exists-maven-plugin's Issues

Provide option to skip remote check if deploy lifecycle is not executed

We have a parent pom with our intranet maven repository that can only be deployed from a specific build server. We use exists-maven-plugin to avoid duplicate deployments.

When we run mvn install the exists-maven-plugin always try to execute its remote task and fails because the intranet maven repository path is not available on a local machine.

It would be cool if we can configure that the remote task should only be executed if the deploy lifecycle is in the executed lifecycles. It makes no sense to run the remote task if the deploy lifecycle is not executed.

Incorrect handling of artifactId with dots

Hi Chonton,

I tried to use your plugin and stumbled on a problem.
When the artifactId contains dots the url created during verification is build incorrectly.

For example artifact available in central repo:
http://central.maven.org/maven2/org/eclipse/rap/org.eclipse.rap.rwt/3.3.0/org.eclipse.rap.rwt-3.3.0.jar

Actual url created by plugin is:
http://central.maven.org/maven2/org/eclipse/rap/org/eclipse/rap/rwt/3.3.0/org.eclipse.rap.rwt-3.3.0.jar

I've traced this to
https://github.com/chonton/exists-maven-plugin/blob/master/src/main/java/org/honton/chas/exists/AbstractExistsMojo.java
lines 168 to 172:

return getRepositoryBase() + '/'
    + groupId.replace('.', '/') + '/'
    + artifactId.replace('.', '/') + '/' // IMHO replace() here is not needed.
    + version + '/'
    + artifact;

Cannot get it to fail as expected

For specific reasons, I'm trying to leverage this plugin from a straight CLI call in a maven project like this:

mvn org.honton.chas:exists-maven-plugin:remote -Dexists.failIfExists=true 

However, no matter what I do the build/plugin happily succeeds and never fails. The following two calls both succeed which, if I'm reading correctly, should be impossible:

mvn org.honton.chas:exists-maven-plugin:remote -Dexists.failIfExists=true 
mvn org.honton.chas:exists-maven-plugin:remote -Dexists.failIfNotExists=true 

I've also do this to see if properties were set, but that doesn't seem to be the case either:

mvn org.honton.chas:exists-maven-plugin:remote -Dexists.failIfExists=true help:effective-pom

What am I doing wrong?

Wrong path in RemoteExistsMojo log printout

The log printout in RemoteExistsMojo is incorrect, the "/" between the "repositoryBase" and "path" variables is missing.
This goes for both instances of "repositoryBase + path" in that file.

Example
Expected printout: Checking for artifact at https://example.com/artifactory/project/com/example/myproj/com.example.myproj/0.1.0/com.example.myproj-0.1.0.jar
Actual printout: Checking for artifact at https://example.com/artifactory/projectcom/example/myproj/com.example.myproj/0.1.0/com.example.myproj-0.1.0.jar

It is just a minor issue, I believe it fetches the correct URL.
But it is a little bit inconvenient and decreases the confidence in that the plugin did the correct check.

Not working if running mvn clean install

If you run "mvn clean install" instead of just the install it will upload to the remote, no matters if the name is the same (nor the version or the version name). Any workaround?

Unable to change the artifact parameter from the command line

I have a project with a custom packaging type, and the artifact that I publish does not use the packaging type as its suffix.

The default value of ${project.build.finalName}.${project.packaging} for the artifact parameter is therefore not useful in this case.

The documentation suggests that I should be able to set the artifact name from the command line by passing, for example, -Dartifact="${project.build.finalName}.pom" but this has no effect.

I need to configure it on the command line, because I am trying to use this plugin to prevent attempting to overwrite previous releases, and of course there's no way to modify the pom of an old tagged release.

Incorrectly identifies remote artifact as not existing when in fact it does exist

I have run mvn exists to check if a remote artifact exists and when I click on the URL that is written to stdout by your plugin I can download that artifact using my browser but for some odd reason your plugin thinks the artifact does not exist. Why is that?

[DEBUG] Configuring mojo org.honton.chas:exists-maven-plugin:0.1.0:remote from plugin realm ClassRealm[plugin>org.honton.chas:exists-maven-plugin:0.1.0, parent: sun.misc.Launcher$AppClassLoader@6d6f6e28]
[DEBUG] Configuring mojo 'org.honton.chas:exists-maven-plugin:0.1.0:remote' with basic configurator -->
[DEBUG] (f) artifact = platform-auth-bdd-1.1.0.jar
[DEBUG] (f) cmpChecksum = false
[DEBUG] (f) failIfExists = true
[DEBUG] (f) failIfNotExists = false
[DEBUG] (f) failIfNotMatch = true
[DEBUG] (f) mavenProject = MavenProject: au.com.maiatechnology:platform-auth-bdd:1.1.0 @ /Volumes/Maia/git/platform-auth-ui/bdd/pom.xml
[DEBUG] (f) project = au.com.maiatechnology:platform-auth-bdd:1.1.0
[DEBUG] (f) property = maven.deploy.skip
[DEBUG] (f) repository = https://
[DEBUG] (f) serverId = gitlab-maven
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@64bc21ac
[DEBUG] (f) settings = org.apache.maven.execution.SettingsAdapter@5d25e6bb
[DEBUG] (f) skip = false
[DEBUG] (f) skipIfSnapshot = true
[DEBUG] (f) snapshotRepository =
[DEBUG] (f) snapshotServerId = gitlab-maven
[DEBUG] (f) userProperty = false
[DEBUG] -- end configuration --
[DEBUG] Checking for artifact at
[INFO] au.com.maiatechnology:platform-auth-bdd:1.1.0 does not exist

exists-maven-plugin v0.1.0 incompatibility with maven 3.3.9 and older

If you try to use v0.1.0 of this plugin on an older version of Maven, you will experience symptoms similar to those described in jeremylong/DependencyCheck#1054.

v0.0.6 continues to work fine.

I had upgraded this after reviewing the output of mvn versions:display-plugin-updates; while some new plugin versions specified that they would require a minimum of e.g. 3.5.4, this one did not:

[INFO] The following plugin updates are available:
[INFO]   org.honton.chas:exists-maven-plugin ................ 0.0.6 -> 0.1.0
[INFO]
[INFO] Project inherits minimum Maven version as: 3.3.9
[INFO] Plugins require minimum Maven version of: 3.3.9
[INFO]
[INFO] Require Maven 3.5.4 to use the following plugin updates:
[INFO]   org.codehaus.mojo:license-maven-plugin .............. 1.20 -> 2.0.0

Perhaps you could ensure that the published plugin compatibility is accurate, to avoid other people encountering the same issue?

Thanks!

NullPointerException when used with jitpack.io

Just tried to use the plugin on a jitpack.io package. Jitpack gives the following error:

[ERROR] Failed to execute goal org.honton.chas:exists-maven-plugin:0.0.6:local (default) on project parent: null: MojoExecutionException: NullPointerException -> [Help 1]

used it like that:

        <plugins>
            <plugin>
                <groupId>org.honton.chas</groupId>
                <artifactId>exists-maven-plugin</artifactId>
                <version>0.0.6</version>
                <configuration>
                    <project>pro.ject</project>
                    <artifact>art.ifact</artifact>
                </configuration>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>local</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            ...

no issues when run locally.

Just tell me how I can help...

Looking for the wrong artifact when using <packaging>content-package</packaging>

When using content-package in my pom, the artifact cannot be found as content-package is amended to the name. See error message below

[INFO] --- exists-maven-plugin:0.12.0:remote (default) @ project-aem-all.all ---
181[INFO] Checking for artifact at https://nexus-url/repository/maven-releases/au/com/project/aem/project-aem-all/project-aem-all.all/9.7.1/project-aem-all.all-9.7.1.content-package
182[INFO] au.com.project.aem.project-aem-all:project-aem-all.all:9.7.1 does not exist
 

SNAPSHOT check exists

Hello,

When plugin tries to check SNAPSHOT version from remote server, the url checked is "<host>/content/repositories/snapshots/<groupId>/<artifact>/<version>/<artifact>-<version>.tar.gz"
But when it is a SNAPHOSTversion, the correct url should contain a timestamp in final filename : <host>/content/repositories/snapshots/groupId/artifact/1.0.0-SNAPSHOT/artifact-1.0.0-20210615.181211-10.jar"
where name is "artifact-1.0.0-20210615.181211-10.jar" and not "artifact-1.0.0-SNAPSHOT.jar".

Regards,

Version 0.7.0 doesn't work when using Amazon S3

I use maven to package and deploy some common code library jars to an Amazon S3 bucket which serves as a private artifact repository. The deployment to the S3 bucket is done via the org.springframework.build:aws-maven:5.0.0.RELEASE maven extension. The exists-maven-plugin has been fantastic at preventing new builds from overwriting existing deployments but something changed in 0.7.0. It no longer detects the existing deployments and overwrites them every time. When I test against a public artifact repository like Maven Central I see that 0.7.0 always works and detects the existing deployments.

I've run maven with the debug flag and noticed a difference between the HTTP requests that are generated between version 0.6.0 and 0.7.0.

In version 0.7.0 the following HTTP call is logged. I've anonymized and redacted some values but the issue is still clear. In the request generated by version 0.7.0 there is a "%2F" in the URL path (the URL encoded value for a forward slash) that does not appear when I use version 0.6.0.

[DEBUG] Sending request: HEAD /release/%2Fcom/example/commons/215/commons-215.jar HTTP/1.1
[DEBUG] >> HEAD /release/%2Fcom/example/commons/215/commons-215.jar HTTP/1.1
[DEBUG] >> Host: repository.example.com.s3.amazonaws.com
[DEBUG] >> Authorization: *** AWS CREDENTIALS REDACTED ***
[DEBUG] >> User-Agent: aws-sdk-java/1.7.1 Windows_10/10.0 OpenJDK_64-Bit_Server_VM/25.322-b06/1.8.0_322
[DEBUG] >> Date: Fri, 10 Jun 2022 17:38:00 GMT
[DEBUG] >> Content-Type: application/x-www-form-urlencoded; charset=utf-8
[DEBUG] >> Connection: Keep-Alive


[DEBUG] Receiving response: HTTP/1.1 404 Not Found
[DEBUG] << HTTP/1.1 404 Not Found
[DEBUG] << x-amz-request-id: *** REDACTED ***
[DEBUG] << x-amz-id-2: *** REDACTED ***
[DEBUG] << Content-Type: application/xml
[DEBUG] << Date: Fri, 10 Jun 2022 17:38:00 GMT
[DEBUG] << Server: AmazonS3

Under 0.6.0 the URL path that is generated and checked is /release/com/example/commons/215/commons-215.jar which returns an HTTP 200 response and the maven-exists-plugin correctly stops the build and reports that the version is already deployed.

I've done a very basic look through of your code and I don't see anything that changed in 0.7.0 that looks like an immediate culprit for this issue. Could it be the change to Maven 3.8.4 in your plugin's pom.xml?

Make exists goal thread-safe

When using parallel execution with Maven, we get the following warning:

[WARNING] *****************************************************************
[WARNING] * Your build is requesting parallel execution, but project *
[WARNING] * contains the following plugin(s) that have goals not marked *
[WARNING] * as @threadsafe to support parallel building. *
[WARNING] * While this /may/ work fine, please look for plugin updates *
[WARNING] * and/or request plugins be made thread-safe. *
[WARNING] * If reporting an issue, report it against the plugin in *
[WARNING] * question, not against maven-core *
[WARNING] *****************************************************************
[WARNING] The following plugins are not marked @threadsafe in MyProject Modules:
[WARNING] org.honton.chas:exists-maven-plugin:0.1.0
[WARNING] Enable debug to see more precisely which goals are not marked @threadsafe.
[WARNING] *****************************************************************

It would be nice to get a thread-safe implementation of the goal. Adding the annotation would be easy, but I don't know how the plugin checks the artifact existence. Maybe the remote repo access needs synchronization - possibly synchronized based on the checked group and arfifact id.

Checking an artifact with pom packaging fails

image

The plugin loads just the pom.xml contents instead of the cached checksum, did you lose ".sha1" part?

[ERROR] Failed to execute goal org.honton.chas:exists-maven-plugin:0.7.0:local (default) on project microservice-parent: buildChecksum(45b67dfc91df453c7be01ebf541d55cf3e2ac15e) != priorChecksum(<?xml version="1.0" encoding="UTF-8"?>
[ERROR] <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
[ERROR]          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
[ERROR]     <modelVersion>4.0.0</modelVersion>
[ERROR]     <parent>
[ERROR]         <groupId>org.springframework.boot</groupId>
[ERROR]         <artifactId>spring-boot-starter-parent</artifactId>
[ERROR]         <version>2.5.5</version>
[ERROR]     </parent>
[ERROR]     <packaging>pom</packaging>

The artifact exists, but the plugin says otherwise

I am trying to use the plugin to verify the existence of the artifact and prevent it from being re-published. I use the Job-Token as an authentication system, but I don't seem to be able to use it, any suggestions?

Thanks

How to handle .bundle?

Hello. I'm trying to build a maven project and at a certain point it downloads a .bundle file. The plugin knows the artifact doesn't exist and skips it, but then it doesn't check for the packages within and the project fails since the deploy still happens, giving error 409 on Azure Artifacts. How to handle this issue?

mock-file.bundle = gets checked, doesn't exist and can get deployed
mock-file.jar/.pom (etc...) = contained in the .bundle, doesn't get checked while existing on repository, gets deployed and gives error

Support for authentication

Hi,

Are there any plans to provide basic authentication to support secured repositories?

That would be great. ;-)

failure when pom packaging

git clone https://github.com/clembo590/issues.git --branch issue_with_maven_exist_plugin_2

mvn clean install works the first time but fails the second time with buildChecksum(f9c8e12afd7fa234f7942c5a0357e71dfd329a26) != priorChecksum(<?xml version="1.0" ...

this might be a duplicate of #34
but still open after 2 years I thought I would repost...

thank you.

Not detecting artifacts with packaging maven-plugin

It seems that, when the packaging of the project is different from jar and pom, this plugin does not work properly.

I tried to use it with a maven plugin project , and for what I'm able to infer from the logs, it uses the project packaging as the file extension:

[INFO] 
[INFO] --- exists-maven-plugin:0.9.0:remote (default) @ distribution-maven-plugin ---
[INFO] Checking for artifact at https://repo.maven.apache.org/maven2/es/iti/commons/distribution-maven-plugin/1.0.2/distribution-maven-plugin-1.0.2.maven-plugin
[INFO] es.iti.commons:distribution-maven-plugin:maven-plugin:1.0.2 does not exist

Since the maven plugins are basically jar files, such *.maven-plugin file is abstent from the repository:

https://repo.maven.apache.org/maven2/es/iti/commons/distribution-maven-plugin/1.0.2/

and thus the plugin always will always decide that it does not exist.

useChecksum fail if there is no remote artifact

I'm trying to use this plugin to avoid a BUILD FAILED in case maven tries to upload an already existing artifact in our repository with the same checksum.
We want a BUILD FAILED only when checksum are different while version is the same.

To achieve that, here's my configuration:

            <plugin>
                <groupId>org.honton.chas</groupId>
                <artifactId>exists-maven-plugin</artifactId>
                <version>0.0.5</version>
                <executions>
                    <execution>
                        <phase>verify</phase>
                        <goals>
                            <goal>remote</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <failIfNotExists>false</failIfNotExists>
                    <useChecksum>true</useChecksum>
                </configuration>
            </plugin>

Unfortunately, the plugin fails if no remote artifact is available:

Caused by: org.apache.maven.plugin.MojoExecutionException: Fetching remote checksum failed for https://our-repo/repository/releases/
    at org.honton.chas.exists.RemoteExistsMojo$WagonHelper.get (RemoteExistsMojo.java:185)
    at org.honton.chas.exists.RemoteExistsMojo.getRemoteChecksum (RemoteExistsMojo.java:111)
    at org.honton.chas.exists.AbstractExistsMojo.verifyWithChecksum (AbstractExistsMojo.java:145)
    at org.honton.chas.exists.AbstractExistsMojo.execute (AbstractExistsMojo.java:101)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:564)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)

I would have expected the plugin to set maven.skip.deploy=false instead of interrupting the build.

Am I missing something ?

Check for multiple existing artifacts only honours the last check

We have a setup here, that requires to upload multiple artifacts to a nexus. If we do that, only the result of the last check decides, if the upload is initiated or not.

<plugin>
	<groupId>org.honton.chas</groupId>
	<artifactId>exists-maven-plugin</artifactId>
	<version>0.0.6</version>
	<configuration>
		<artifact>${project.build.finalName}.jar</artifact>
		<artifact>${project.build.finalName}.pom</artifact>
		<artifact>${project.build.finalName}-prod.zip</artifact>
		<artifact>${project.build.finalName}-test1.zip</artifact>
		<artifact>${project.build.finalName}-test4.zip</artifact>
		<artifact>${project.build.finalName}-dev.zip</artifact>
	</configuration>
</plugin>

Am I doing it wrong?

Thanks in advance for your reply

Failing the build

Hi Chas,

thanks for this cute plugin! As en enhancement it would be nice to have also the possibility to fail a build.

Cheers,
Jörg

Version 0.9.0 - cmpChecksum doesn't work when using Amazon S3

I think this is most likely the same root cause as in #37. The files are present and the scenario is working with version 0.5.0. Although version 0.8.0 fixes the access for the the artifact itself the checksum files still seem to be fetched with an extra / (being encoded as %2F in the request):

image

Question : profile activation

Hello,

There is a possibility to use your plugin to activate a maven profile if a specific dependency doesn't exist ?
I would like to use a dependency with version RELEASE if a specific version (1.0.0 for example) doesn't exist.

Regards,

failure with `Cannot invoke "String.length()" because "path" is null`

the issue with exists-maven-plugin

I believe The Failure is due to the fact that the plugin is looking for a <distributionManagement> section but this is not necessary to have it because this can actually be set in the maven settings.xml file as altReleaseDeploymentRepository.

In order to reproduce exactly the issue easily I have created a branch on my repo:

git clone https://github.com/clembo590/issues.git --branch issue_with_maven_exist_plugin

run (note: you MUST modify of course the volume path to whatever folder you prefer)
docker run -d -p 8081:8081 --name nexus -v /Users/clement2/code/tutorials/dockervol/nexus sonatype/nexus3;

run
docker ps
get the nexus containerId

run (of course replace the containerId by what you found previously)
docker exec -it containerId sh;

from within the docker container
run cat /nexus-data/admin.password

copy the password and got to http://localhost:8081

sign in using admin/thePasswordYouJustCopied

once signed in
through the wizard just create a user with admin/admin (as user/pwd)

--> you are now good to go.

mvn clean deploy
--> it FAILS with Cannot invoke "String.length()" because "path" is null

remove the exists-maven-plugin from the pom.xml file
run
mvn clean deploy
--> it WORKS

Check if artifact exists in remote repository not working for test-jar

Hi

First of all, I really like the idea behind the plugin and I have use cases where it is really helpful.

However, I have a problem with the following constellation:

We have Maven modules which expose code from the test scope (but they do not produce any main artifacts) by creating test-jar artifacts to use them in other modules, referenced with the type element:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
    <executions>
      <execution>
        <goals>
          <goal>test-jar</goal>
        </goals>
      </execution>
    </executions>
</plugin>

Let's call the artifact 'testArtifact'

In the Maven module where these test jars are used, let's call it testApplication, they are declared as dependencies:

<dependency>
  <groupId>some.groupId</groupId>
  <artifactId>testArtifact</artifactId>
  <version>${project.version}</version>
  <type>test-jar</type>
</dependency>

Because they need to be packaged into the resulting jar.

the exists-maven-plugin correctly identifies that the testApplication artifact already exists in the remote repository. However, because the deployment of the primary artifact is skipped (deploy.skip=true), Maven has some fallback behavior which results in this:

[exists-maven-plugin] some.groupId:testApplication:jar:version exists
[exists-maven-plugin] setting maven.deploy.skip=true
[exists-maven-plugin] Skipping artifact deployment
[maven] No primary artifact to deploy, deploying attached artifacts instead.
[maven] Uploading to ***-repository: https://nexus/content/repositories/release-repository/groupid/testArtifact/version/testArtifact.artifactId-version.pom

And then the build fails because it tries to deploy an artifact that already exists.

Do you have a suggestion how I can solve this problem? Or is this a bug?

Not working?

Hi,

I would like to disable some of my plugins executions but it seems that I have something wrong. Actually by design I am not sure your plugin is working for current latest maven version.

Here is my maven configuration:

      <plugin>
        <groupId>org.honton.chas</groupId>
        <artifactId>exists-maven-plugin</artifactId>
        <version>0.0.2</version>
        <executions>
          <execution>
            <goals>
              <goal>local</goal>
            </goals>
            <phase>validate</phase>
          </execution>
        </executions>
        <configuration>
            <property>skip-all</property>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.5.2</version>
        <configuration>
          <skip>${skip-all}</skip>
        </configuration>
      </plugin>

And I can see in my logs:


[INFO] --- exists-maven-plugin:0.0.2:local (default) @ xxx-asset ---
[INFO] setting skip-all=true
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ xxx-asset ---
[INFO] Installing /Users/cemo/Projects/xxx-project/xxx-asset/target/xxx-asset-NO-VERSION-LOCAL.jar to /Users/cemo/.m2/repository/xxx/xxx-asset/NO-VERSION-LOCAL/xxx-asset-NO-VERSION-LOCAL.jar
[INFO] Installing /Users/cemo/Projects/xxx-project/xxx-asset/pom.xml to /Users/cemo/.m2/repository/xxx/xxx-asset/NO-VERSION-LOCAL/xxx-asset-NO-VERSION-LOCAL.pom

However when I run:

mvn clean install -f xxx-asset/pom.xml -Dskip-all=true


[INFO] --- exists-maven-plugin:0.0.2:local (default) @ xxx-asset ---
[INFO] setting skip-all=true
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ xxx-asset ---
[INFO] Skipping artifact installation

Is there something I am missing?

Authentication not passed properly into wagon when using encryption in settings.xml

The way how the authentication is passed to the wagon was changed from 0.0.6 to 0.0.7. The new code does not take care of the encrypted password and assumes that settings object holds the plain text password.

The code can be rolled back to get the authentication from wagonManager as in 0.0.6

wagonManager.getAuthenticationInfo(repository.getId()))

or the code would need to be adjusted to check for the encryption and use the maven functionality to get the actual password

securityDispatcher.decrypt( server.getPassword() ) 

https://github.com/mojohaus/sql-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/sql/SqlExecMojo.java

v0.0.6 uses vulnerable guava

Versions of guava <24.1.1 are vulnerable, of which dependency "org.apache.maven:maven-core:jar:3.3.9" is using "com.google.guava:guava:jar:18.0".
The latest I can patch it to is "com.google.guava:guava:jar:23.4-jre"; instances above ('23.5-jre' and beyond) fail the build (https://mvnrepository.com/artifact/com.google.guava/guava).

I tried to patch "org.apache.maven:maven-core:jar:3.3.9" with the latest that still builds "org.apache.maven:maven-core:jar:3.5.4" here - however this still uses "com.google.guava:guava:jar:20.0".

If possible can "exists-maven-plugin" be configured to use the latest "org.apache.maven:maven-core:jar:3.6.0", which does not seem to need guava at all (https://mvnrepository.com/artifact/org.apache.maven/maven-core)?

Kind regards!

Remote checks fails because of missing security file

Hi,

I ran into an issue with remote goal and receiving following error:

[ERROR] Failed to execute goal org.honton.chas:exists-maven-plugin:0.2.0:remote (default) on project apm-filebeat: org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException: java.io.FileNotFoundException: /root/.settings-security.xml (No such file or directory) -> [Help 1]

I tried to dig a bit why this is happening and ran into following issue.

Can you please advise whether there is a possibility to override location of XML file? When I am symlinking /root/.settings-security.xml to my ~/.m2/settings-security.xml everything works in my localhost environment. Unfortunately I do not have rights to do the same on our build machine.

Thanks in advance for your reply
Jan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.