1

If I am using an IDE with Maven integration (IntelliJ IDEA) to import a Maven project (Android), do I still need to run mvn install on the command line to build the project? Or should that all be done by IntelliJ during the project import wizard?

Edit: My issue is that after importing the project into IntelliJ, when I open up my libraries, many of the Maven libraries are linked to wrong sources and javadocs. The folder they are getting the sources and javadocs does exist, but the specific javadoc.jar or sources.jar files referenced do not exist in that folder.

So I'm thinking I did something wrong with my Maven import - I only used the IntelliJ wizard to do it. Oddly the project still compiles and runs fine, the only 'symptom' of this problem is the empty javadocs.

enter image description here

Edit (9 Nov): I tried the method suggested by @JJF and while it does download the missing javadocs and source files, it adds on a '.lastUpdated' suffix to them. Why does that happen?

enter image description here

Also, I manually renamed the javadocs and while that clears things up in the Libraries window, when I go back to my project my inline documentation (mouse hover) still brings up empty documentation (this was the problem that initially led me to this question, I created a different thread for it here). Maybe I might be doing something wrong in my SDK Documentation Paths instead?

enter image description here

Running the process described by @Nick78 produces the errors below:

"C:\Program Files\Java\jdk1.8.0_45\bin\java" -Dmaven.multiModuleProjectDirectory=C:\Users\misao\Documents\GitHub\apps-android-commons\commons "-Dmaven.home=C:\Program Files\apache-maven-3.3.3" "-Dclassworlds.conf=C:\Program Files\apache-maven-3.3.3\bin\m2.conf" -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 14.1.5\bin" -Dfile.encoding=windows-1252 -classpath "C:\Program Files\apache-maven-3.3.3\boot\plexus-classworlds-2.5.2.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 14.1.5\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=14.1.5 -DskipTests=true clean install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building commons - Application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ commons ---
[INFO] Deleting C:\Users\misao\Documents\GitHub\apps-android-commons\commons\target
[INFO] 
[INFO] --- android-maven-plugin:3.6.0:generate-sources (default-generate-sources) @ commons ---
[WARNING] Error injecting: com.jayway.maven.plugins.android.phase01generatesources.GenerateSourcesMojo
java.lang.NoClassDefFoundError: Lorg/sonatype/aether/RepositorySystem;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
    at java.lang.Class.getDeclaredFields(Class.java:1916)
    at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:661)
    at com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:366)
    at com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:165)
    at com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:612)
    at com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:568)
    at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:554)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:877)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:798)
    at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:281)
    at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:213)
    at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:998)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1031)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:994)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1044)
    at org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:54)
    at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:115)
    at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:176)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:46)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1009)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1059)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1005)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:36)
    at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81)
    at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:546)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    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:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    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)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.RepositorySystem
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
    ... 64 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.075 s
[INFO] Finished at: 2015-11-09T00:38:37+13:00
[INFO] Final Memory: 13M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources (default-generate-sources) on project commons: Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources failed: A required class was missing while executing com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources: Lorg/sonatype/aether/RepositorySystem;
[ERROR] -----------------------------------------------------
[ERROR] realm =    extension>com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/misao/.m2/repository/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.6.0/android-maven-plugin-3.6.0.jar
[ERROR] urls[1] = file:/C:/Users/misao/.m2/repository/com/android/tools/build/builder/0.4/builder-0.4.jar
[ERROR] urls[2] = file:/C:/Users/misao/.m2/repository/com/android/tools/sdklib/22.0/sdklib-22.0.jar
[ERROR] urls[3] = file:/C:/Users/misao/.m2/repository/org/apache/httpcomponents/httpclient/4.1.1/httpclient-4.1.1.jar
[ERROR] urls[4] = file:/C:/Users/misao/.m2/repository/org/apache/httpcomponents/httpcore/4.1/httpcore-4.1.jar
[ERROR] urls[5] = file:/C:/Users/misao/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
[ERROR] urls[6] = file:/C:/Users/misao/.m2/repository/commons-codec/commons-codec/1.4/commons-codec-1.4.jar
[ERROR] urls[7] = file:/C:/Users/misao/.m2/repository/org/apache/httpcomponents/httpmime/4.1/httpmime-4.1.jar
[ERROR] urls[8] = file:/C:/Users/misao/.m2/repository/com/android/tools/layoutlib/layoutlib-api/22.0/layoutlib-api-22.0.jar
[ERROR] urls[9] = file:/C:/Users/misao/.m2/repository/com/android/tools/dvlib/22.0/dvlib-22.0.jar
[ERROR] urls[10] = file:/C:/Users/misao/.m2/repository/org/apache/commons/commons-compress/1.0/commons-compress-1.0.jar
[ERROR] urls[11] = file:/C:/Users/misao/.m2/repository/com/android/tools/build/builder-test-api/0.4/builder-test-api-0.4.jar
[ERROR] urls[12] = file:/C:/Users/misao/.m2/repository/com/android/tools/build/builder-model/0.4/builder-model-0.4.jar
[ERROR] urls[13] = file:/C:/Users/misao/.m2/repository/com/android/tools/common/22.0/common-22.0.jar
[ERROR] urls[14] = file:/C:/Users/misao/.m2/repository/com/google/guava/guava/13.0.1/guava-13.0.1.jar
[ERROR] urls[15] = file:/C:/Users/misao/.m2/repository/com/android/tools/sdk-common/22.0/sdk-common-22.0.jar
[ERROR] urls[16] = file:/C:/Users/misao/.m2/repository/com/android/tools/ddms/ddmlib/22.0/ddmlib-22.0.jar
[ERROR] urls[17] = file:/C:/Users/misao/.m2/repository/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar
[ERROR] urls[18] = file:/C:/Users/misao/.m2/repository/com/android/tools/build/manifest-merger/22.0/manifest-merger-22.0.jar
[ERROR] urls[19] = file:/C:/Users/misao/.m2/repository/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48.jar
[ERROR] urls[20] = file:/C:/Users/misao/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.jar
[ERROR] urls[21] = file:/C:/Users/misao/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.1.1/sisu-inject-bean-2.1.1.jar
[ERROR] urls[22] = file:/C:/Users/misao/.m2/repository/org/sonatype/sisu/sisu-guice/2.9.4/sisu-guice-2.9.4-no_aop.jar
[ERROR] urls[23] = file:/C:/Users/misao/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[24] = file:/C:/Users/misao/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[25] = file:/C:/Users/misao/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[26] = file:/C:/Users/misao/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[27] = file:/C:/Users/misao/.m2/repository/org/apache/maven/maven-archiver/2.5/maven-archiver-2.5.jar
[ERROR] urls[28] = file:/C:/Users/misao/.m2/repository/emma/emma/2.1.5320/emma-2.1.5320.jar
[ERROR] urls[29] = file:/C:/Users/misao/.m2/repository/org/codehaus/plexus/plexus-archiver/2.3/plexus-archiver-2.3.jar
[ERROR] urls[30] = file:/C:/Users/misao/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[31] = file:/C:/Users/misao/.m2/repository/org/codehaus/plexus/plexus-io/2.0.6/plexus-io-2.0.6.jar
[ERROR] urls[32] = file:/C:/Users/misao/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.10/plexus-utils-3.0.10.jar
[ERROR] urls[33] = file:/C:/Users/misao/.m2/repository/commons-jxpath/commons-jxpath/1.3/commons-jxpath-1.3.jar
[ERROR] urls[34] = file:/C:/Users/misao/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
[ERROR] urls[35] = file:/C:/Users/misao/.m2/repository/org/ow2/asm/asm/4.1/asm-4.1.jar
[ERROR] urls[36] = file:/C:/Users/misao/.m2/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
[ERROR] urls[37] = file:/C:/Users/misao/.m2/repository/org/sonatype/aether/aether-util/1.13.1/aether-util-1.13.1.jar
[ERROR] urls[38] = file:/C:/Users/misao/.m2/repository/com/github/rtyley/android-screenshot-paparazzo/1.9/android-screenshot-paparazzo-1.9.jar
[ERROR] urls[39] = file:/C:/Users/misao/.m2/repository/com/madgag/animated-gif-lib/1.0/animated-gif-lib-1.0.jar
[ERROR] urls[40] = file:/C:/Users/misao/.m2/repository/com/github/rtyley/android-screenshot-celebrity/1.8/android-screenshot-celebrity-1.8.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------: org.sonatype.aether.RepositorySystem
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/AetherClassNotFound

Process finished with exit code 1
Community
  • 1
  • 1
misaochan
  • 890
  • 2
  • 8
  • 25
  • 1
    I think that importing the project and building the project is two different operations. What is the actual problem that you face? – Rufi Nov 06 '15 at 12:32
  • @VladimirTikhomirov I have edited my opening post to explain the problem with a screenshot attached. Thanks! – misaochan Nov 06 '15 at 23:22

2 Answers2

2

From the command line run

mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc

That will download any missing sources and Javadocs. See Get source JARs from Maven repository

Also WRT to building your project with IntelliJ vs running mvn install: IntelliJ will compile your source files whenever you go to run or debug your app. You don't need to run maven to get your sources to compile. If you want to say package or install your project from within IntelliJ then go to the Maven Projects tool window and expand either the Life Cycle node or the Plugins node and you can run Maven goals by double clicking whatever goal you're interested in running.

If you right click on one of the goals you can create a run configuration for that goal that you can run from the run configurations drop down.

Community
  • 1
  • 1
JJF
  • 2,681
  • 2
  • 18
  • 31
  • Thank you, I have done that, but still seem to be having issues. :( I've described my issue in the opening post with screenshots (since I can't post images in comments I think). – misaochan Nov 08 '15 at 11:36
1

first of all be sure that in the Settings (Top menu > File > Settings > Build, Execution, Deployment > Build Tools > Maven) IntelliJ is pointing to the same Maven Repository as defined in your Maven Installation defined in M2_HOME. That's usually (in Windows) C:\Users\Username\.m2\repository. Then in the console go to the directory where your pom.xml is located and type in: mvn idea:idea (that will create or recreate your IntelliJ project files). In IntelliJ be sure that under Top menu > View > Tool Buttons is checked. Somewhere at the border of the IntelliJ Window there is a button called Maven Projects click it. In the opened dialog click the green + and add your pom.xml. After that click the reimport button (blue pointer circle) on the top left of the maven dialog. Then in the same dialog expand your project > Lifecycle. Hold ctrl and select clean and install. Click the blue circle with the lighning (skip tests) and after that the play button. Maybe do a reimport (blue pointer circle) again.

nick78
  • 251
  • 3
  • 19
  • Hm, this seems to do the exact same thing as running mvn install on command line, yes? This produces errors (that I pasted in my opening post). – misaochan Nov 08 '15 at 11:40
  • Edit: Also, isn't the M2_HOME environment variable supposed to point to the Maven installation, not to the Maven local repository? My Maven local repository is in the .m2\repository folder but my Maven installation is in Program Files (which is where my M2_HOME variable is pointed to). – misaochan Nov 08 '15 at 11:55
  • Of course `M2_HOME` must point to the Maven Installation. What I meant was if in the `settings.xml` (in `conf` directory of maven) no local repository is defined, then it's located in `C:/Users/Your-User/.m2/repository` by default. So, does IntelliJ point to this repository as well? Are you able to build the project from console? If not maybe you have to add a remote repository where the missing sources are located. Or maybe there are dependencies missing. Especially where the missing Lorg/sonatype/aether/RepositorySystem is included. – nick78 Nov 08 '15 at 12:19
  • Yes, the 'Maven local repository' in IntelliJ points to the directory you mentioned as well. I can see that this directory exists and when I run the commands listed by JJF I can see that the missing sources and javadocs are added to this directory. Running mvn install from the command line produces the same errors as running your process in the IntelliJ Maven Projects window does (pasted in opening post). How would I check which dependencies are missing? – misaochan Nov 08 '15 at 12:27
  • Relating to your sources and javadoc problem, maybe this plugin helps https://maven.apache.org/plugin-developers/cookbook/attach-source-javadoc-artifacts.html – nick78 Nov 08 '15 at 12:28
  • Have you seen these: http://stackoverflow.com/questions/27700099/error-injecting-com-jayway-maven-plugins-android-phase01generatesources-generat http://stackoverflow.com/questions/17293940/soap-enabler-maven-build-failure Isn't there a documentation of the android plugin which dependencies you have to use? – nick78 Nov 08 '15 at 12:58