Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No clear what is "repository" of algs4 #18

Open
powazny opened this issue Dec 29, 2016 · 6 comments
Open

No clear what is "repository" of algs4 #18

powazny opened this issue Dec 29, 2016 · 6 comments

Comments

@powazny
Copy link

powazny commented Dec 29, 2016

Hello,

What is the Maven dependency and what is the repository we should to use to build application using Maven?

Could you please provide the appropriate entries we can use in pom.xml in the project?

Best regards
Powazny

@Momus
Copy link

Momus commented Jan 2, 2017

OK, so I think I figured this out. If I want to include algs4.jar in your own Maven project, this is what you do (assuming you have Maven installed):

  1. Clone this repo.
  2. Build the jar file with mvn compile
  3. Copy the resulting jar file somewhere handy in your project. I created the lib directory
  4. Install the jar in your project with
  mvn install:install-file -Dfile=lib/algs4-1.0.0.0.jar -DgroupId=edu.princeton.cs -DartifactId=algs4 -Dversion=1.0.0 -Dpackaging=jar

Add the following to your project's pom.xml :

<dependency>
    <groupId>edu.princeton.cs</groupId>
    <artifactId>algs4</artifactId>
    <version>1.0.0</version>
</dependency>

and that seems do it.
In theory one should be able to install the generated jar with mvn install:install-file -Dfile=<path-to-file> but this did not work for me.

As for the Maven Central Repository that didn't seem to work for me at all, and I suspect even if it did, the resulting import statement would be something like import com.google.somethingsomethign which I'd have to change before trying to submit assignments.

I think the algs4.jar from the book site didn't work maybe because of version info? But when you build your own with this repo, you can see what you're getting.

@kevin-wayne
Copy link
Owner

kevin-wayne commented Jan 2, 2017 via email

@ny83427
Copy link

ny83427 commented Dec 19, 2018

Currently there is a algs4 in maven central repository:

<dependency>
    <groupId>edu.princeton.cs</groupId>
    <artifactId>algs4</artifactId>
    <version>1.0.3</version>
</dependency>

From the version number and last update time it seems apparently not done by Princeton but others. The sources there is not synchronized to the latest here, so those who want to use it should keep this in mind - take risk on your own.

@ny83427
Copy link

ny83427 commented Dec 21, 2018

@Momus I don't think it needs that many steps, after clone the repository you just need to execute mvn clean install and all will be settle down.

git clone https://github.com/kevin-wayne/algs4 && mvn clean install

Then add below to your pom.xml:

<dependency>
    <groupId>edu.princeton.cs</groupId>
    <artifactId>algs4</artifactId>
    <version>1.0.0.0</version>
</dependency>

@yudi-azvd
Copy link

yudi-azvd commented Jul 4, 2020

The solution above worked for me 👌.

EDIT: Actually, I needed to cd into algs4 directory before executing mvn clean install. Future readers, keep this in mind.

@WuJieFly
Copy link

@ny83427 very nice !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants