26

I am using intellij idea ultimate version 12.1.4 and trying to use maven with a project. Here is my pom.xml:

<?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>

  <parent>
    <groupId>com.fasterxml</groupId>
    <artifactId>oss-parent</artifactId>
    <version>10</version>
  </parent>

  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
  <version>2.2.2</version>

  <name>jackson-databind</name>
  <description>General data-binding functionality for Jackson: works on core streaming API</description>
  <url>http://wiki.fasterxml.com/JacksonHome</url>

  <scm>
    <connection>scm:git:git@github.com:FasterXML/jackson-databind.git</connection>
    <developerConnection>scm:git:git@github.com:FasterXML/jackson-databind.git</developerConnection>
    <url>http://github.com/FasterXML/jackson-databind</url>
    <tag>jackson-databind-2.2.2</tag>
  </scm>

  <properties>
    <osgi.export>
com.fasterxml.jackson.databind,
com.fasterxml.jackson.databind.annotation,
com.fasterxml.jackson.databind.cfg,
com.fasterxml.jackson.databind.deser,
com.fasterxml.jackson.databind.deser.impl,
com.fasterxml.jackson.databind.deser.std,
com.fasterxml.jackson.databind.exc,
com.fasterxml.jackson.databind.ext,
com.fasterxml.jackson.databind.introspect,
com.fasterxml.jackson.databind.jsonschema,
com.fasterxml.jackson.databind.jsonFormatVisitors,
com.fasterxml.jackson.databind.jsontype,
com.fasterxml.jackson.databind.jsontype.impl,
com.fasterxml.jackson.databind.module,
com.fasterxml.jackson.databind.node,
com.fasterxml.jackson.databind.ser,
com.fasterxml.jackson.databind.ser.impl,
com.fasterxml.jackson.databind.ser.std,
com.fasterxml.jackson.databind.type,
com.fasterxml.jackson.databind.util
    </osgi.export>
    <osgi.import>
com.fasterxml.jackson.annotation,
com.fasterxml.jackson.core,
com.fasterxml.jackson.core.base,
com.fasterxml.jackson.core.format,
com.fasterxml.jackson.core.json,
com.fasterxml.jackson.core.io,
com.fasterxml.jackson.core.util,
com.fasterxml.jackson.core.type,
org.xml.sax,org.w3c.dom, org.w3c.dom.bootstrap, org.w3c.dom.ls,
javax.xml.datatype, javax.xml.namespace, javax.xml.parsers
</osgi.import>

    <!-- Generate PackageVersion.java into this directory. -->
    <packageVersion.dir>com/fasterxml/jackson/databind/cfg</packageVersion.dir>
    <packageVersion.package>com.fasterxml.jackson.databind.cfg</packageVersion.package>
  </properties>

  <dependencies>
    <!-- Builds on core streaming API; also needs core annotations -->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>2.2.2</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>2.2.2</version>
    </dependency>

    <!-- and for testing, JUnit is needed, as well as quite a few
         libs for which we use reflection for code, but direct dep for testing
      -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.10</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>cglib</groupId>
      <artifactId>cglib</artifactId>
      <version>2.2.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy</artifactId>
      <version>1.7.9</version>
      <scope>test</scope>
    </dependency>
    <dependency> <!--  from core we just test for repackaged cglib, not hibernate proper -->
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-cglib-repack</artifactId>
      <version>2.1_3</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire.version}</version>
        <configuration>
          <excludes>
            <exclude>com/fasterxml/jackson/failing/*.java</exclude>
          </excludes>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${javadoc.version}</version>
        <configuration>
          <links>
            <link>http://docs.oracle.com/javase/6/docs/api/</link>
            <link>http://fasterxml.github.com/jackson-annotations/javadoc/2.1.1/</link>
            <link>http://fasterxml.github.com/jackson-core/javadoc/2.1.1/</link>
          </links>
        </configuration>
      </plugin>
      <plugin>
        <!-- Inherited from oss-base. Generate PackageVersion.java.-->
        <groupId>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>replacer</artifactId>
        <executions>
          <execution>
            <id>process-packageVersion</id>
            <phase>process-sources</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>release</id>
      <properties>
        <maven.test.skip>true</maven.test.skip>
        <skipTests>true</skipTests>
      </properties>
    </profile>
  </profiles>

</project>

When I do a maven dependency resolution, its taking forever to get it through and this is what I get:

enter image description here

And it sticks here forever.

Here are my maven settings:

enter image description here

I followed steps given in this SO answer.

Please let me know where am I doing wrong and how do I get rid of it.

EDIT

If this should help, I am trying to run this code: https://github.com/hmkcode/Android/tree/master/java-post-gcm

I am not sure whether its an issue with the pom.xml itself. Perhaps if someone is able to have it working on his IDE, it may be concluded that its an issue with my specific IDE config.

Community
  • 1
  • 1
rahulserver
  • 10,411
  • 24
  • 90
  • 164
  • does the filename-indicator in your small screenshot EVER change? – specializt Sep 06 '14 at 13:17
  • @specializt I hope u are talking about the first screenshot. Its progress bar keeps on moving left and right. And nothing changes there.Its stuck at jackson-databind-2.2.2.jar – rahulserver Sep 06 '14 at 13:18
  • 1
    Are you behind a proxy? – Edwin Dalorzo Sep 06 '14 at 13:21
  • @EdwinDalorzo nopes. – rahulserver Sep 06 '14 at 13:22
  • 2
    And if you run maven from the command line, does it work fine? or does it freeze too? I think it's worth knowing if this is an IntelliJ-related issue or just a maven-related issue. – Edwin Dalorzo Sep 06 '14 at 13:25
  • maven-repositories DO have issues from time to time but your connection simply drops after a while, producing an exception in your caller ... im guessing that woul've been visualized. Since that apparently isnt happening i think its quite assured that his IDE is at fault .... which is also my general experience with java-IDEs other than eclipse (most of them miss even the most basic features AND are buggy) – specializt Sep 06 '14 at 13:27
  • @EdwinDalorzo maven does not work from my command line. Does it have to? I mean do we have to have it in path so that it works in intellij idea? – rahulserver Sep 06 '14 at 13:30
  • @rahulserver Not necessarily. But if you follow the [installation instructions](http://maven.apache.org/download.cgi) in the download page you could make it work from the command line. – Edwin Dalorzo Sep 06 '14 at 13:35
  • that doesnt make any sense. Apparently your're mistaking SO for some internet forum - i think you need to switch communities. – specializt Sep 06 '14 at 13:40
  • i was talking to Edwin, of course. Well i tried to clone that project but apparently something is wrong with github today, neither am i able to download it as zip anywhere nor does the github-app clone it. Are you able to compress the whole project and put it somewhere else? – specializt Sep 06 '14 at 14:21
  • nevermind, got it running now ... im currently trying to compile, please wait – specializt Sep 06 '14 at 14:28
  • okay, it compiles perfectly with eclipse mars - im guessing luna will also work. I can provide my JAR if you only need the results ... – specializt Sep 06 '14 at 14:29
  • @specializt well thank you so much for compiling and running. Now its proved that its an IDE issue rather than with the pom.xml – rahulserver Sep 06 '14 at 14:47
  • I had a very similar problem in IntelliJ, and this answer seems to be working: http://stackoverflow.com/a/32706984/14379 – seanf Mar 08 '16 at 07:43
  • http://stackoverflow.com/questions/29279859/intellij-14-1-is-too-slow-when-i-import-a-maven-project – baggio Aug 12 '16 at 05:27

4 Answers4

16

If this is an issue very specific to intellij, I would suggest do the following steps You can try running mvn clean install.(Depending on your network speed it will pull every dependency)

Change intellij settings in Preferences->build,execution,deployment->maven->Maven home directory->{now change this to point to your mvn home rather than bundled mvn}

mvn -v in command line should give you the maven home path. Now it won't try to download dependencies again.

rhozet
  • 542
  • 1
  • 6
  • 17
10

File | Settings | Build, Execution, Deployment | Build Tools | Maven | Threads (-T option) | 8 (or however many threads you want to try)

mvn compile -T 8

I had the same issue. Maven was taking an hour in IntelliJ and also running from the command line. Using the -T parameter you can tell Maven to use more threads to download artifacts simultaneously. Takes only about 15 minutes now.

Don't use bundled mvn. Point "Maven home directory" to the path on your file system.

After you're done building. Check "Work offline". This stops mvn from searching remote websites each time you build. Uncheck when you update your POM file so it can search for the changes.

You can also skip tests. This is evertyhing from the command line.

mvn clean install -T 8 -o -DskipTests 
Philip Rego
  • 552
  • 4
  • 20
  • 35
2

Select File, Settings, then set VM options for Maven importing to -Xms1024m -Xmx2048m.

Visit https://www.programmersought.com/article/56414660398/

Kirby
  • 15,127
  • 10
  • 89
  • 104
sarshalom
  • 29
  • 3
0

For me, issue was related to https://repo.maven.apache.org/maven2 and it was not responding. I added another mirror(maven-central.storage.googleapis.com) in settings.xml

Jitendra
  • 59
  • 6