2

Edit 3: I also tried to set maven proxy through java option parameters mentioned at this thread.


Edit 2: I'm sure intellij idea are using same settings.xml, same maven binary and the same local repository as system maven.


Edit 1: I tried to check build log of each workload, the main difference is about how to invoke maven at the very beginning of build log.

For intellij idea, it's like below:

C:\Program Files\Java\jdk1.8.0_101\bin\java.exe" -Dmaven.multiModuleProjectDirectory=C:\Users\eugene\IdeaProjects\alluxio -Dmaven.home=C:\apache-maven-3.5.4-bin\apache-maven-3.5.4 -Dclassworlds.conf=C:\apache-maven-3.5.4-bin\apache-maven-3.5.4\bin\m2.conf "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA\plugins\maven\lib\maven-event-listener.jar" -Dfile.encoding=UTF-8 -classpath C:\apache-maven-3.5.4-bin\apache-maven-3.5.4\boot\plexus-classworlds-2.5.2.jar org.codehaus.classworlds.Launcher -Didea.version2019.2.4 -DskipTests=true -T 2C clean install -DskipTests -Dmaven.javadoc.skip -Dfindbugs.skip -Dcheckstyle.skip -Dlicense.skip

For system shell, maven just launched without this invoking info.


I'm using maven to build a project Alluxio from source code.

I tried both Windows 10 and Ubuntu and found same issue when using intellij idea, let me clarify it into details.

  • OS: windows 10/ Ubuntu 18.04
  • Maven: 3.5.4
  • Build command: mvn -T 2C clean install -DskipTests -Dmaven.javadoc.skip -Dfindbugs.skip -Dcheckstyle.skip -Dlicense.skip

The Alluxio can be built successfully using maven 3.5.4 directly but failed with several errors using intellij idea. What makes me confused is that I configured intellij idea to use system maven 3.5.4 and used exactly same build command. Why errors happened here but not in system shell.

The error I met is like:

Failure to find com.google.guava:listenablefuture:jar:sources:9999.0-empty-to-avoid-conflict-with-guava in https://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced

And also like:

sourceFile C:\Users\eugene\IdeaProjects\alluxio\table\server\underdb\target\alluxio-table-server-underdb-2.2.0-SNAPSHOT-jar-with-dependencies.jar does not exist

The method used to trigger maven build from intellij idea:

  • Click maven icon at right top corner
  • Click Execute Maven Goal
  • Input mvn -T 2C clean install -DskipTests -Dmaven.javadoc.skip -Dfindbugs.skip -Dcheckstyle.skip -Dlicense.skip and enter to launch build

The maven settings in intellij idea is as default except change the maven binary from build-in binary to system maven 3.5.4.

Thanks for your help in advance.

Eugene
  • 10,627
  • 5
  • 49
  • 67
  • When executing the goal in IntelliJ, take a look at the console and verify what's the actual command being executed, what's different from the one you execute directly in the shell? – lealceldeiro Jan 01 '20 at 10:13
  • I strongly recommend to test first: Remove everything from your local repository and try to build via `mvn clean package` not `mvn clean install` and check if this works without issues... – khmarbaise Jan 01 '20 at 10:28
  • @lealceldeiro Thnaks for this comment. I updated the difference at question. – Eugene Jan 01 '20 at 10:35
  • @khmarbaise For quick test, I tried `mvn clean package` with no luck. For slow test (remove everything from local repository), I will do it at night and update the result once it's finished. Anyway, according to my understanding, `install` contains `package` step and has extra step to make built target available at local maven repository. I tried `install` goal with empry repository and I guess the slow test will also fail. – Eugene Jan 01 '20 at 11:12
  • If something is on the build which needs a `install` this is an indicator that the build in general is wrong...missing inter module dependencies which is an issue...apart from that: Why should tests fail if an install has not been made? – khmarbaise Jan 01 '20 at 12:44
  • @khmarbaise I want to say that I have tried `install` with empty repository and it fails. Based on above fact, I guess 'package` from empty repository will also fail. Anyway, I will try that later. – Eugene Jan 01 '20 at 12:49
  • @khmarbaise I don't quite get your point here, "If something is on the build which needs a install this is an indicator that the build in general is wrong" – Eugene Jan 01 '20 at 12:50
  • If you need to run the build with `mvn clean install` and works but with `mvn clean package` only not there are issues in the build...which I wrote missing dependencies between modules for example etc. In particular if you like to get things faster via `mvn -T 2C ..` ... – khmarbaise Jan 01 '20 at 13:05
  • @khmarbaise I tried to empty the entire maven local repository and tried 'mvn clean package` but got same error. As a workaround, I will use intellij idea to edit the code and use system shell to maven build it. Thanks for your time anyway. – Eugene Jan 02 '20 at 02:37

1 Answers1

1

I have seen two issues that will produce an error message like you see and it has nothing to do with IntelliJ.

The first occurs when Maven fails to successfully download an artifact from a repository (e.g., network interruption). It will mark the artifact as failed and will refuse to retry until some period lapses. Cleaning your local Maven cache or removing that artifact's folder will fix this issue.

The second occurs when two separate Maven builds attempt to download the same artifact from different repositories. Many years ago, Maven had a problem with people building modified versions of open-source projects (e.g., Apache Commons) and publishing them in a publicly available repository. I don't remember the details but this caused lots of issues. Maven now records the repository used to fetch an artifact. When two Maven projects use different repositories, the second one built will fail because the repository does not match. I had this occur when switching to a private repository, Artifactory, and not having all my projects migrated yet.

Since you are attempting to build the same project with two tools, your issue appears to be a variant of the second issue. I suspect that IntelliJ is using a different settings.xml than what you have available from the command line and that IntelliJ is using different repositories. Repositories can be specified in the settings.xml as well as the project's POM.

Try deleting your local cache and building from IntelliJ first. If it succeeds and then the shell build fails, this is your problem.


Update: See this answer for more details on why Maven started tracking the repository but note the the tracking file is now called _remote.repositories.

https://stackoverflow.com/a/16870552/252344

Faron
  • 1,354
  • 10
  • 23
  • Thanks for your answer and let me response what you mentioned. Firstly, I also think it might be network issue, I tried to remove related artifactory folder from local repository and the error was still there. And secondly, I'm sure that intellij idea is using same settings.xml, same maven binary and same local repository. – Eugene Jan 01 '20 at 15:58