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

Can I just get a jar? #31

Open
vsvxnet opened this issue Dec 27, 2017 · 21 comments
Open

Can I just get a jar? #31

vsvxnet opened this issue Dec 27, 2017 · 21 comments

Comments

@vsvxnet
Copy link

vsvxnet commented Dec 27, 2017

I just want the jar. ./gradlew jar does not work. i dont want to run this in spring boot. just standalone java application.

@verona-rupes
Copy link

Just run the command gradle jar in project folder. Then go to build folder. You will see gdax-java-0.9.0.jar

@rjpg
Copy link

rjpg commented Jan 12, 2018

And directly download a jar and an example with it is not possible ?

(Like big players do like google for example with tensorflow for java .... you go to the site download a ready to use jar file and them see examples using that jar ... simple dont you think ? )

@robevansuk
Copy link
Collaborator

./gradlew jar

then the file should appear under build/gdax-java-[VERSION].jar

@robevansuk
Copy link
Collaborator

its not on maven yet but no reason why it can't be

@rjpg
Copy link

rjpg commented Jan 22, 2018

Using maven it is a real pain... I was force to use maven to use DL4J in my project. I just wanted to include a DL4J.JAR in a bigger project. Generate DL4J.JAR was a titanic operation (I only manage to produce the jar with the maven eclipse plugin - maven command line did not do the job ...). In the end I end up with a DL4J.JAR of 400MB that is bigger than the entire project (because maven force the inclusion of many many things that were not needed to have a stand alone jar) and impossible to upload it in github ...

Result: forget DL4J and use tensorflow in java. Google provide a small tensoflow.jar (ready to download) that was simple to include in any project.

In this project (gdax-java ) it is easy to have a jar but you have to put the credentials inside the jar (not good).

And on top of that we are force to learn spring. I did not look into spring yet but it seams I will have to change the base logic of my project where I want to include gdax-java just because of "spring" ...

@robevansuk
Copy link
Collaborator

It really shouldn't be so hard. This is why build tools exist (like Gradle). Managing dependencies by downloading them isn't transferrable from one machine to the next so easily. Also managing the correct versions of dependencies will become more difficult if you do it manually.

Regarding the credentials being difficult to manage - we will look into this. I know others have managed to make use of the codebase as a lib successfully but its not something I've done and so it hasn't been documented yet. I'm working on a live orderbook that will initially be applied on top of the existing codebase. Once thats done, I'll attempt to put it into a separate codebase entirely which will be independent of the API. Hopefully then that can act as a live document/example of how to use this codebase as a library.

@robevansuk
Copy link
Collaborator

robevansuk commented Jan 22, 2018

Being forced to learn spring... hmm. I guess if you embrace Spring within Java you will find it makes your life orders of magnitude easier. I tried to create a project similar to this before now without spring. It became spaghetti code and unmanageable. I've since been back and begun converting it to a Spring application and the resulting code is SOO much better, more readable, more manageable, more maintainable. I can't sing and dance enough about how much faster I can now develop applications. I'm a relative novice with it too. But I get where you're coming from. I was once (in the not too distant past) incapable of understanding Spring too. Since I now understand it and use it on enterprise projects I can tell you its a necessity for any larger scale system, which this could easily become. Start with the right foundations.... That said, there are 76 Forks of the codebase - some have been amended to remove spring (if I remember correctly). You only have to look at what others have done (I will not do this portion of leg work for you) to find a version that works for you. Before this version, from what research I did, there was relatively little choice in what you could work with. Having this library has opened up the gates for many others to improve it.

@rjpg
Copy link

rjpg commented Jan 23, 2018

But if you have already a big Java project (related with markets trading.. with scalping, trailing-stops, swing mechanism, already implemented in generic form and machine learning methods already integrated etc, etc ) and just want to read data and include it in this project (that does not use spring) it will be a nightmare that would be solved with a simple pure java JAR to connect and retrieve data and put simple orders on the market ...

This API, that should be simple (because it is just a communication API nothing more ) to integrate in any project, will force the host java code/framework to use spring logic ...

Does it makes sense to build a JAR simple communication base API based on spring (?)
You are reducing your "audience target" to spring users ...

@rjpg
Copy link

rjpg commented Jan 23, 2018

Just was with a friend here that does not understand nothing about computers and I have explain to him :
"Just want a line code to :
1- log in
2- select the market
3- Read the market
4- put orders "

And he said :
" OK I see ... you want that simple calls and they send you to learn a new framework "spring" "

lol

@robevansuk
Copy link
Collaborator

robevansuk commented Feb 16, 2018

log in - there is no login - all requests are signed with a secret unique to the user and cryptographic hashing.
select the market & read the market - offered by MarketDataService.getMarketData(productId, level);
put orders - offered by OrderService.createOrder(yourOrder)

It really is simpler with Spring.

Perhaps you can provide a bit more detail about which java project you're trying to integrate this with? I'm soon going to start looking at writing the documentation for using this more as a library

@robevansuk
Copy link
Collaborator

Looking to publish to maven as a next step so the libs can be depended on independently

@rjpg
Copy link

rjpg commented Jul 27, 2020

I have give up on this a longo time ago because of spring... Using bitmex Java Simple to use implementation

irufus added a commit that referenced this issue Oct 22, 2020
#31 re-add lost update to websocket feed's object mapper
@irufus
Copy link
Owner

irufus commented Oct 23, 2020

Using bitmex Java

That's a different exchange but glad you were able to find something that you can work with.

@andreffrosa
Copy link

Doing ./gradlew build produces an empty jar for the whole project. However, it does produce a jar for each subproject (api, ...). How can I make a "fat-jar" to be included in a project? Do I have to include each subproject independently?

@robevansuk
Copy link
Collaborator

robevansuk commented Nov 26, 2020

#74 - one jar that contains everything. I've merged this to master

@robevansuk
Copy link
Collaborator

robevansuk commented Nov 26, 2020

try ./gradlew shadowJar - this should contain everything - let us know if this works for you. I'll add it to the docs if all's good. My initial attempt was untested. I've since checked the results and found everything is present in the big jar. It'll output to ${rootProjectDir}/build/libs/coinbase-pro-java-0.11.0-all.jar

@andreffrosa
Copy link

try ./gradlew shadowJar - this should contain everything - let us know if this works for you. I'll add it to the docs if all's good. My initial attempt was untested. I've since checked the results and found everything is present in the big jar. It'll output to ${rootProjectDir}/build/libs/coinbase-pro-java-0.11.0-all.jar

It worked. Thanks!

@Coalado
Copy link

Coalado commented Jan 15, 2021

This might be a kind of stupid question, but is it possible the the gradlescript does not work?

I get this error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':compileJava'.
> Could not resolve all task dependencies for configuration ':compileClasspath'.
   > Could not resolve project :api.
     Required by:
         project :
      > Unable to find a matching variant of project :api:
          - Variant 'apiElements' capability com.coinbase.exchange:api:0.11.0:
              - Found org.gradle.category 'library' but wasn't required.
              - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
              - Required org.gradle.jvm.version '8' and found incompatible value '11'.
              - Required org.gradle.usage 'java-api' and found compatible value 'java-api-jars'.
          - Variant 'runtimeElements' capability com.coinbase.exchange:api:0.11.0:
              - Found org.gradle.category 'library' but wasn't required.
              - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
              - Required org.gradle.jvm.version '8' and found incompatible value '11'.
              - Required org.gradle.usage 'java-api' and found compatible value 'java-runtime-jars'.
   > Could not resolve project :model.
     Required by:
         project :
      > Unable to find a matching variant of project :model:
          - Variant 'apiElements' capability com.coinbase.exchange:model:0.11.0:
              - Found org.gradle.category 'library' but wasn't required.
              - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
              - Required org.gradle.jvm.version '8' and found incompatible value '11'.
              - Required org.gradle.usage 'java-api' and found compatible value 'java-api-jars'.
          - Variant 'runtimeElements' capability com.coinbase.exchange:model:0.11.0:
              - Found org.gradle.category 'library' but wasn't required.
              - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
              - Required org.gradle.jvm.version '8' and found incompatible value '11'.
              - Required org.gradle.usage 'java-api' and found compatible value 'java-runtime-jars'.
   > Could not resolve project :security.
     Required by:
         project :
      > Unable to find a matching variant of project :security:
          - Variant 'apiElements' capability com.coinbase.exchange:security:0.11.0:
              - Found org.gradle.category 'library' but wasn't required.
              - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
              - Required org.gradle.jvm.version '8' and found incompatible value '11'.
              - Required org.gradle.usage 'java-api' and found compatible value 'java-api-jars'.
          - Variant 'runtimeElements' capability com.coinbase.exchange:security:0.11.0:
              - Found org.gradle.category 'library' but wasn't required.
              - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
              - Required org.gradle.jvm.version '8' and found incompatible value '11'.
              - Required org.gradle.usage 'java-api' and found compatible value 'java-runtime-jars'.
   > Could not resolve project :websocketfeed.
     Required by:
         project :
      > Unable to find a matching variant of project :websocketfeed:
          - Variant 'apiElements' capability com.coinbase.exchange:websocketfeed:0.11.0:
              - Found org.gradle.category 'library' but wasn't required.
              - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
              - Required org.gradle.jvm.version '8' and found incompatible value '11'.
              - Required org.gradle.usage 'java-api' and found compatible value 'java-api-jars'.
          - Variant 'runtimeElements' capability com.coinbase.exchange:websocketfeed:0.11.0:
              - Found org.gradle.category 'library' but wasn't required.
              - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
              - Required org.gradle.jvm.version '8' and found incompatible value '11'.
              - Required org.gradle.usage 'java-api' and found compatible value 'java-runtime-jars'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s

@robevansuk
Copy link
Collaborator

robevansuk commented Jan 15, 2021

what version of gradle are you running with? It worked last time I checked.

@Coalado
Copy link

Coalado commented Jan 15, 2021

I found the issue. I had Java 1.8 in my java_path. Everything works fine with 11

@patrickwyler
Copy link

patrickwyler commented Feb 18, 2021

Hey all
I had the same problem like others of you and created an easy solution for it.

I had the use case that I just wanted some parts of this project (api/model/security) so I created a script which is cloning this repo, building it and pushing the final jars to a local maven repository. Now I can use them like any other dependency in my project.

Steps

  1. Create a folder named local-maven-repo in the root of your project

  2. Create this bash script in the root folder of your project

     #/bin/bash
     localMavenFolder=$(pwd)/local-maven-repo
     tmpFolder=$(pwd)/tmp-gdax-java
     version=0.11.0
    
     git clone https://github.com/irufus/gdax-java.git $tmpFolder
     cd $tmpFolder
     ./gradlew shadowJar
    
     cd $tmpFolder/api/build/libs
     mvn install:install-file \
        -Dfile=api-$version.jar \
        -DgroupId=com.irufus.coinbase-pro-client \
        -DartifactId=api \
        -Dversion=$version \
        -Dpackaging=jar \
        -DlocalRepositoryPath=$localMavenFolder \
        -DcreateChecksum=true
    
     cd $tmpFolder/security/build/libs
     mvn install:install-file \
        -Dfile=security-$version.jar \
        -DgroupId=com.irufus.coinbase-pro-client \
        -DartifactId=security \
        -Dversion=$version \
        -Dpackaging=jar \
        -DlocalRepositoryPath=$localMavenFolder \
        -DcreateChecksum=true
    
     cd $tmpFolder/model/build/libs
     mvn install:install-file \
        -Dfile=model-$version.jar \
        -DgroupId=com.irufus.coinbase-pro-client \
        -DartifactId=model \
        -Dversion=$version \
        -Dpackaging=jar \
        -DlocalRepositoryPath=$localMavenFolder \
        -DcreateChecksum=true
    
  3. Execute the bash script

  4. Add the local maven repository to your build configuration (pom.xml)

     <repositories>
         <repository>
             <id>project.local</id>
             <name>project</name>
             <url>file://${project.basedir}/local-maven-repo</url>
         </repository>
     </repositories>
    
  5. Add dependencies (pom.xml)

     <dependency>
         <groupId>com.irufus.coinbase-pro-client</groupId>
         <artifactId>api</artifactId>
         <version>0.11.0</version>
     </dependency>
     <dependency>
         <groupId>com.irufus.coinbase-pro-client</groupId>
         <artifactId>security</artifactId>
         <version>0.11.0</version>
     </dependency>
     <dependency>
         <groupId>com.irufus.coinbase-pro-client</groupId>
         <artifactId>model</artifactId>
         <version>0.11.0</version>
     </dependency>
    
  6. Build project mvn clean install

  7. Done
    Bildschirmfoto 2021-02-18 um 14 57 32

Now you can use them as described here: https://github.com/irufus/gdax-java/blob/master/CONTRIBUTING.md

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

No branches or pull requests

8 participants