0

I am developing a Maven project on IntelliJ Idea. I want to say that these things that I mentioned below is worked on Windows, now I am trying this on Ubuntu. I tried to add dependencies with following command:

mvn install:install-file -Dfile=/..pat_here..cytoscapeswing-3.5.1.jar -DgroupId=cytoscapeswing -DartifactId=cytoscapeswing -Dversion=3.5.1 -Dpackaging=jar

And I got "BUILD SUCCESS" message. Then I added this dependency to my project like this:

 <dependency>
        <groupId>cytoscapeswing</groupId>
        <artifactId>cytoscapeswing</artifactId>
        <version>3.5.1</version>
 </dependency>

But when trying to build the project, IntelliJ does not see the library that I added. I mean there were no "cytoscapeswing" library in external library tab. Where am I doing wrong?

JollyRoger
  • 737
  • 1
  • 12
  • 38
  • Have you checked in your local repository that your dependency is properly added? Are you sure your IntelliJ's Maven repository points to the same repository than the one used for your `mvn` command? – DamCx Jan 17 '18 at 08:22
  • 1
    Can you build the project from command line with the mvn command instead of from intellij? – Veselin Davidov Jan 17 '18 at 08:27
  • @DamCx Yes I am sure it points same repository. How can I check local repository? The library that I added does not exist in the list that libraries are listed. – JollyRoger Jan 17 '18 at 08:33
  • @VeselinDavidov I could not find the way to do that, can you write the whole command? I will try. – JollyRoger Jan 17 '18 at 08:34
  • https://www.mkyong.com/maven/where-is-maven-local-repository/ – Sync Jan 17 '18 at 08:34
  • @Synch Yes, it is exist in ~/.m2/repository direction – JollyRoger Jan 17 '18 at 08:36
  • @JollyRoger In IntelliJ, do File > Settings > Build, Execution, Deployment > Build tools > Maven, and there, you'll be able to find the path used for your local repository within Eclipse. Then open the path in your file browser and check if your dependency can be found there or not – DamCx Jan 17 '18 at 08:37
  • @DamCx The path was different from '~/.m2/repository'. But the dependency file is exist here as well. '/home/erkan/.m2/repository' – JollyRoger Jan 17 '18 at 08:43
  • @JollyRoger `~` is shell shorthand for your home directory. – Thorbjørn Ravn Andersen Jan 17 '18 at 08:50
  • '~/.m2/repository' and '/home/erkan/.m2/repository' are two different wayes to write the same path on a linux OS. Then, I can't really explain the difference you are having, then, with the few info we have here – DamCx Jan 17 '18 at 08:54
  • @ThorbjørnRavnAndersen No it is not. Okey I see that '~/.m2/repository' and '/home/erkan/.m2/repository' is same. I am just new at ubuntu. – JollyRoger Jan 17 '18 at 09:01
  • @DamCx I just noticed that '~/.m2/repository' and '/home/erkan/.m2/repository' is same, sorry I am new at ubuntu. What information do you need? – JollyRoger Jan 17 '18 at 09:01
  • In your maven config file, is your local repository configured as a mirror to use? – DamCx Jan 17 '18 at 09:16
  • First make sure you can actually build the project by Maven from command line. This will help to understand if the issue is IDE configuration or the Maven one. In the project directory with your main pom.xml execute `mvn compile`. You may need to add Maven executable (`mvn`) to the PATH environment variable to be able to execute `mvn` command, see https://maven.apache.org/install.html – Andrey Jan 17 '18 at 09:59

3 Answers3

0

Add your dependency in your pom.xml. Then, in IntelliJ while inside pom.xml, right click -> "Maven" -> "Reimport" and let IntelliJ import it for you.

Sync
  • 3,571
  • 23
  • 30
0

First, check the local repository, and make sure the lib is imported successfully.

Then, check the IntelliJ Idea setting, make sure the value of Settings->Build, Exexution, Deployment->Build Tools->Maven->Local repository is the correct path, if not, check the Override box, and overwrite the path.

holten
  • 119
  • 5
  • I have already tried this as well. The path was different but the library that I wanted to add is exist in here as well. Also I change the path to the local repository '~/.m2/repository', but it did not worked again. You can see the same solution recommended by DamCx in the comments of my post that you mentioned. – JollyRoger Jan 17 '18 at 08:49
0

If you executed the mvn install.. command after IntelliJ scanned the local repository it may not have been indexed correctly. This is rare but not unheard of.

Try

File -> Invalidate Caches/Restart -> Invalidate and Restart

to see if it helps on the situation

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • No, unfortunately it did not help. I thought about it before actually but I did not know rescan in this way. So I just restarted IntelliJ, both way did not helped. – JollyRoger Jan 17 '18 at 08:55
  • In that case, you may have made a typo in the installation procedure. Consider looking at https://stackoverflow.com/questions/10802280/multiple-installinstall-file-in-a-single-pom-xml – Thorbjørn Ravn Andersen Jan 17 '18 at 09:15