Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] MavenLauncher always fails #5030

Closed
backcover7 opened this issue Dec 7, 2022 · 14 comments
Closed

[Question] MavenLauncher always fails #5030

backcover7 opened this issue Dec 7, 2022 · 14 comments

Comments

@backcover7
Copy link

I am not sure if there's any configuration problem on my local side, but I cannot use MavenLauncher to load any source code.

I tried to load the following two projects with MavenLauncher, all of them failed.

The error info contains something like Could not transfer metadata org.codehaus.mojo:javancss-maven-plugin/maven-metadata.xml from/to apache.snapshots, Error resolving version for plugin

Here is my code.

MavenLauncher launcher = new MavenLauncher(codebase, MavenLauncher.SOURCE_TYPE.APP_SOURCE);
launcher.addInputResource(codebase);
launcher.getEnvironment().disableConsistencyChecks();
launcher.getEnvironment().setCommentEnabled(false);
launcher.buildModel();
model = launcher.getModel();
@backcover7 backcover7 changed the title MavenLauncher always fails [Question] MavenLauncher always fails Dec 7, 2022
@I-Al-Istannen
Copy link
Collaborator

Spoon executes mvn dependency:build-classpath in your project, does that work when run manually?

@backcover7
Copy link
Author

That helps! I do not know why there have some issues in the original open source project when building classpath. After I cleanup the issue it works!

@I-Al-Istannen
Copy link
Collaborator

That helps! I do not know why there have some issues in the original open source project when building classpath. After I cleanup the issue it works!

Great! I don't know either, but the statistics for building random maven projects from github aren't exactly rosy, so I am not too surprised :P I think this issue can be closed then, feel free to comment or re-open if not :)

Plus, any plan release spoon-decompiler to maven central?

I am not aware of any plan currently. Have a look at the submodule policy introduced in #4930 for reference. You can use e.g. jitpack to let it build the module for you, if you want though.

@backcover7
Copy link
Author

I am trying to mvn clean package my maven project which depends on spoon. However, it seems the maven settings of spoon have an issue itself. It is set to use http instead of https. And this results that the maven http blocker will not allow me to compile my project only if I added some extra configurations. Do you have any plan on replace http with https?

@I-Al-Istannen
Copy link
Collaborator

I am not sure what you mean. spoon-core is hosted on maven central and maven central supports https. Spoon itself also builds in CI without special settings (and on my computer with maven 3.8.6) without any adjustments.

Could you tell me which part of spoon uses an http repository?

@backcover7
Copy link
Author

I also did not find where's the misconfiguration. I reproduced by created a new maven project and only import the spoon dependency in pom.xml. And the console displays Downloading from maven-default-http-blocker: http://0.0.0.0/org/apache/maven/maven-model/maven-metadata.xml and stucked. I assumed it was trying to search the local repository.

From Internet resources (https://stackoverflow.com/questions/66980047/maven-build-failure-dependencyresolutionexception), it seems that maven > 3.8.1 will perform like this due to http misconfiguration. Can you reproduce it in a new maven project?

@I-Al-Istannen
Copy link
Collaborator

@backcover7 Using the following pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>de.ialistannen</groupId>
  <artifactId>Foobar</artifactId>
  <version>1.0-SNAPSHOT</version>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.target>19</maven.compiler.target>
    <maven.compiler.source>19</maven.compiler.source>
  </properties>

  <dependencies>
    <dependency>
      <groupId>fr.inria.gforge.spoon</groupId>
      <artifactId>spoon-core</artifactId>
      <version>10.2.0</version>
    </dependency>
  </dependencies>

</project>

I can create a project without a problem :)

I can also create a project without a problem in the maven:3 docker image. Are you sure your setup is actually correct?

@backcover7
Copy link
Author

backcover7 commented Dec 8, 2022

Your XML still does not work on my side. Have you ever customized your settings.xml in .m2?

Here's my verbose output on my side. (maven clean package -X)
image
The https://maven.inria.fr/ seems to use a unvalidated ssl certificate.

@I-Al-Istannen
Copy link
Collaborator

I-Al-Istannen commented Dec 8, 2022

Your XML still does not work on my side. Have you ever customized your settings.xml in .m2?

I mean, I also ran it in a docker image as I said above. The docker image does not ship with a .m2 folder and neither did I adjust my config. It also never touches the inria.fr repository (and why would it? The XML above does not configure this repository):

root@7713a2758687:/foo# mvn package &>out.txt
root@7713a2758687:/foo# vim out.txt 
root@7713a2758687:/foo# cat out.txt | grep inria
Downloading from central: https://repo.maven.apache.org/maven2/fr/inria/gforge/spoon/spoon-core/10.2.0/spoon-core-10.2.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/fr/inria/gforge/spoon/spoon-core/10.2.0/spoon-core-10.2.0.pom (11 kB at 961 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/fr/inria/gforge/spoon/spoon-pom/1.0/spoon-pom-1.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/fr/inria/gforge/spoon/spoon-pom/1.0/spoon-pom-1.0.pom (21 kB at 1.4 MB/s)
Downloading from central: https://repo.maven.apache.org/maven2/fr/inria/gforge/spoon/spoon-core/10.2.0/spoon-core-10.2.0.jar
Downloaded from central: https://repo.maven.apache.org/maven2/fr/inria/gforge/spoon/spoon-core/10.2.0/spoon-core-10.2.0.jar (1.9 MB at 7.3 MB/s)
root@7713a2758687:/foo#

@backcover7
Copy link
Author

Not sure if it's my problem. But it seems the root cause is the dependency maven-model in spoon pom.xml. I cannot retrieve the metadata.xml of this jar

@I-Al-Istannen
Copy link
Collaborator

I-Al-Istannen commented Dec 8, 2022

But nothing in spoon uses the maven.inria.fr repository (rg has zero results) and maven-model is available on maven central: https://mvnrepository.com/artifact/org.apache.maven/maven-model

This is really weird. Does it work for you if you use the maven:3 docker image as the base instead of running it locally on your computer?

@Kang-Hou
Copy link

@I-Al-Istannen Sorry for the late reply. It works for me now.

@I-Al-Istannen
Copy link
Collaborator

@Kang-Hou Are you the OP? If so, I am glad and thanks for your comment :) If not, I am also glad but a tad confused ;)

@I-Al-Istannen
Copy link
Collaborator

You can not (except for writing your own mvn wrapper and putting that earlier in the PATH). Spoon uses the maven API and expects that to work. What does your Selfbuild command do exactly that maven can not?

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

No branches or pull requests

3 participants