3

I'm trying to build the project from this site http://www.joptimizer.com/usage.html. I downloaded the sources jar file, unpacked it and ran maven package in the root folder. Maven fails at the last minute saying it couldn't resolve the dependency..

could not find artifact seventytwomiles:architecture-rules:jar:3.0.0-M1 in central repo - repo.maven.apache.org/maven2 .. 

I have a feeling I might need to change something in the pom.xml file for this to work, but have no idea what. Googling for this missing dependency lead me no where. In general, how would one know what to do to handle such errors (and also please help with this specific case).

Tuna
  • 2,937
  • 4
  • 37
  • 61
Rohit Pandey
  • 2,443
  • 7
  • 31
  • 54

3 Answers3

7

Specifically

According to the Building notes on http://www.joptimizer.com/usage.html:

JOptimizer is build on maven 3.0. Before building it, you must resolve (in pom.xml) the external dependency on Colt and other dependencies that aren't in public repositories. Please refer to the "Dependencies" report for a complete treatment. For ease of use a boundle with these external libraries is provided (visit "Download"): extract the boundle in a folder and run the "maven-install.cmd" (translate it in your own shell language), and you will get the artifacts in your local repository.

To get the bundle for this, go to http://sourceforge.net/projects/cvxopt/files/, and download the appropriate version of joptimizer-3.X.X-dependencies.zip. Unzip in your own folder, and run mvn install:install-file -DgroupId=seventytwomiles -DartifactId=architecture-rules -Dversion=3.0.0-M1 -Dpackaging=jar -Dfile=architecture-rules-3.0.0-M1.jar -DpomFile=architecture-rules-3.0.0-M1.pom

Generally

Use a tool like http://mavenrepository.com to search for another version of the missing dependency and update your POM with the proper version. If MVNRepository doesn't know about it, you can install the dependency yourself. If you are working with a group of developers, as Eric Jablow mentions, an artifact repository like Nexus or Artifactory is great for sharing non-public dependencies. If it's just you, you can install the artifact in your local repo as described here: How to manually install an artifact in Maven 2?

Community
  • 1
  • 1
lreeder
  • 12,047
  • 2
  • 56
  • 65
  • Thank you sir! I tried these steps and then tried mvn package and every thing worked. I produced the binaries in the target folder. However, now I include the jar in my project and try to run the sample code but I get an error saying - NoClassDefFoundError for cern/colt/matrix/linalg/Algebra. Is it best to just try and get the jar file for that one separately? – Rohit Pandey Sep 14 '13 at 02:23
  • And this despite the fact that the pom.xml file of joptimizer already had the colt dependency in it. – Rohit Pandey Sep 14 '13 at 02:26
  • colt-1.2.0.jar is included in the dependency package you downloaded from sourceforge, and contains `cern/colt/matrix/linalg/Algebra`. Make sure the colt jar is in the classpath when you run the sample code. – lreeder Sep 14 '13 at 02:29
  • Alright, I added all the jars to my project and it worked! Thanks a ton! – Rohit Pandey Sep 14 '13 at 02:38
1

You should add your own repository manager like Nexus or Artifactory. Then, find out where this dependency is kept; there are repositories other than central. If it's kept on another repository, have your repository mirror that too.

Otherwise, Nexus or Artifactory have commands to enter the dependency manually. Create a local repository called "Third-party" and add it there.

Finally, change your settings.xml file to refer everything to your repository manager.

The most common case for this is when a company refuses to license their products to be held at the central repository. For example, Microsoft won't let its sqljdbc.jar file be distributed through Central. So, you need to add it by hand.

Eric Jablow
  • 7,874
  • 2
  • 22
  • 29
  • I'm sorry, but I'm a newbie at this dependency resolution stuff. How do I create a local repository? And then, where in the settings.xml file do I make the change and what do I add? – Rohit Pandey Sep 14 '13 at 01:52
  • Also, I see a build.xml, catalog.xml and pom.xml but no settings.xml file in the root folder of my project. – Rohit Pandey Sep 14 '13 at 01:53
  • `settings.xml` is usually in your local system because it applies to all your projects. It does not apply to a specific project. On a Unix system, it's usually `~/.m2/settings.xml`. The Maven page is http://maven.apache.org/settings.html. And this shows how to configure `settings.xml` to use Nexus: http://books.sonatype.com/nexus-book/reference/config.html. – Eric Jablow Sep 14 '13 at 02:09
  • Oh, and when you install Maven, it creates a local repository, again in `~/.m2`. – Eric Jablow Sep 14 '13 at 02:27
0

Change the dependency as follows

<dependency>
  <groupId>org.architecturerules</groupId>
  <artifactId>architecture-rules</artifactId>
  <version>3.0.0-rc1</version>
  <scope>test</scope>
</dependency>

Add the repository in pom

  <repositories>
    <repository>
      <id>architecturerules.googlecode.com</id>
      <url>http://architecturerules.googlecode.com/svn/maven2/</url>
    </repository>
 </repositories>
Badal Singh
  • 918
  • 1
  • 6
  • 13