[
https://issues.apache.org/jira/browse/MDEPLOY-254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16843414#comment-16843414
]
Karl Heinz Marbaise edited comment on MDEPLOY-254 at 5/19/19 1:26 PM:
----------------------------------------------------------------------
So after taking a look into your pom file I questioning myself the following:
You have defined a profile {{twice-source-jar-goal}} which defines two
executions of the {{maven-source-plugin}} which will result in creating two jar
files (internally) ok so far so good..The question is why do you execute
{{maven-source-plugin}} twice without changing it's configuration for example
adding a classifier. You can also see that in your attached log files where
{{maven-source-plugin}} is executed twice. (Apart from the question why you
have configured {{maven-source-plugin}} twice in your build which is different
point).
Nevertheless tested with Maven 3.2.5 produces the same result which means the
plugin will be executed twice times as described above. In the end the deploy
of a SNAPSHOT will push two snapshot packages into repository manager:
(slightly changed the configuration to use {{jar-no-fork}} goal instead of
{{jar}}, but with the original configuration it will do that same)
{code}
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ sample ---
[INFO] Building jar:
/Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/target/sample-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-source-plugin:3.0.1:jar-no-fork (source1) @ sample ---
[INFO] Building jar:
/Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/target/sample-0.0.1-SNAPSHOT-sources.jar
[INFO]
[INFO] --- maven-source-plugin:3.0.1:jar-no-fork (source2) @ sample ---
[INFO] Building jar:
/Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/target/sample-0.0.1-SNAPSHOT-sources.jar
[INFO]
{code}
Furthermore you can see that the {{maven-install-plugin}}:
{code}
[INFO] --- maven-install-plugin:2.4:install (default-install) @ sample ---
[INFO] Installing
/Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/target/sample-0.0.1-SNAPSHOT.jar
to
/Users/khmarbaise/.m2/repository/sample/sample/0.0.1-SNAPSHOT/sample-0.0.1-SNAPSHOT.jar
[INFO] Installing /Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/pom.xml to
/Users/khmarbaise/.m2/repository/sample/sample/0.0.1-SNAPSHOT/sample-0.0.1-SNAPSHOT.pom
[INFO] Installing
/Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/target/sample-0.0.1-SNAPSHOT-sources.jar
to
/Users/khmarbaise/.m2/repository/sample/sample/0.0.1-SNAPSHOT/sample-0.0.1-SNAPSHOT-sources.jar
[INFO] Installing
/Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/target/sample-0.0.1-SNAPSHOT-sources.jar
to
/Users/khmarbaise/.m2/repository/sample/sample/0.0.1-SNAPSHOT/sample-0.0.1-SNAPSHOT-sources.jar
[INFO]
{code}
installs the same file twice times which results in overwriting the file. This
is related to MNG-5969 which already describes that scenario. If you run {{mvn
deploy}} those two added source package will be deployed which exactly will
result in a failure during the release cause your repository manager denies
overwriting of already existing released artifacts.
A short term solution (workaround) would be to change your build and configure
your executions for the {{maven-source-plugin}} by using different classifiers
(Apart form the question why you have two executions in your build at all?).
The {{maven-shade-plugin}} (it creates also a {{sources}} packages which
collides with the one previously created). The part with {{maven-shade-plugin}}
looks strange. I'm not sure at the moment if this is a bug in
{{maven-shade-plugin}} ??
A short term solution (workaround) would be to use either
{{maven-source-plugin}} only to create a source package or use
{{maven-shade-plugin}} only but not both.
There are four solutions possible which I can think of:
# Handle it in Maven core via MNG-5969 and break the build if something like
this happens. Will only work with newer Maven versions.
# Try to identify such scenario in {{maven-source-plugin}} as well as in
{{maven-shade-plugin}} and break the build.
# Try to identify such scenario in {{maven-install-plugin}} and break the build
# Try to identify such scenario in {{maven-deploy-plugin}} and break the build
Maybe we need to do all of them...to make it more stable and more clear for
users.
Unfortunately that will help only if users use the most recent versions of at
least of one of the plugins otherwise your build will break as described in
this issue.
was (Author: khmarbaise):
So after taking a look into your pom file I questioning myself the following:
You have defined a profile {{twice-source-jar-goal}} which defines two
executions of the {{maven-source-plugin}} which will result in creating two jar
files (internally) ok so far so good..The question is why do you execute
{{maven-source-plugin}} twice without changing it's configuration for example
adding a classifier. You can also see that in your attached log files where
{{maven-source-plugin}} is executed twice. (Apart from the question why you
have configured {{maven-source-plugin}} twice in your build which is different
point).
Nevertheless tested with Maven 3.2.5 produces the same result which means the
plugin will be executed twice times as described above. In the end the deploy
of a SNAPSHOT will push two snapshot packages into repository manager:
(slightly changed the configuration to use {{jar-no-fork}} goal instead of
{{jar}}, but with the original configuration it will do that same)
{code}
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ sample ---
[INFO] Building jar:
/Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/target/sample-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-source-plugin:3.0.1:jar-no-fork (source1) @ sample ---
[INFO] Building jar:
/Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/target/sample-0.0.1-SNAPSHOT-sources.jar
[INFO]
[INFO] --- maven-source-plugin:3.0.1:jar-no-fork (source2) @ sample ---
[INFO] Building jar:
/Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/target/sample-0.0.1-SNAPSHOT-sources.jar
[INFO]
{code}
Furthermore you can see that the {{maven-install-plugin}}:
{code}
[INFO] --- maven-install-plugin:2.4:install (default-install) @ sample ---
[INFO] Installing
/Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/target/sample-0.0.1-SNAPSHOT.jar
to
/Users/khmarbaise/.m2/repository/sample/sample/0.0.1-SNAPSHOT/sample-0.0.1-SNAPSHOT.jar
[INFO] Installing /Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/pom.xml to
/Users/khmarbaise/.m2/repository/sample/sample/0.0.1-SNAPSHOT/sample-0.0.1-SNAPSHOT.pom
[INFO] Installing
/Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/target/sample-0.0.1-SNAPSHOT-sources.jar
to
/Users/khmarbaise/.m2/repository/sample/sample/0.0.1-SNAPSHOT/sample-0.0.1-SNAPSHOT-sources.jar
[INFO] Installing
/Users/khmarbaise/ws-git-maven-bugs/MDEPLOY-254/target/sample-0.0.1-SNAPSHOT-sources.jar
to
/Users/khmarbaise/.m2/repository/sample/sample/0.0.1-SNAPSHOT/sample-0.0.1-SNAPSHOT-sources.jar
[INFO]
{code}
installs the same file twice times which results in overwriting the file. This
is related to MNG-5969 which already describes that scenario. If you run {{mvn
deploy}} those two added source package will be deployed which exactly will
result in a failure during the release cause your repository manager denies
overwriting of already existing released artifacts.
A short term solution (workaround) would be to change your build and configure
your executions for the {{maven-source-plugin}} by using different classifiers
(Apart form the question why you have two executions in your build at all?).
The {{maven-shade-plugin}} (it creates also a {{sources}} packages which
collides with the one previously created). The part with {{maven-shade-plugin}}
looks strange. I'm not sure at the moment if this is a bug in
{{maven-shade-plugin}} ??
A short term solution (workaround) would be to use either
{{maven-source-plugin}} only to create a source package or use
{{maven-shade-plugin}} only but not both.
There are four solutions possible which I can think of:
# Handle it in Maven core via MNG-5969 and break the build if something like
this happens. Will only work with newer Maven versions.
# Try to identify such scenario in {{maven-source-plugin}} as well as in
{{maven-shade-plugin}} and break the build.
# Try to identify such scenario in {{maven-install-plugin}} and break the build
# Try to identify such scenario in {{maven-deploy-plugin}} and break the build
Maybe we need to do all of them...to make it more stable and more clear for
users.
> Maven Deploy Plugin deploy jar twice : Maven 3.3.3
> --------------------------------------------------
>
> Key: MDEPLOY-254
> URL: https://issues.apache.org/jira/browse/MDEPLOY-254
> Project: Maven Deploy Plugin
> Issue Type: Bug
> Reporter: Akshay
> Priority: Blocker
> Fix For: waiting-for-feedback
>
> Attachments: log1-mvn_clean_deploy_-Ptwice-source-jar-goal.txt,
> log2-mvn_clean_deploy_-Psource-and-shade-plugin.txt, sample-project.zip
>
>
> Failed to execute goal
> org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on
> project ****** :
> Failed to retrieve remote metadata ******/maven-metadata.xml:
> Could not transfer metadata ****** from/to ******
> {color:#FF0000} Not authorized , ReasonPhrase:Unauthorized. {color}
>
> Wanted to know if the fix is out in a later version of Maven?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)