Android Studio - creating a JAR file with dependencies for a standard Java project

I am creating a standard java project, not an android project.

It uses the Gson library from Google. Is there a way to create a JAR file for this project while preserving dependencies on the Gson library? Please correct me if I formulate the question incorrectly.

build.gradle for my module is as follows:

apply plugin: 'java'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile  'com.google.code.gson:gson:2.3'
}

I used the instructions here to create a JAR file, but when I run it from the command line using "java -jar myproject.jar", I get this error:

there is no main manifest attribute in myproject.jar

I tried to find a solution, and it seems that there is no way to create a JAR file with dependencies, although the link above is quite new. It seems that I should make an AAR file in this case.

java, , ?

.

: Manifest.MF "Main-Class: MyMainClassName". JAR . android. , ?

+4

Source: https://habr.com/ru/post/1627458/


All Articles