terl / lazysodium-java

A Java implementation of the Libsodium crypto library. For the lazy dev.
https://github.com/terl/lazysodium-java/wiki
Mozilla Public License 2.0
135 stars 47 forks source link

Trouble installing the lazysodium library in maven #60

Closed yatw closed 4 years ago

yatw commented 4 years ago

Hi, I am getting the Could not find artifact co.libly:resource-loader:pom:1.3.5 in lazysodium-java (https://dl.bintray.com/terl/lazysodium-maven) error when compiling the pom.xml

Here is my maven pom.xml following the instruction from https://docs.lazycode.co/lazysodium/usage/installation


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

    <groupId>xx</groupId>
    <artifactId>testlazysodium</artifactId>
    <version>1.0-SNAPSHOT</version>

    <repositories>
        <repository>
            <id>lazysodium-java</id>
            <url>https://dl.bintray.com/terl/lazysodium-maven</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.goterl.lazycode</groupId>
            <artifactId>lazysodium-java</artifactId>
            <version>4.2.3</version>
        </dependency>

        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>5.5.0</version>
        </dependency>
    </dependencies>

</project>

I also tried to install library using the gradle instruction; gradle works fine. Must be a maven problem then.

gurpreet- commented 4 years ago

Hi @yatw,

The reason why your install fails is because Lazysodium recently packaged the loading of shared libraries into it's own library called resource-loader, simply due to the fact that it was very difficult to extract things out from JARs. The reason this error occurs is because Resource Loader is only available on jCenter, whereas Lazysodium is available on its own repository (https://dl.bintray.com/terl/lazysodium-maven) as well as jCenter.

So in order to solve this, the recommended way now is to use jCenter rather than https://dl.bintray.com/terl/lazysodium-maven. I am not sure how to specify the main jCenter repository in Maven. But once you have it specified, then you can just theoretically just add the following to your pom.xml:

<dependencies>
        <dependency>
            <groupId>com.goterl.lazycode</groupId>
            <artifactId>lazysodium-java</artifactId>
            <version>4.2.3</version>
        </dependency>

        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>5.5.0</version>
        </dependency>
</dependencies>

I have now updated the installation pages in the docs to reflect this.

yatw commented 4 years ago

Thank you for explaining the problem. After setting up the repository to jCenter in maven, I was able to install the library and run SodiumJava sodium = new SodiumJava();

Below is the code used to set up the repository to jCenter in maven.


    <repositories>
        <repository>
            <id>jcenter</id>
            <url>https://jcenter.bintray.com/</url>
        </repository>
    </repositories>

Please consider update the documentation to helper other beginners set up the library. Thanks again.

cekvenich commented 4 years ago

I had to add: implementation 'co.libly:resource-loader:1.3.7' and then it worked.

truthadjustr commented 3 years ago

For my pom.xml I only needed to add the jcenter repository as shown above, and then I add the lazy-sodium and jna dependencies as shown above. But no need to add in pom.xml the resource-loader. I later, checked that resource-loader got automatically downloaded as a transitive dependency of lazy-sodium. Of most curious, is that even if I only add lazy-sodium as a dependency it automatically downloads both jna and resource-loader into .m2/ local repo folder. But the app won't run, I then have to add into pom.xml the jna for the app to run.

LorhanSohaky commented 3 years ago

Please update the documentation. I followed the how to install Lazysodium and was unable to install