Skip to content

[MRESOLVER-98] resolver ant task doesn't obey dependencyManagement#2

Closed
lwr wants to merge 2 commits intoapache:masterfrom
lwr:MRESOLVER-98
Closed

[MRESOLVER-98] resolver ant task doesn't obey dependencyManagement#2
lwr wants to merge 2 commits intoapache:masterfrom
lwr:MRESOLVER-98

Conversation

@lwr
Copy link
Copy Markdown

@lwr lwr commented Mar 2, 2020

@lwr lwr force-pushed the MRESOLVER-98 branch 2 times, most recently from a0d12c9 to 2215051 Compare March 2, 2020 07:53
@lwr
Copy link
Copy Markdown
Author

lwr commented Mar 3, 2020

After applying the patch, the resolving mechanism still does not work as expected

test case

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.apache.maven.resolver</groupId>
        <artifactId>maven-resolver-api</artifactId>
        <version>1.4.1</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.apache.maven.resolver</groupId>
      <artifactId>maven-resolver-util</artifactId>
      <version>1.4.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

the dependency tree

[INFO] \- org.apache.maven.resolver:maven-resolver-util:jar:1.4.1:test
[INFO]    \- org.apache.maven.resolver:maven-resolver-api:jar:1.4.1:test

but the resolver will incorrectly resolve maven-resolver-api as compile scope

I think it would be caused by the resolver itself, will 1.4.2 resolve this problem?

@lwr
Copy link
Copy Markdown
Author

lwr commented Mar 4, 2020

I had add the testcase to expose this problem

the resolver will incorrectly resolve maven-resolver-api as compile scope

@snoopyhzy
Copy link
Copy Markdown

您好,咨询下,还没编译您这个版本。
我发现比如springtext他自带mockito这种,我们在properties里指定了版本,在用实际maven的过程当中没问题,但在ant中用-verbose可以看出他用的版本是有问题的是因为您这个原因么?

另外发现如果有版本在仓库是snapshot模式的,带时间戳和buildnumber的也会报错,和这个相关么?

@lwr
Copy link
Copy Markdown
Author

lwr commented Mar 20, 2020

@snoopyhzy I have abandon this project as a solution of maven ant integration

this PR fixes the DependencyManagement version issue but still have the scope issue, so I think the maven resolver is not a stable solution I can rely on this time.

Now I switch back to use the deprecated maven-ant-task project, with a little patch

<!-- patch super pom to workaround central repo policy change problem (http access forbidden) -->
<unzip src="path/to/maven-ant-task-2.1.3.jar"
   dest="maven/target/workaround-central-repo-https">
    <patternset includes="**/pom-4.0.0.xml" />
</unzip>
<replace dir="maven/target/workaround-central-repo-https" encoding="utf8"
     token="http://repo1.maven.org/maven2" value="https://repo1.maven.org/maven2" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant">
    <classpath path="maven/target/workaround-central-repo-https" />
    <classpath path="path/to/maven-ant-task-2.1.3.jar" />
</typedef>

@snoopyhzy
Copy link
Copy Markdown

@lwr thank you
I used the project last week,but find a fatal problem that I cannot slove.The problm is https://issues.apache.org/jira/plugins/servlet/mobile#issue/MANTTASKS-251 ,and My company cannot acesss Internet.
So I use this project instend.

I use this project to download java libs and then run inc test case.

Now I find another solusion that is use exec cmd.exe /c mvn dependency:copy-dependencies -Doutputdir.
It can solve my problem and dependent orginial maven

@lwr
Copy link
Copy Markdown
Author

lwr commented Mar 20, 2020

@snoopyhzy that project is already retired, no any issue reporting will be fixed and has no meaning.

I had found the same problem what you reported I in https://issues.apache.org/jira/browse/MANTTASKS-251

That issue only occurs while processing dependency with type=import (mirror not being applied), in most situations that is not a problem until recently that http://repo1.maven.org being shutdown (enforcing https accessing).

We have several choices:

  1. first I try maven-resolver-ant-tasks and now I am being here
  2. secondly I try patch the super pom as last comment, and that works.
  3. meanwhile run command mvn dependency:resolve before the ant execution, would help workaround the download problem, both "central repo http problem" and "mirror problem"
    mvn dependency:resolve -s settings.xml

@snoopyhzy
Copy link
Copy Markdown

@lwr thank you,But I am sure it is the problem of maven-resolver-ant-tasks

@lwr
Copy link
Copy Markdown
Author

lwr commented Mar 24, 2020

@snoopyhzy it is problem of retired project maven-ant-tasks not this new project maven-resolver-ant-tasks, they are different and this project is the replacement of the retired one

@snoopyhzy
Copy link
Copy Markdown

@lwr the new one has two other problem that I find.
One is it download error version of dependencies.
for example,I use springboot test and set mockito version in properties.The version download different with use mvn copy-dependencies and the ant plugin.
Another is it do not support Snapshot version with timestamp and serialno

@lwr
Copy link
Copy Markdown
Author

lwr commented Mar 25, 2020

@snoopyhzy I had said that why I am here for, this project maven-resolver-ant-tasks is not workable.

this PR fixes one (dependency management version problem), but another not fixed yet (see the new committed test case testResolvePomWithScopedAndManagement). So, my suggestion is

  1. stay use the retired maven-ant-tasks project
  2. with patching it's embedded super pom-4.0.0.xml
  3. run mvn dependency:resolve before the ant task run so all download problems could be avoided

@snoopyhzy
Copy link
Copy Markdown

@lwr OIC,you mean use resolve to download all jar to local repo

@michael-o
Copy link
Copy Markdown
Member

@lwr Can you rebase on top of master? I'd like to pick this up.

@michael-o
Copy link
Copy Markdown
Member

Please hav a look at DefaultProjectDependenciesResolver in Maven Core. There you will find the code how Maven prepares the collect request. I strongly assume that those code bases are disjoint and therefore you see the erratic behavior.

@lwr
Copy link
Copy Markdown
Author

lwr commented Aug 27, 2021

we had give-up using maven-resolver, try this https://gist.github.com/lwr/6829cefaab2261cec1cc733f6398b9ac

@michael-o
Copy link
Copy Markdown
Member

Closing this since is not going to be fixed.

@michael-o michael-o closed this Aug 27, 2021
@jkahrman
Copy link
Copy Markdown
Contributor

The change in this pull request appears to have been similarly applied in #30.

The second issue brought up in https://issues.apache.org/jira/browse/MRESOLVER-98?focusedCommentId=17050291&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17050291 with regards to incorrect scope resolution when using dependency management still applies .

@jira-importer
Copy link
Copy Markdown

Resolve #111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants