I'm trying to clean build project with Spring boot plugin and getting the following message:
Execution failed for task ':lecture05:findMainClass'.
Unable to find a single main class from the following candidates [ru.atom.boot.mm.MatchMakerApp, ru.atom.boot.hw.HelloSpringBoot]
I can't find any information for this case here. I've found a couple of questions like this, but this is for maven. How to config my project correctly?
I was trying to add
bootRepackage {
mainClass = 'ru.atom.boot.mm.MatchMakerApp'
}
to build.gradle
My root project:
plugins {
id 'org.springframework.boot' version '1.5.8.RELEASE'
id 'com.github.kt3k.coveralls' version '2.6.3'
}
bootRepackage {
mainClass = 'ru.atom.boot.mm.MatchMakerApp'
}
ext {
jdkVersion = 1.9
jettyVersion = "9.4.7.v20170914"
junitVersion = "4.12"
jacksonVersion = "2.9.1"
log4jVersion = "2.7"
jetbrainsAnnotationVersion = "15.0"
okhttpVersion = "3.6.0"
jerseyVersion = "2.26"
gsonjVersion = "2.7"
postgresVersion = "9.4-1200-jdbc41"
jetbrainsAnnotationVersion = "15.0"
hibernateVersion = "5.2.3.Final"
websocketVersion = "9.4.3.v20170317"
jolVersion = "0.8"
}
allprojects {
group = "technoatom"
version = "1.0-SNAPSHOT"
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
repositories {
mavenCentral()
}
sourceCompatibility = jdkVersion
targetCompatibility = jdkVersion
}
subprojects {
checkstyle {
ignoreFailures = false
toolVersion = '7.5'
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
}
tasks.withType(Checkstyle) {
reports {
xml.enabled false
html.destination
"$rootProject.buildDir/report/${project.name}.html"
html.stylesheet
resources.text.fromFile(rootProject.file('config/checkstyle/checkstyle-custom.xsl'))
}
}
}
ext.libraries = [
spring_boot : [
"org.springframework.boot:spring-boot-starter-web",
"org.springframework.boot:spring-boot-starter-actuator"
],
spring_boot_test : "org.springframework.boot:spring-boot-starter-test",
jetty_server : "org.eclipse.jetty:jetty-server:$jettyVersion",
jetty_servlet: "org.eclipse.jetty:jetty-servlet:$jettyVersion",
junit: "junit:junit:$junitVersion",
log4j: [
"org.apache.logging.log4j:log4j-api:$log4jVersion",
"org.apache.logging.log4j:log4j-core:$log4jVersion"
],
jetbrainsAnnotations: "org.jetbrains:annotations:$jetbrainsAnnotationVersion",
okhttp: "com.squareup.okhttp3:okhttp:$okhttpVersion",
jersey_server: "org.glassfish.boot.core:boot-server:$jerseyVersion",
jersey_hk2: "org.glassfish.boot.inject:boot-hk2:$jerseyVersion",
jersey_containers: "org.glassfish.boot.containers:boot-container-servlet:$jerseyVersion",
jersey_test:
"org.glassfish.boot.test-framework.providers:boot-test-framework-provider-grizzly2:$jerseyVersion",
gson: "com.google.code.gson:gson:$gsonjVersion",
postgres: "org.postgresql:postgresql:$postgresVersion",
hibernate: "org.hibernate:hibernate-core:$hibernateVersion",
websocketclient: "org.eclipse.jetty.websocket:websocket-client:$websocketVersion",
websocketserver: "org.eclipse.jetty.websocket:websocket-server:$websocketVersion",
websocketapi: "org.eclipse.jetty.websocket:websocket-api:$websocketVersion",
jackson: "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion",
jol: "org.openjdk.jol:jol-core:$jolVersion",
jol_samples: "org.openjdk.jol:jol-samples:$jolVersion"
]
jacocoTestReport {
additionalSourceDirs =
files(subprojects.sourceSets.main.allSource.srcDirs)
sourceDirectories =
files(subprojects.sourceSets.main.allSource.srcDirs)
classDirectories = files(subprojects.sourceSets.main.output)
executionData = files(subprojects.jacocoTestReport.executionData)
onlyIf = {
true
}
reports {
xml.enabled = true
html.enabled = true
}
doFirst {
executionData = files(executionData.findAll {
it.exists()
})
}
}
coveralls {
sourceDirs =
files(subprojects.sourceSets.main.allSource.srcDirs).files.absolutePath
}
Subproject, I'm trying to build, that has two Main classes:
dependencies {
compile rootProject.libraries.spring_boot
compile rootProject.libraries.log4j
testCompile rootProject.libraries.junit
testCompile rootProject.libraries.spring_boot_test
}
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
}
test {
java {
srcDirs = ['src/test/java']
}
}
}
Try to replace it with:
springBoot {
mainClass = 'ru.atom.boot.mm.MatchMakerApp'
}
As jprism mentioned you can read more in Spring Boot plugin docs
Related
I am having a Gradle spring-boot project and getting the following error when starting the application.
Ran this cmd: gradle clean bootRun --warning-mode all
ptEvaluatorFactory as ValidatorFactory-scoped script evaluator factory.
14:06:27.154 [restartedMain] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalArgumentException: Unable to instantiate factory class: org.springframework.boot.env.EnvironmentPostProcessor
at org.springframework.core.io.support.SpringFactoriesLoader.instantiateFactory(SpringFactoriesLoader.java:167)
at org.springframework.core.io.support.SpringFactoriesLoader.loadFactories(SpringFactoriesLoader.java:104)
at org.springframework.boot.context.config.ConfigFileApplicationListener.loadPostProcessors(ConfigFileApplicationListener.java:183)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:173)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:163)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:347)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:306)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at app.EventsApplication.main(EventsApplication.java:25)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.NoSuchMethodException: org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.<init>()
at java.base/java.lang.Class.getConstructor0(Class.java:3349)
at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2553)
at org.springframework.util.ReflectionUtils.accessibleConstructor(ReflectionUtils.java:530)
at org.springframework.core.io.support.SpringFactoriesLoader.instantiateFactory(SpringFactoriesLoader.java:164)
... 20 common frames omitted
BUILD SUCCESSFUL in 7s
I tried updating to the newer version of gradle to springboot and even deleted the local cache. Restarted the intellij by invalidating the cache etc,but no luck.
This is the build.gradle file.
buildscript {
dependencies {
classpath 'org.postgresql:postgresql:42.2.24'
classpath 'com.smartnews:jpa-entity-generator:0.99.8'
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.4.0.RELEASE")
}
}
plugins {
// id 'com.diffplug.spotless' version '5.15.1'
id 'com.github.ben-manes.versions' version '0.39.0'
id 'com.github.johnrengelman.processes' version '0.5.0'
id 'com.github.spotbugs' version '4.7.5'
id 'com.star-zero.gradle.githook' version '1.2.1'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.flywaydb.flyway' version '7.15.0'
id 'org.springframework.boot' version '2.4.0'
id 'org.owasp.dependencycheck' version '6.3.2'
id 'org.sonarqube' version '3.3'
id 'org.springdoc.openapi-gradle-plugin' version '1.3.3'
id 'pl.allegro.tech.build.axion-release' version '1.13.3'
id 'ru.netris.commitlint' version '1.4.1'
id 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' version '1.71.4'
id 'checkstyle'
id 'java'
id 'jacoco'
id 'pmd'
}
group = 'app'
version = "1.0.0"
//sourceCompatibility = '11' VERSION_11
java.sourceCompatibility = JavaVersion.VERSION_11
apply plugin: 'entitygen'
repositories {
mavenCentral()
// mavenLocal()
maven {
url "http://nexus.infra.cloud.247-inc.net:8080/nexus/repository/greleases/"
allowInsecureProtocol = true
}
}
sourceSets {
integrationTest {
compileClasspath += main.output
runtimeClasspath += main.output
}
smokeTest {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
processResources {
filesMatching("**/application.properties") {
expand(project.properties)
}
}
dependencies {
annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok-mapstruct-binding:0.2.0'
implementation 'assist:kafka-connector:4.0.0'
implementation 'org.projectlombok:lombok:1.18.22'
implementation 'org.mapstruct:mapstruct:1.4.2.Final'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'io.springfox:springfox-boot-starter:3.0.0'
implementation 'io.springfox:springfox-swagger-ui:3.0.0'
runtimeOnly 'org.postgresql:postgresql:42.2.24'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.assertj:assertj-core:3.21.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.testcontainers:testcontainers:1.16.0'
testImplementation 'org.testcontainers:junit-jupiter:1.16.0'
testImplementation 'org.testcontainers:postgresql:1.16.0'
developmentOnly("org.springframework.boot:spring-boot-devtools")
integrationTestImplementation sourceSets.main.runtimeClasspath
integrationTestImplementation sourceSets.test.runtimeClasspath
smokeTestImplementation sourceSets.main.runtimeClasspath
smokeTestImplementation sourceSets.test.runtimeClasspath
}
githook {
failOnMissingHooksDir = false
hooks {
'commit-msg' {
task = 'commitlint'
}
}
}
openApi {
outputDir = file('build/docs')
}
bootBuildImage {
imageName = 'spring-api:latest'
}
checkstyle {
toolVersion = '9.0'
configFile = file('checkstyle.xml')
}
pmd {
toolVersion = '6.38.0'
ignoreFailures = true
}
//spotless {
// java {
// target 'src/**/*.java'
// importOrder()
// removeUnusedImports()
// prettier([
// 'prettier': '2.4.1',
// 'prettier-plugin-java': '1.4.0'
// ]).configFile('.prettierrc')
// }
//}
spotbugs {
toolVersion = '4.4.1'
ignoreFailures = true
}
sonarqube {
properties {
property 'sonar.projectKey', 'voice-reporting-events-generator'
property 'sonar.projectName', 'voice-reporting-events-generator'
property "sonar.sourceEncoding", "UTF-8"
property "sonar.jacoco.reportPath", "./build/jacoco/test.exec"
property "sonar.host.url", "http://sonar.cicd.247-inc.net:8080"
property "sonar.sources", "./src/main/java"
property "sonar.tests", "./src/test/java"
property "sonar.java.binaries", "./build/classes/java/main/"
property "sonar.java.test.binaries", "./build/classes/java/test/"
property "sonar.inclusions", "**/*.java"
property "sonar.exclusions", "**/*Generated.java"
property "http.proxyHost", "10.64.99.240"
property "http.proxyPort", "3128"
property "https.proxyHost", "10.64.99.240"
property "https.proxyPort", "3128"
}
}
flyway {
url = DB_URL
user = DB_USER
password = DB_PASSWORD
}
entityGen {
configPath = 'src/main/resources/db/entity-generator.yaml'
}
jacoco {
toolVersion = '0.8.7'
}
jacocoTestReport {
dependsOn test
finalizedBy jacocoTestCoverageVerification
reports {
xml.required = true
}
}
jacocoTestCoverageVerification {
dependsOn test
violationRules {
rule {
limit {
minimum = 0.5
}
}
}
}
test {
finalizedBy jacocoTestReport
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
task integrationTest(type: Test) {
description = 'Runs the integration tests.'
group = 'Verification'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
task smokeTest(type: Test) {
description = 'Runs the smoke tests.'
group = 'Verification'
testClassesDirs = sourceSets.smokeTest.output.classesDirs
classpath = sourceSets.smokeTest.runtimeClasspath
useJUnitPlatform()
testLogging {
exceptionFormat = 'full'
}
}
task generateEntities(type: Exec) {
description = 'Generates the entities sources.'
group = 'Build'
commandLine './gradlew', 'entityGen', 'format'
environment([DB_URL: DB_URL, DB_USER: DB_USER, DB_PASSWORD: DB_PASSWORD])
doLast {
ant.replace(token: '\\\"', value: '') {
fileset(dir: 'src/main/java/app/entity')
}
}
}
task lint() {
dependsOn 'formatCheck', 'checkstyle' , 'pmd', 'spotbugs'
description = 'Runs several static code analysis.'
group = 'Verification'
}
task checkstyle() {
dependsOn 'checkstyleIntegrationTest', 'checkstyleMain', 'checkstyleSmokeTest', 'checkstyleTest'
description = 'Runs Checkstyle analysis for the source folder.'
group = 'Verification'
}
task pmd() {
dependsOn 'pmdIntegrationTest', 'pmdMain'
description = 'Runs PMD analysis for the source folder.'
group = 'Verification'
}
task spotbugs() {
dependsOn 'spotbugsIntegrationTest', 'spotbugsMain', 'spotbugsSmokeTest', 'spotbugsTest'
description = 'Runs SpotBugs analysis for the source folder.'
group = 'Verification'
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
reports {
html.enabled = true
}
}
}
task format() {
dependsOn 'spotlessApply'
description = 'Applies code formatting steps to source code in-place.'
group = 'Verification'
}
task formatCheck() {
dependsOn 'spotlessCheck'
description = 'Checks that source code satisfies formatting steps.'
group = 'Verification'
}
task generateChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
description = 'Generates a changelog from GIT repository.'
group = 'Release'
fromRepo = file('.')
file = file('CHANGELOG.md');
templateContent = file('changelog.mustache').getText('UTF-8');
}
task deploy(type: Exec) {
commandLine 'ansible-playbook', 'cicd/deploy/deploy-to-swarm.yaml'
description = 'Deploys the application to Docker Swarm.'
group = 'Release'
}
jar {
baseName = 'base-name'
version = '1.0.0'
manifest {
attributes 'Main-Class': 'app.EventsApplication'
}
}
task fatJar(type: Jar) {
manifest.from jar.manifest
// classifier = 'all'
from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
} {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
with jar
}
artifacts {
archives fatJar
}
springBoot {
buildInfo()
}
bootJar {
archiveBaseName = rootProject.name
archiveVersion = rootProject.version
}
ext {
set('springCloudVersion', "Hoxton.SR8")
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
I am trying to build my Java 11 project to have either an executable jar (FatJar, SuperJar, whatever its called) or an EXE or any form of runnable version even a batch file (Using Application). Everything I try I either get JavaFX is missing or my dependencies included the packages arent visible and it error's out.
Here is my build.gradle
plugins {
id 'application'
id 'java'
id 'maven-publish'
id 'org.openjfx.javafxplugin' version '0.0.8'
id 'edu.sc.seis.launch4j' version '2.4.6'
id 'org.beryx.jlink' version '2.12.0'
}
application {
mainClassName = 'sassa.sassa.Main'
}
repositories {
mavenLocal()
maven {
url = uri('https://jitpack.io')
}
maven {
url = uri('https://repo.maven.apache.org/maven2')
}
}
javafx {
version = "11.0.2"
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.graphics' ]
}
jlink {
launcher {
name = 'sassa'
}
}
dependencies {
implementation 'com.github.toolbox4minecraft:amidst:v4.4-beta1'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
}
jar {
manifest {
attributes("Manifest-Version": "1.0",
"Main-Class": "sassa.main.Main");
}
}
compileJava {
doFirst {
println "CLASSPATH IS $classpath.asPath"
options.compilerArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'javafx.graphics',
'--add-modules', 'javafx.controls',
'--add-modules', 'javafx.fxml'
]
classpath = files()
}
}
task fatJar(type: Jar) {
manifest.from jar.manifest
classifier = 'all'
from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
} {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
with jar
}
launch4j {
mainClassName = 'sassa.main.Main'
icon = "${projectDir}/src/main/resources/sassa/sassa.ico"
jreMinVersion = '11'
jreMaxVersion = '14'
jdkPreference = 'preferJre'
initialHeapSize = 128
maxHeapSize = 512
stayAlive = false
bundledJre64Bit = true
dontWrapJar = true
bundledJrePath = 'jre'
}
group = 'sassa'
version = '0.5.0'
sourceCompatibility = '11'
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
Also for the layout of the project it is on github (I was using maven before but figured Gradle might work better. (The maven code is still on github) https://github.com/Zodsmar/SeedSearcherStandaloneTool/tree/development
Literally I have tried everything and I just can't seem to get a buildable version to distribute...
Also I have read up about module.info files I do not have any I want to have a simple build.gradle that just includes everything I need to build an executable.
To anyone whoever comes across this and wants to know how I fixed it. I created a Gradle build task and then was able to build Jars, EXEs, Tar, and Zip this is the gradle:
plugins {
id 'application'
id 'java'
id 'maven-publish'
id 'org.openjfx.javafxplugin' version '0.0.8'
id 'edu.sc.seis.launch4j' version '2.4.6'
}
dependencies {
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
implementation ('com.github.KaptainWutax:BiomeUtils:master-SNAPSHOT') {
transitive = false;
changing = true;
}
implementation ('com.github.KaptainWutax:FeatureUtils:master-SNAPSHOT')
{
transitive = false;
changing = true;
}
implementation ('com.github.KaptainWutax:SeedUtils:master-SNAPSHOT')
{
transitive = false;
changing = true;
}
}
group = 'sassa'
version = 'v0.6.0'
sourceCompatibility = '1.8'
String stringVersion = version
javafx {
version = "11.0.2"
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.graphics' ]
}
application {
mainClassName = 'sassa.main.Main'
}
jar {
manifest {
attributes 'Main-Class': 'sassa.main.Main'
}
from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
launch4j {
mainClassName = 'sassa.main.Main'
outfile = group + "-" + stringVersion + ".exe"
icon = "${projectDir}/src/main/resources/sassa/sassa.ico"
}
repositories {
mavenLocal()
maven {
url = uri('https://jitpack.io')
}
maven {
url = uri('https://repo.maven.apache.org/maven2')
}
}
task buildAll(type: GradleBuild) {
tasks = ['jar', 'createExe', 'assemble']
}
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
So I've just exported my project as a JAR-file. I'm only making a desktop application. When trying to run the program i get
"A JNI error has occurred.." Not much else there. However, in the command prompt it is revealed that
"Exception in thread "main" java.lang.NoClassDefFoundError: com/badlogic/gdx/ApplicationListener"
So the libGDX ApplicationListener can't be found? It works perfectly when compiling/running in Eclipse.
I'm using:
Windows 7 Ultimate
Eclipse Oxygen.3a
Gradle 4.4.1
java JRE version 1.8.0_241
java JDK version 1.8.0_241
Environment variables:
PATH_HOME: "C:\Program Files\Java\jdk1.8.0_241"
var: "C:\Program Files\Java\jdk1.8.0_241\bin"
Path: "C:\Program Files (x86)\Common Files\Oracle\Java\javapath; C:\ProgramData\Oracle\Java\javapath; C:\Windows\system32; C:\Windows; C:\Windows\System32\Wbem; C:\Windows\System32\WindowsPowerShell\v1.0\; C:\Gradle\gradle-4.4.1\bin"
Main class
public class DesktopLauncher
{
public static boolean rebuildAtlas = true;
public static boolean drawDebugOutline = true;
public static void main (String[] arg)
{
// Build Texture Atlases
if (rebuildAtlas) {
Settings settings = new Settings();
settings.maxWidth = 1024;
settings.maxHeight = 1024;
settings.combineSubdirectories = true;
// Pack images in "textures" folder
TexturePacker.process("assets/textures", "assets/atlas", "textures.atlas");
}
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "TI Helper";
cfg.useGL30 = false;
cfg.width = Cn.RESOLUTION_WIDTH;
cfg.height = Cn.RESOLUTION_HEIGHT;
cfg.fullscreen = true;
new LwjglApplication(new ti_app(), cfg);
}
}
Desktop build.gradle
apply plugin: "java"
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
sourceSets.main.resources.srcDirs = ["../core/assets"]
project.ext.mainClassName = "com.lf.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../core/assets")
task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task debug(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}
task dist(type: Jar) {
manifest {
attributes 'Main-Class': project.mainClassName
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}
dist.dependsOn classes
Core build.gradle
apply plugin: "java"
sourceCompatibility = 1.8
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ]
Workspace build.gradle
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
google()
}
dependencies {
}
}
allprojects {
apply plugin: "eclipse"
version = '1.0'
ext {
appName = "TIHelper"
gdxVersion = '1.9.10'
roboVMVersion = '2.3.8'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
google()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java-library"
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
}
}
project(":core") {
apply plugin: "java-library"
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
api "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
api "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
api "com.badlogicgames.gdx:gdx-ai:$aiVersion"
api "net.dermetfan.libgdx-utils:libgdx-utils:0.13.4"
api "net.dermetfan.libgdx-utils:libgdx-utils-box2d:0.13.4"
api "com.badlogicgames.ashley:ashley:$ashleyVersion"
}
}
Singular unsettling tales also suggests I could be missing some sort of native JAR-file (gdx-native.jar or something like that) among my external dependencies
But those topics where years of age so I guess I have it, it's just named "gdx-platform-1.9.10-natives-desktop.jar" nowadays. Or is the problem related to the fact that the project says Native library location: (none)? I'm kinda lost here I must say. Are the libGDX jars not exported?
I have one modular project, I decided to distribute it to modules. Server and client.
There was a question now. How to call a dependent task from another module?
parent build.gradle
plugins {
id "net.ltgt.apt" version "0.14"
}
apply from: "$rootDir/gradle/idea.gradle"
group 'com.test.portal'
version '1.0-SNAPSHOT'
allprojects {
apply plugin: 'net.ltgt.apt'
}
subprojects {
apply from: "$rootDir/gradle/versions.gradle"
apply from: "$rootDir/gradle/java.gradle"
repositories {
mavenCentral()
mavenLocal()
jcenter()
}
}
java.gradle
def generatedDir = new File("$projectDir", "src/generated")
apply plugin: 'java'
sourceSets {
generated {
java.srcDir "src/generated/java"
}
main.java.srcDirs = ['src/main/java', "src/generated/java"]
main.resources.srcDir "src/main/resources"
test.java.srcDir "src/test/java"
test.resources.srcDir "src/test/resources"
}
// deletes generated classes before new compilation
task deleteGenerated(type: Delete) {
generatedDir.deleteDir()
}
compileGeneratedJava {
dependsOn('deleteGenerated')
}
compileJava {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
options.encoding = 'UTF-8'
options.compilerArgs = ['-Xlint:unchecked'] // Just a smoke test that using this option does not lead to any
options.annotationProcessorGeneratedSourcesDirectory = new File("$generatedDir", "java")
dependsOn(processResources, compileGeneratedJava)
source += sourceSets.generated.java
source += sourceSets.generated.output
}
test {
systemProperties = System.properties
}
And I have 2 child-modules
GWT
build.gradle
apply from: "$rootDir/gradle/gwt.gradle"
dependencies {
...
}
compileGwt {
classpath {
[
sourceSets.main.java.srcDirs, // Java source
sourceSets.main.output.resourcesDir, // Generated resources
sourceSets.main.output.classesDir, // Generated classes
sourceSets.main.compileClasspath, // Deps
]
}
}
gwt.gradle
task compileGwt(dependsOn: classes, type: JavaExec) {
ext.buildDir = "${project.buildDir}/gwt"
ext.extraDir = "${project.buildDir}/extra"
inputs.file sourceSets.main.java.srcDirs
inputs.dir sourceSets.main.output.resourcesDir
outputs.dir buildDir
doFirst {
file(buildDir).mkdirs()
}
main = "com.google.gwt.dev.Compiler"
classpath {
[
sourceSets.main.java.srcDirs, // Java source
sourceSets.main.output.resourcesDir, // Generated resources
sourceSets.main.output.classesDir, // Generated classes
sourceSets.main.compileClasspath, // Deps
]
}
if (project.hasProperty('dev')) {
println "Run developer mode"
args = [
"com.test.portal.AppClientModule",
"-war", buildDir,
"-logLevel", "INFO",
"-localWorkers", "4",
"-compileReport",
"-extra", extraDir,
"-style", "OBF",
"-optimize", "9" // 0=none, 9=max
]
} else {
println "Run production mode"
args = [
"com.test.portal.AppClientModule",
"-war", buildDir,
"-logLevel", "INFO",
"-localWorkers", "4",
"-compileReport",
"-extra", extraDir,
"-style", "OBF",
"-optimize", "9" // 0=none, 9=max
]
}
maxHeapSize = "4G"
}
Server
gradle.build
plugins {
id "org.springframework.boot" version "1.5.10.RELEASE"
}
dependencies {
...
}
jar.dependsOn compileGwt
jar {
into("static") {
from compileGwt.buildDir
}
}
Questions:
How properly call jar.dependsOn compileGwt from one module, a task from another module
Script java.gradle Can I optimize it? Is there any duplication of code?
I keep having very often the below error when running jUnit tests from Intellij command line with the following command: gradlew clean test aggregate -Dtags="domain:SmokeTests"
The page object class de.telekom.commtech.bart.pages.common.TelekomLandingPageObject looks dodgy: Failed to instantiate page (net.thucydides.core.webdriver.UnsupportedDriverException: Could not instantiate class org.openqa.selenium.firefox.FirefoxDriver) de.telekom.commtech.bart.steps.AbstractScenarioSteps.getTelekomLandingPageObject(AbstractScenarioSteps.java :52) de.telekom.commtech.bart.steps.inbox.AuthNavigationSteps.landingPageShouldAppear(AuthNavigationSteps.java :245) de.telekom.commtech.bart.testcases.BaseTest.login(BaseTest.java :447) de.telekom.commtech.bart.testcases.adressbook.lefthandnavigation.AdressBookContactsGroupTestCase.setup(AdressBookContactsGroupTestCase.java :46)
I use latest version of Serenity Bdd (1.1.42) and Firefox 47.0.2
If I run individual tests with Run Configuration, I don't get that error.
I tried downgrading the Firefox version to 45.0, but it acts the same.
What else can I try?
EDIT: The build.gradle file looks like this:
repositories {
mavenLocal()
maven {
name "bart"
credentials {
username nexusUser
password nexusPassword
}
url nexusBartRepoUrl
}
maven {
name "Testchameleon"
url "https://admin.testChameleon.com/artifactory/libs-release-local"
}
jcenter()
}
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath("net.serenity-bdd:serenity-gradle-plugin:1.1.42")
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.2'
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.8'
}
}
group = 'de.telekom.bart'
description = 'Bart Test Framework'
apply plugin: 'org.asciidoctor.convert'
apply plugin: 'java'
apply plugin: 'net.serenity-bdd.aggregator'
tasks.withType(JavaCompile) {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
options.deprecation = true
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked"
}
dependencies {
compile('de.telekom.bart:bart-account-manager:2.0.12')
compile('net.serenity-bdd:serenity-core:1.1.42')
compile('org.slf4j:slf4j-api:1.7.7')
compile('org.slf4j:log4j-over-slf4j:1.7.7')
compile('org.slf4j:jul-to-slf4j:1.7.7')
compile('org.slf4j:jcl-over-slf4j:1.7.7')
compile('ch.qos.logback:logback-classic:1.1.3')
compile('de.testbirds.tech:testcase-api:0.3.20')
compile('org.mnode.ical4j:ical4j:1.0.7')
compile('org.apache.commons:commons-lang3:3.1')
testCompile('net.serenity-bdd:serenity-junit:1.1.42')
testCompile('org.reflections:reflections:0.9.8')
testCompile('junit:junit:4.12')
testCompile('org.assertj:assertj-core:1.7.0')
}
gradle.startParameter.continueOnFailure = true
test {
maxParallelForks = Runtime.runtime.availableProcessors()
if (System.properties['https.proxyHost']) {
systemProperty 'https.proxyHost', System.properties['https.proxyHost']
systemProperty 'https.proxyPort', System.properties['https.proxyPort']
systemProperty 'https.nonProxyHosts', System.properties['https.nonProxyHosts']
}
if (System.properties['http.proxyHost']) {
systemProperty 'http.proxyHost', System.properties['http.proxyHost']
systemProperty 'http.proxyPort', System.properties['http.proxyPort']
systemProperty 'http.nonProxyHosts', System.properties['http.nonProxyHosts']
}
if (System.properties['tags']) {
systemProperty 'tags', System.properties['tags']
}
System.properties.each { key, value ->
if (key.startsWith('serenity') || key.startsWith('webdriver') || key.startsWith('bart') ||(key.startsWith('test'))) {
systemProperty key, value
}
}
testLogging {
showStandardStreams = true
}
/* Pass all system properties: */
systemProperties System.getProperties()
beforeTest { descriptor ->
logger.lifecycle("Running test: ${descriptor}")
}
}
asciidoctor {
//backends = ['html5', 'pdf']
backends = ['html5']
sources {
include 'index.adoc'
}
}
task copyDocs(type: Copy, dependsOn: 'asciidoctor') {
from asciidoctor.outputDir.canonicalPath
into '/data/www/htdocs/bart-docs'
}
task wrapper(type: Wrapper) {
gradleVersion = '3.1'
}