にはどうすればいいほどのGradleから脂肪JARを実行するためのGradle アプリケーションにプラグインを利用することになる。構築された太いJARをgradleタスクとして実行するには?
[email protected]:~/NetBeansProjects/selenium$
[email protected]:~/NetBeansProjects/selenium$ gradle clean fatJar;java -jar build/libs/selenium-all.jar
BUILD SUCCESSFUL in 23s
4 actionable tasks: 4 executed
Jul 18, 2017 7:47:49 PM net.bounceme.dur.web.selenium.Main main
INFO: running..
1500432473386 geckodriver INFO Listening on 127.0.0.1:30879
1500432475320 geckodriver::marionette INFO Starting browser /usr/lib/firefox/firefox with args ["-marionette"]
1500432488971 addons.xpi WARN Add-on [email protected] is not compatible with application version.
1500432488978 addons.xpi WARN Add-on [email protected] is not compatible with application version.
1500432489767 addons.xpi WARN Add-on [email protected] is not compatible with application version.
1500432489769 addons.xpi WARN Add-on [email protected] is not compatible with application version.
^[email protected]:~/NetBeansProjects/selenium$
build.gradle:私は脂肪のJARを必要条件とする
plugins {
id 'com.gradle.build-scan' version '1.8'
id 'java'
id 'application'
}
mainClassName = 'net.bounceme.dur.web.selenium.Main'
buildScan {
licenseAgreementUrl = 'https://gradle.com/terms-of-service'
licenseAgree = 'yes'
}
repositories {
jcenter()
}
jar {
manifest {
attributes 'Main-Class': 'net.bounceme.dur.web.selenium.Main'
attributes 'Class-path': 'selenium-java-3.4.0.jar'
}
}
task fatJar(type: Jar) {
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': '3.4.0'
attributes 'Main-Class': 'net.bounceme.dur.web.selenium.Main'
}
}
dependencies {
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.4.0'
compile group: 'org.seleniumhq.selenium', name: 'selenium-server', version: '3.4.0'
compile group: 'org.seleniumhq.selenium', name: 'selenium-firefox-driver', version: '3.4.0'
compile group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: '3.4.0'
compile group: 'org.seleniumhq.selenium', name: 'selenium-ie-driver', version: '3.4.0'
compile group: 'org.seleniumhq.selenium', name: 'selenium-safari-driver', version: '3.4.0'
compile group: 'org.seleniumhq.selenium', name: 'selenium-edge-driver', version: '3.4.0'
}
実際に実際に JARファイルをビルドして実行します。 CLIからfatJARを実行しているcontext。
参考:
https://docs.gradle.org/current/userguide/userguide_single.html
Running an executable jar file built from a gradle based project
Run jar with parameters in gradle
How to execute jar file in gradle?