Я думаю, проблема связана с манифестом.
IDE -
Intellij - 2019.2
Gradle Project
Код: Выделить всё
Java - java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
Код: Выделить всё
plugins {
id 'java'
}
group 'com.HelloWorldTesting'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
jar {
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes(
'Implementation-Title': 'Hello World',
"Main-Class": "com.HelloWorldTesting.Hello"
)
}
archivesBaseName = 'app'
}
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
Код: Выделить всё
public class Hello {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
}
Ошибка: неверный или поврежденный jar-файл HelloWorldArt.main.jar
дерево -
.
├── build
│ ├── классы
│ │ └── java
│ │ └── main
│ │ └── Hello.class
│ └── tmp
│ └── компиляцияJava
├── build.gradle
├── gradle
│ └── оболочка
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── META-INF
│ └── MANIFEST.MF
├── out
│ └── артефакты
│ ├── HelloWorldArt_jar
│ │ └── HelloWorldArt.jar
│ └── HelloWorldArt_main_jar
│ └── HelloWorldArt.main.jar
├── settings.gradle
├── src
│ ├── main
│ │ ├── java
│ │ │ ├── Hello.java
│ │ │ └── META-INF
│ │ │ └── MANIFEST.MF
│ │ └── ресурсы
│ └── тест
│ ├── java
│ └── ресурсы
Подробнее здесь: https://stackoverflow.com/questions/572 ... pt-jarfile
Мобильная версия