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?
Related
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'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
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'
}
I am trying to use mapstruct generated classes on a new spring-boot project(personal), and it seems my build script requires something else.
The classes are being generated correctly cause I can see them(java and class files in the build folder) and when the application is executed from the jar file, it actually works.
The problem is that when it is executed from eclipse STS, it says spring cant find the generated clases, and yes I made sure, they are created using #Component, and are in the ComponentScanPath.
build.gradle
buildscript {
ext {
springBootVersion = '1.1.6.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
ext {
javaLanguageLevel = '1.8'
generatedMapperSourcesDir = "${buildDir}/generated-src/mapstruct/main"
}
configurations {
mapstruct
}
sourceSets.main {
ext.originalJavaSrcDirs = java.srcDirs
java.srcDir "${generatedMapperSourcesDir}"
}
jar {
baseName = 'MtgGrimoire'
version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-aop")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-websocket")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-ws")
compile('org.postgresql:postgresql:9.3-1102-jdbc41')
compile( 'org.mapstruct:mapstruct:1.0.0.Beta1' )
compile fileTree(dir: 'libs', include: ['*.jar'])
mapstruct( 'org.mapstruct:mapstruct-processor:1.0.0.Beta1' )
testCompile("org.springframework.boot:spring-boot-starter-test")
}
eclipse {
classpath {
containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
}
}
task wrapper(type: Wrapper) {
gradleVersion = '1.12'
}
task generateMainMapperClasses(type: JavaCompile) {
ext.aptDumpDir = file( "${buildDir}/tmp/apt/mapstruct" )
destinationDir = aptDumpDir
classpath = compileJava.classpath + configurations.mapstruct
source = sourceSets.main.originalJavaSrcDirs
ext.sourceDestDir = file ( "$generatedMapperSourcesDir" )
options.define(
compilerArgs: [
"-nowarn",
"-proc:only",
"-encoding", "UTF-8",
"-processor", "org.mapstruct.ap.MappingProcessor",
"-s", sourceDestDir.absolutePath,
"-source", rootProject.javaLanguageLevel,
"-target", rootProject.javaLanguageLevel,
]
);
inputs.dir source
outputs.dir generatedMapperSourcesDir;
doFirst {
sourceDestDir.mkdirs()
}
doLast {
aptDumpDir.delete()
}
}
compileJava.dependsOn generateMainMapperClasses
Also it seems it isn't generated inside the project bin folder