I have a simple multi-project structure as follows:
|- gps-framework
|- build.gradle
|- settings.gradle
|- gps-web-service
|----build.gradle
|----src/main....
Under the root build.gradle located in gps-framework/ looks like this:
plugins {
id 'java'
id "java-library"
id "maven-publish"
id "jacoco"
id 'org.springframework.boot' version '2.3.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
}
subprojects {
subproject ->
apply plugin: 'maven-publish'
apply plugin: 'jacoco'
def isApp = subproject.name == 'gps-web-service'
if (isApp) {
apply plugin: 'java'
} else {
apply plugin: 'java-library'
}
group = 'com.mycompnay'
version = project.hasProperty('customVersion') ? project['customVersion'] : 'integration-SNAPSHOT'
//System.out.println(subproject.name)
compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
options.encoding = 'UTF-8'
}
compileTestJava {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
options.encoding = 'UTF-8'
}
repositories {
mavenCentral()
mavenLocal()
maven {
name "release"
url "my-custom-mvn-repo/release"
authentication {
//
}
}
maven {
name "snapshot"
url "my-custoom-mvn-repo/snapshot"
authentication {
//
}
}
}
configurations {
runtime.exclude(group: "org.slf4j", module:"slf4j-log4j12")
}
publishing {
repositories {
maven {
authentication {
//
}
def isSnapshot = subproject.version.contains('SNAPSHOT')
url = isSnapshot ? "my-custom-mvn-repo/snapshot" : "my-custom-mnv-repo/release"
}
}
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled true
}
}
if (subproject.hasProperty('jacocoTestCoverageVerification')) {
subproject.check.dependsOn subproject.jacocoTestCoverageVerification
}
test {
testLogging {
exceptionFormat = 'full'
}
}
}
The build.gradle of sub-project gps-web-service located in gps-framework/gps-web-service looks like this:
group = 'com.mycompany'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
From what I have read so far, since the repository settings are defined in the root build.gradle and these settings are injected into these subprojects, I do not need to redefine repository settings. This does not appear to be the case as when I run
./gradlew build
The error I get is:
Could not find org.springframework.boot:spring-boot-starter-web:.
Required by:
project :gps-web-service
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Am I misunderstanding the whole concept of injection of project properties or what am I missing here? I will try duplicating the repo settings in the sub-projects build.gradle but was hoping this is not necessary.
To solve this specific problem, I had to define the spring boot plugin in the sub-project's build.gradle as follows:
plugins {
id 'org.springframework.boot' version '2.3.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
}
The resulting file looks like this:
plugins {
id 'org.springframework.boot' version '2.3.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
}
group = 'com.mycompany'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
I am trying to use ObjectBox as a server database with Spring Boot and Tomcat
When i use the embedded tomcat server of Spring Boot, it works fine (running directly from IntelliJ IDEA),
But when i deploy the WAR file / exploded API to Tomcat, i get the error "no objectbox-jni-windows-x64 in java.library.path"
I do have Microsoft Visual C++ 2017 installed
Can you please help me to deploy it successfully?
The following is my build.gradle file:
buildscript {
ext {
kotlinVersion = '1.3.10'
springBootVersion = '2.1.1.RELEASE'
objectboxVersion = '2.2.0'
}
repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
classpath "net.ltgt.gradle:gradle-apt-plugin:0.15"
}
}
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.3.10'
}
apply plugin: 'application'
apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'io.objectbox'
apply plugin: 'kotlin-kapt'
apply plugin: 'net.ltgt.apt-idea'
group = 'com.techontouch'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
mainClassName = "ScoresOnTouchApplicationKt"
compileKotlin {
kotlinOptions {
freeCompilerArgs = ["-Xjsr305=strict"]
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
freeCompilerArgs = ["-Xjsr305=strict"]
jvmTarget = "1.8"
}
}
repositories {
mavenCentral()
jcenter()
}
configurations {
providedRuntime
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.boot:spring-boot-starter-data-rest')
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('com.fasterxml.jackson.module:jackson-module-kotlin')
providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
testImplementation('org.springframework.boot:spring-boot-starter-test')
implementation "io.objectbox:objectbox-java:$objectboxVersion"
implementation "io.objectbox:objectbox-kotlin:$objectboxVersion"
kapt "io.objectbox:objectbox-processor:$objectboxVersion"
implementation "io.objectbox:objectbox-linux:$objectboxVersion"
implementation "io.objectbox:objectbox-macos:$objectboxVersion"
implementation "io.objectbox:objectbox-windows:$objectboxVersion"
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlin:kotlin-reflect")
compile('org.json:json:20180813')
compile('com.google.code.gson:gson:2.8.5')
compile('javax.xml.bind:jaxb-api:2.2.8')
compile('io.springfox:springfox-swagger2:2.9.2')
compile('io.springfox:springfox-swagger-ui:2.9.2')
compile('org.antlr:antlr-complete:3.5.2')
}
// enable debug output for plugin
objectbox {
debug = true
}
// enable debug output for annotation processor
tasks.withType(JavaCompile) {
options.compilerArgs += ["-Aobjectbox.debug=true"]
}
GitHub Link: https://github.com/objectbox/objectbox-java/issues/170#issuecomment-444075662
I am creating javafx app with spring boot in background. To do this I used this library: springboot-javafx-support Every time when I start it I get exception "No auto configuration found in META-INF/spring.factories". I have no idea what I am doing wrong. I guess it must be something wrong in my gradle build script.
Below you can find gradle.build file
buildscript {
ext {
springBootVersion = '2.0.1.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
//apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'pl.opfol.subiekt'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.9
sourceSets {
main.java.srcDirs += 'build/generated/source/apt/main'
}
jar {
enabled = true
}
bootJar {
mainClassName = 'pl.opfol.subiekt.util.MainApp'
}
repositories {
mavenCentral()
maven {
url "https://artifact.aspose.com/repo"
}
maven {
url "https://dl.bintray.com/jerady/maven"
}
}
dependencies {
compile 'org.projectlombok:lombok:1.16.20'
compile('org.springframework.boot:spring-boot-starter')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-validation')
compile('org.springframework.boot:spring-boot-starter-logging')
compile('com.h2database:h2:1.4.197')
compile('javax.mail:javax.mail-api:1.6.1')
compile('com.sun.mail:javax.mail:1.6.1')
compile('commons-io:commons-io:2.6')
compile('commons-codec:commons-codec:1.11')
compile('org.apache.commons:commons-collections4:4.1')
compile('org.apache.commons:commons-lang3:3.7')
compile('commons-configuration:commons-configuration:1.10')
compile('com.aspose:aspose-words:17.3.0:jdk16')
compile('com.microsoft.sqlserver:mssql-jdbc:6.4.0.jre9')
compile('javax.annotation:javax.annotation-api:1.3.2')
compile('org.controlsfx:controlsfx:9.0.0')
compile('com.itextpdf:itext7-core:7.1.1')
compile('javax.xml.bind:jaxb-api:2.3.0')
compile('com.jfoenix:jfoenix:9.0.0')
compile('de.roskenet:springboot-javafx-support:2.1.6')
compile('de.jensd:fontawesomefx-controls:9.1.2')
compile('de.jensd:fontawesomefx-commons:9.1.2')
compile('de.jensd:fontawesomefx-weathericons:2.0.10-9.1.2')
compile('de.jensd:fontawesomefx-materialicons:2.2.0-9.1.2')
compile('de.jensd:fontawesomefx-materialdesignfont:2.0.26-9.1.2')
compile('de.jensd:fontawesomefx-octicons:4.3.0-9.1.2')
compile('de.jensd:fontawesomefx-fontawesome:4.7.0-9.1.2')
compile('de.jensd:fontawesomefx-materialstackicons:2.1-5-9.1.2')
compile('de.jensd:fontawesomefx-icons525:4.2.0-9.1.2')
compile('de.jensd:fontawesomefx-emojione:3.1.1-9.1.2')
compileOnly ('org.hibernate:hibernate-jpamodelgen:5.2.16.Final')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
I had same problem, make sure you run it on JRE 1.8.
When I try to compile/build a Spring Boot project with Spark/Phoenix dependencies, it says there's too many SLF4J's, and when i try to exclude a package, it throws the above error.
How can i get them to work together?
buildscript {
ext {
springBootVersion = '1.5.6.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
//THIS DOESN'T WORK
configurations {
compile.exclude group:'ch.qos.logback'
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
/* EXCLUDING HERE ALSO DIDN'T WORK */
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.apache.spark:spark-sql_2.10:1.5.2')
compile('org.apache.spark:spark-core_2.10:1.5.2')
compile('org.apache.phoenix:phoenix-spark:4.7.0-HBase-1.1')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
I want to generate java files from wsdl. I try to use wsdl2java gradle plugin. I define the plugin:
subprojects {
buildscript{
repositories{
jcenter()
mavenCentral()
}
dependencies {
classpath 'no.nils:wsdl2java:0.10'
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'application'
apply plugin: 'no.nils.wsdl2java'
....
}
but I got this error:
> Plugin with id 'no.nils.wsdl2java:no.nils:wsdl2java' not found.
I checked the syntax (many times it is good). I googled for the plugin, it is used by many people.
Does anybody have an idea what is going wrong?
Upd:
I have a main gradle where the plugins defined, and there are three sub project, where I want to use this plugin.
I defined the sub projects in the settings.gradle:
include 'project1', 'project2', 'project3'
I made a folder and the build.gradle file for each project.
If I commented out the apply plugin: 'no.nils.wsdl2java' in the main build.gradle and the wsdl2java methods in the sub projects the gradle works fine.
You add the buildscript inside the subprojects-closure, thats not supported, see this Gradle discussion (Buildscript {} in subprojects {} ignored?).
You do not have to add the buildscript for every project, it is enough to just declare it on the root-build.gradle
buildscript{
repositories{
jcenter()
mavenCentral()
}
dependencies {
classpath 'no.nils:wsdl2java:0.10'
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'application'
apply plugin: 'no.nils.wsdl2java'
....
}
I was able to get the wsdl2 java working in my gradle build with jaxws and ant tasks. Here it is
apply plugin: 'java'
repositories {
mavenCentral()
flatDir {
dirs 'lib'
}
}
configurations { jaxws }
dependencies { jaxws 'com.sun.xml.ws:jaxws-tools:2.2.6' }
dependencies {
compile 'com.sun.xml.bind:jaxb-impl:2.2.6'
}
task generateSCMOrderImportServiceClient{
if(!file("./lib/employee-services-client.jar").exists()) {
def rootDir = file("build/wsdlToJava/employee-services-client");
def javaDir = file("${rootDir}/java");
def wsdlJarDir = file("${projectDir}/lib");
def classesDir = file("${rootDir}/classes");
def wsdlDir=file("${projectDir}/src/main/resources/wsdl");
def wsdlFile = file("${wsdlDir}/employee-services.wsdl")
doLast{
classesDir.mkdirs()
javaDir.mkdirs()
wsdlJarDir.mkdirs()
copy {
from "${wsdlFile}"
into "${classesDir}"
}
ant {
taskdef(name: 'wsimport',
classname: 'com.sun.tools.ws.ant.WsImport',
classpath: configurations.jaxws.asPath)
wsimport(keep: true,
destdir: classesDir,
sourcedestdir: javaDir,
extension: "true",
verbose: "true",
quiet: "false",
xnocompile: "false",
xendorsed: true,
wsdlLocation: "EmployeeServices.wsdl",
wsdl: "${wsdlFile}")
{
binding(dir:"${wsdlDir}", includes:"jaxb-bindings.xml,jaxws-bindings.xml")
xjcarg(value: "-XautoNameResolution")
}
}
ant.jar(
destfile: wsdlJarDir.path + "/employee-services-client.jar",
basedir: classesDir
)
}
}
}
compileJava.dependsOn generateSCMOrderImportServiceClient
I had achieved this task using this git repository. The build.gradle file looks something like this.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'no.nils:wsdl2java:0.10'
}
}
plugins {
id 'org.springframework.boot' version '2.2.0.M6'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
id 'no.nils.wsdl2java' version '0.10'
}
group = 'your.application.groupname'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
}
dependencies {
wsdl2java(
'com.sun.xml.bind:jaxb-xjc:2.3.0.1',
'javax.xml.bind:jaxb-api:2.3.1',
'javax.xml.ws:jaxws-api:2.3.1',
'org.apache.cxf:cxf-rt-wsdl:3.2.7',
'javax.jws:javax.jws-api:1.1',
'com.sun.xml.bind:jaxb-core:2.3.0.1',
'com.sun.xml.bind:jaxb-xjc:2.3.2',
'com.sun.xml.bind:jaxb-impl:2.3.2',
'javax.xml.bind:jaxb-api:2.3.1'
)
implementation 'com.sun.xml.bind:jaxb-core:2.3.0.1'
implementation 'com.sun.xml.bind:jaxb-xjc:2.3.0.1'
implementation 'com.sun.xml.bind:jaxb-impl:2.3.2'
implementation 'javax.xml.bind:jaxb-api:2.3.1'
implementation 'javax.xml.ws:jaxws-api:2.3.1'
implementation 'org.apache.cxf:cxf-rt-wsdl:3.2.7'
implementation 'javax.jws:javax.jws-api:1.1'
}
test {
useJUnitPlatform()
}
wsdl2java {
wsdlsToGenerate = [
['-p', 'your.package.name',
'-autoNameResolution', "$projectDir/src/main/resources/wsdl/some_wsdl_file.wsdl"]
]
generatedWsdlDir = file("$projectDir/src/main/java")
wsdlDir = file("$projectDir/src/main/resources/wsdl")
locale = Locale.ENGLISH
}
wsdl2javaExt {
cxfVersion = "2.5.1"
}
To generate the java code we need to run the gradle task as shown below.
$ gradlew wsdl2java
For anybody who is looking for generating with Apache CXF. I tried to avoid using any plugin. I did it by creating configuration with dependencies, externalized array of strings with wsdl file names and then just use it like this:
ext {
wsdlDir = file("${projectDir}/src/main/resources/wsdl")
outputDir = file("$buildDir/generated-sources")
sourceWsdls = [
"$wsdlDir/MyWsdlFile1.wsdl",
"$wsdlDir/MyWsdlFile2.wsdl",
"$wsdlDir/MyWsdlFile3.wsdl",
"$wsdlDir/MyWsdlFile4.wsdl"
]
}
sourceSets.main.java.srcDirs += "$outputDir"
dependencies {
cxf (
'org.apache.cxf:cxf-tools-wsdlto-core:3.3.6',
'org.apache.cxf:cxf-tools-wsdlto-frontend-jaxws:3.3.6',
'org.apache.cxf:cxf-tools-wsdlto-databinding-jaxb:3.3.6'
)
}
task generateJavaClasses {
doLast{
sourceWsdls.each { wsdlFile ->
javaexec {
classpath configurations.cxf
main = 'org.apache.cxf.tools.wsdlto.WSDLToJava'
args '-d', outputDir
args '-b', 'PATH/TO/BINDING/FILE.xjb'
args wsdlFile
}
}
}
}
This is just simple calling javaexec of Apache CXF class - see docs for all args and options.
Note: If you have a folder with wsdl files and you want to generated classes from all wsdl files there, it is even easier and just use it like this:
task generateJavaClassesAllWsdlFiles {
doLast{
// Find all wsdl files in directory defined in ext
fileTree(wsdlDir).matching {
include "*.wsdl"
}.each {
wsdlFile ->
println "Generating " + wsdlFile
javaexec {
classpath configurations.cxf
main = 'org.apache.cxf.tools.wsdlto.WSDLToJava'
args '-d', outputDir
args '-b', 'PATH/TO/BINDING/FILE.xjb'
args wsdlFile
}
}
}
}
I put it all into gist, if you want to see it complete, gist is here.
To solve this try adding the buildScript before the plugin declarations and apply the wsdl plugin after the plugin block for example:
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'no.nils:wsdl2java:0.10'
}
}
plugins {
id 'org.springframework.boot' version '2.1.7.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
id 'war'
id "org.sonarqube" version "2.7"
}
apply plugin: 'java'
apply plugin: 'no.nils.wsdl2java'
for JDK8 you can update gradle with the following and specify cxfVersion under wsdl2java
apply plugin: 'no.nils.wsdl2java'
wsdl2java {
wsdlDir = file("$projectDir/src/main/resources/fooSchemas")
cxfVersion = '3.3.2'
wsdlsToGenerate = [
["$projectDir/src/main/resources/emailSchemas/FooService.wsdl"]
]
}