I'm trying a libgdx project depending on a lib published in local repo with maven-publish:
// to publish locally:
// ~/gdx-gltf$ ./gradlew gltf:publishToMavenLocal
apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'io.github.odys-z'
artifactId = 'gdx-gltf'
version = '0.1.0-SNAPSHOT'
from components.java
}
}
}
When I running the depending desktop with gradlew CLI, it's working:
./gradlew desktop:run
But in eclipse and right click the BasicTweenTest class (gradle project.ext.mainClassName) and run as java application, eclipse reported errors:
com.badlogic.gdx.utils.GdxRuntimeException: java.lang.Error: Unresolved compilation problems:
sceneAsset cannot be resolved to a variable
GLTFLoader cannot be resolved to a type
SceneModel cannot be resolved to a type
scenes cannot be resolved or is not a field
animationLoader cannot be resolved to a variable
The missing type is in the local repo dependency, gdx-gltf-0.1.0-SNAPSHOT. No matter what I cleaned projects or refreshed gradle, the error persisting appear.
Eclipse Screenshot with stacktrace report
desktop/build.gradle:
apply plugin: "java"
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/", "test/" ]
sourceSets.main.resources.srcDirs = ["../android/assets", "test"]
// project.ext.mainClassName = "io.oz.wnw.norm.desktop.DesktopLauncher"
// project.ext.mainClassName = "io.oz.wnw.norm.desktop.PlaneStarTest"
project.ext.mainClassName = "io.oz.wnw.norm.desktop.BasicTweenTest"
project.ext.assetsDir = new File("../android/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
}
from {
configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}
dist.dependsOn classes
The other two tests commented out above can run both in CLI and eclipse, which don't depend on the local published package. Any idea?
--------- parent project/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 {
classpath 'org.wisepersist:gwt-gradle-plugin:1.0.9'
classpath 'com.android.tools.build:gradle:7.0.0-alpha08'
}
}
allprojects {
version = '1.0'
ext {
appName = "wn cloud"
gdxVersion = '1.9.14'
gltfVersion = '0.1.0-SNAPSHOT'
roboVMVersion = '2.3.8'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
maven { url "http://maven.aliyun.com/nexus/content/groups/public" }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
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"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
}
}
project(":html") {
apply plugin: "java-library"
apply plugin: "gwt"
apply plugin: "war"
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
api "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
api "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
api "com.badlogicgames.ashley:ashley:$ashleyVersion:sources"
}
}
project(":core") {
apply plugin: "java-library"
apply plugin: 'eclipse'
eclipse {
classpath {
downloadSources=true
downloadJavadoc = true
}
}
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.ashley:ashley:$ashleyVersion"
api 'io.github.odys-z:gdx-gltf:0.1.0-SNAPSHOT'
}
}
I faced the same problem. Turns out that LibGDX works with JDK 7 and any version compiled above won't work.
You need to enforce java to compile at version 1.7 before publishing locally
apply plugin: 'java'
sourceCompatibility = 1.7
targetCompatibility = 1.7
i'm trying to get the war file from Jhipster project project using this command
./gradlew -Pprod -Pwar clean bootWar
this the error that i got
FAILURE: Build failed with an exception.
What went wrong:
Task 'bootWar' not found in root project 'account'. Some candidates are: 'bootRun'.
Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 0s
this my bild.gradle
import org.gradle.internal.os.OperatingSystem
buildscript {
repositories {
mavenLocal()
jcenter()
maven { url "https://repo.spring.io/plugins-release" }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${spring_boot_version}"
classpath "io.spring.gradle:propdeps-plugin:0.0.9.RELEASE"
classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:1.4.17"
//jhipster-needle-gradle-buildscript-dependency - JHipster will add additional gradle build script plugins here
}
}
plugins {
id "org.sonarqube" version "2.5"
id "net.ltgt.apt-eclipse" version "0.13"
id "net.ltgt.apt-idea" version "0.13"
id "net.ltgt.apt" version "0.13"
id "io.spring.dependency-management" version "1.0.3.RELEASE"
//jhipster-needle-gradle-plugins - JHipster will add additional gradle plugins here
}
apply plugin: 'java'
sourceCompatibility=1.8
targetCompatibility=1.8
tasks.withType(JavaExec) {
jvmArgs = [ '-Xmx512m','-Xms256m']
}
// Until JHipster supports JDK 9
assert System.properties['java.specification.version'] == '1.8'
apply plugin: 'maven'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'
apply plugin: 'propdeps'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'idea'
dependencyManagement {
imports {
mavenBom 'io.github.jhipster:jhipster-dependencies:' + jhipster_dependencies_version
//jhipster-needle-gradle-dependency-management - JHipster will add additional dependencies management here
}
}
defaultTasks 'bootRun'
group = 'com.skywriter.account'
version = '0.0.1-SNAPSHOT'
description = ''
bootRepackage {
mainClass = 'com.skywriter.account.AccountApp'
}
war {
}
springBoot {
mainClass = 'com.skywriter.account.AccountApp'
executable = true
buildInfo()
}
if (OperatingSystem.current().isWindows()) {
task pathingJar(type: Jar) {
dependsOn configurations.runtime
appendix = 'pathing'
doFirst {
manifest {
attributes 'Class-Path': configurations.runtime.files.collect {
it.toURI().toURL().toString().replaceFirst(/file:\/+/, '/').replaceAll(' ', '%20')
}.join(' ')
}
}
}
bootRun {
addResources = false
dependsOn pathingJar
doFirst {
classpath = files("$buildDir/classes/java/main", "$buildDir/resources/main", pathingJar.archivePath)
}
}
} else {
bootRun {
addResources = false
}
}
test {
exclude '**/CucumberTest*'
// uncomment if the tests reports are not generated
// see https://github.com/jhipster/generator-jhipster/pull/2771 and https://github.com/jhipster/generator-jhipster/pull/4484
// ignoreFailures true
reports.html.enabled = false
}
task cucumberTest(type: Test) {
description = "Execute cucumber BDD tests."
group = "verification"
include '**/CucumberTest*'
// uncomment if the tests reports are not generated
// see https://github.com/jhipster/generator-jhipster/pull/2771 and https://github.com/jhipster/generator-jhipster/pull/4484
// ignoreFailures true
reports.html.enabled = false
}
check.dependsOn cucumberTest
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports/tests")
reportOn test
}
task cucumberTestReport(type: TestReport) {
destinationDir = file("$buildDir/reports/tests")
reportOn cucumberTest
}
apply from: 'gradle/docker.gradle'
apply from: 'gradle/sonar.gradle'
apply from: 'gradle/liquibase.gradle'
apply from: 'gradle/mapstruct.gradle'
//jhipster-needle-gradle-apply-from - JHipster will add additional gradle scripts to be applied here
if (project.hasProperty('prod')) {
apply from: 'gradle/profile_prod.gradle'
}
if (project.hasProperty('stage')) {
apply from: 'gradle/profile_stage.gradle'
}
if (project.hasProperty('demo')) {
apply from: 'gradle/profile_demo.gradle'
}
if (project.hasProperty('aws')) {
apply from: 'gradle/profile_aws.gradle'
}
if (project.hasProperty('devtest')) {
apply from: 'gradle/profile_devtest.gradle'
}
if (project.hasProperty('aws')) {
apply from: 'gradle/profile_aws.gradle'
}
else {
apply from: 'gradle/profile_dev.gradle'
}
if (project.hasProperty('graphite')) {
apply from: 'gradle/graphite.gradle'
}
if (project.hasProperty('prometheus')) {
apply from: 'gradle/prometheus.gradle'
}
if (project.hasProperty('zipkin')) {
apply from: 'gradle/zipkin.gradle'
}
configurations {
providedRuntime
compile.exclude module: "spring-boot-starter-tomcat"
}
repositories {
mavenLocal()
jcenter()
}
dependencies {
compile 'io.logz.logback:logzio-logback-appender:v1.0.21'
compile "org.springframework.boot:spring-boot-starter-cache"
compile "io.github.jhipster:jhipster"
compile "io.dropwizard.metrics:metrics-core"
compile "io.dropwizard.metrics:metrics-json"
compile "io.dropwizard.metrics:metrics-jvm"
compile "io.dropwizard.metrics:metrics-servlet"
compile "io.dropwizard.metrics:metrics-servlets"
compile "net.logstash.logback:logstash-logback-encoder"
compile "com.fasterxml.jackson.datatype:jackson-datatype-json-org"
compile "com.fasterxml.jackson.datatype:jackson-datatype-hppc"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
compile "com.fasterxml.jackson.datatype:jackson-datatype-hibernate5"
compile "com.fasterxml.jackson.core:jackson-annotations"
compile "com.fasterxml.jackson.core:jackson-databind"
compile "com.fasterxml.jackson.module:jackson-module-afterburner"
compile "com.ryantenney.metrics:metrics-spring"
compile "com.hazelcast:hazelcast"
compile "com.hazelcast:hazelcast-hibernate52"
compile "com.hazelcast:hazelcast-spring"
compile "javax.cache:cache-api"
compile "org.hibernate:hibernate-core"
compile "com.zaxxer:HikariCP"
compile "org.apache.commons:commons-lang3"
compile "commons-io:commons-io"
compile "javax.transaction:javax.transaction-api"
compile "org.hibernate:hibernate-entitymanager"
compile "org.hibernate:hibernate-envers"
compile "org.hibernate:hibernate-validator"
compile "org.liquibase:liquibase-core"
compile "com.mattbertolini:liquibase-slf4j"
compile "org.springframework.boot:spring-boot-actuator"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-loader-tools"
compile "org.springframework.boot:spring-boot-starter-mail"
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-aop"
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile "org.springframework.boot:spring-boot-starter-security"
compile ("org.springframework.boot:spring-boot-starter-web") {
exclude module: 'spring-boot-starter-tomcat'
}
compile "org.springframework.boot:spring-boot-starter-undertow"
compile "org.springframework.boot:spring-boot-starter-thymeleaf"
compile "org.zalando:problem-spring-web"
compile "org.springframework.cloud:spring-cloud-starter"
compile "org.springframework.cloud:spring-cloud-starter-ribbon"
compile "org.springframework.cloud:spring-cloud-starter-hystrix"
compile "org.springframework.cloud:spring-cloud-starter-spectator"
compile "org.springframework.retry:spring-retry"
compile "org.springframework.cloud:spring-cloud-starter-eureka"
compile "org.springframework.cloud:spring-cloud-starter-config"
compile "org.springframework.cloud:spring-cloud-security"
compile "org.springframework.cloud:spring-cloud-starter-feign"
compile "org.springframework.cloud:spring-cloud-spring-service-connector"
compile "org.springframework:spring-context-support"
compile "org.springframework.security:spring-security-config"
compile "org.springframework.security:spring-security-data"
compile "org.springframework.security:spring-security-web"
compile "org.springframework.security.oauth:spring-security-oauth2"
compile "org.springframework.security:spring-security-jwt"
compile ("io.springfox:springfox-swagger2") {
exclude module: 'mapstruct'
}
compile "io.springfox:springfox-bean-validators"
compile "org.postgresql:postgresql"
compile "org.mapstruct:mapstruct-jdk8:${mapstruct_version}"
testCompile "com.jayway.jsonpath:json-path"
testCompile "info.cukes:cucumber-junit"
testCompile "info.cukes:cucumber-spring"
testCompile ("org.springframework.boot:spring-boot-starter-test") {
exclude group: 'com.vaadin.external.google', module: 'android-json'
}
testCompile "org.springframework.security:spring-security-test"
testCompile "org.springframework.boot:spring-boot-test"
testCompile "org.assertj:assertj-core"
testCompile "junit:junit"
testCompile "org.mockito:mockito-core"
testCompile "com.mattbertolini:liquibase-slf4j"
testCompile "org.hamcrest:hamcrest-library"
testCompile "com.h2database:h2"
optional ("org.springframework.boot:spring-boot-configuration-processor") {
exclude group: 'com.vaadin.external.google', module: 'android-json'
}
//jhipster-needle-gradle-dependency - JHipster will add additional dependencies here
}
task cleanResources(type: Delete) {
delete 'build/resources'
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
}
task stage(dependsOn: 'bootRepackage') {
}
compileJava.dependsOn processResources
processResources.dependsOn cleanResources,bootBuildInfo
bootBuildInfo.mustRunAfter cleanResources
thanks in advance
To make the answer more visible (valid for jhipster 4.x):
for creating a war that can be deployed in an application server use ./gradlew war and for an executable war file, which can be executed via java -jar use ./gradlew bootWar.
I'm trying to publish my project to JCenter with gradle.
I'm getting this error:
$ ./gradlew bintrayUpload
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/tomcaflisch/my-project/build.gradle' line: 32
* What went wrong:
A problem occurred evaluating root project 'my-project'.
> No signature of method: build_1izvkzzfcfkppgubyut54udzf.bintray() is applicable for argument types: (build_1izvkzzfcfkppgubyut54udzf$_run_closure3) values: [build_1izvkzzfcfkppgubyut54udzf$_run_closure3#30577a07]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Here's my build.gradle file
buildscript {
repositories {
maven { url "https://repo1.maven.org/maven2" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
plugins {
id "com.jfrog.bintray" version "1.8.5"
}
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'java'
group = 'com.projectx'
version = '0.0.1'
repositories {
jcenter()
mavenCentral()
}
sourceSets {
main.java.srcDirs = ['src/main/java']
}
bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
publications = ['MyPublication']
pkg {
repo = 'maven'
name = 'project-x'
userOrg = 'myorg'
licenses = ['Proprietary']
vcsUrl = 'https://github.com/myorg/my-project.git'
version {
name = project.version
released new Date()
}
}
}
publishing {
publications {
MyPublication(MavenPublication) {
from components.java
groupId project.group
artifactId 'projectx'
version project.version
}
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'jacoco'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
install {
repositories.mavenInstaller {
pom.artifactId = 'projectx'
}
}
test {
finalizedBy jacocoTestReport // Report is always generated after tests run
}
jacocoTestReport {
dependsOn test // Tests are required to run before generating the report
reports {
xml.enabled true
}
}
task execute(type:JavaExec) {
main = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
dependencies {
compile 'io.swagger:swagger-annotations:1.5.22'
compile "com.google.code.findbugs:jsr305:3.0.2"
compile 'com.squareup.okhttp3:okhttp:3.14.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.14.2'
compile 'com.google.code.gson:gson:2.8.5'
compile 'io.gsonfire:gson-fire:1.8.3'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
testCompile 'junit:junit:4.13'
testCompile 'org.mockito:mockito-core:3.+'
testImplementation "com.google.truth:truth:1.0.1"
}
javadoc {
options.tags = [ "http.response.details:a:Http Response Details" ]
}
Bintray is dead.
But to answer the question, No signature of method: build_whatever.[method]() comes from something in the configuration of [method] being incorrect. In this case I'd guess it's caused by released new Date() which should probably be released = new Date()
I am coming from Maven workd and new to Gradle.I have multi-module Gradle product with following modules:
"cdna-common"
'cdna-data-access'
"cdna-api-dto"
"cdna-api-module"
"cdna-request-executor-module"
my root settings.glade looks like this:
rootProject.name = 'cdna-one-platform'
include "cdna-common"
include 'cdna-data-access'
//include "cdna-api-dto" //commented temporary
include "cdna-api-module"
//include "cdna-request-executor-module" //commented temporary
gradle file for module 'cdna-data-access' is :
buildscript {
ext {
springBootVersion = '2.0.0.M6'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
ext['hibernate.version'] = '5.2.11.Final'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.company.cdna'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
jar {
baseName = 'cdna-one-data-access'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
a
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compile('mysql:mysql-connector-java')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.hibernate:hibernate-search-orm')
compile group: 'org.hibernate', name: 'hibernate-search-orm' , version: '5.8.2.Final'
compile group: 'org.apache.lucene', name: 'lucene-analyzers-kuromoji' , version: '5.5.5'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('com.h2database:h2')
}
Module 'cdna-common' depends on 'cdna-one-data-access' and gradle file looks like :
apply plugin: 'java'
apply plugin: 'eclipse'
group = 'com.company.cdna'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
jar {
baseName = 'cdna-one-commons'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
compile project(':cdna-data-access')
}
When I compile the module 'cdnHowever,cess' using 'gradlew cdna-data-access:build' , it compiles without any error.
However , when I try to compile the module 'cdna-common' using 'gradlew cdna-common:build' , it gives following error:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':cdna-common:compileClasspath'.
> Could not find org.springframework.boot:spring-boot-starter:.
Searched in the following locations:
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter//spring-boot-starter-.pom
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter//spring-boot-starter-.jar
https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter//spring-boot-starter-.pom
https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter//spring-boot-starter-.jar
https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter//spring-boot-starter-.pom
https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter//spring-boot-starter-.jar
Required by:
project :cdna-common > project :cdna-data-access
> Could not find mysql:mysql-connector-java:.
Searched in the following locations:
https://repo1.maven.org/maven2/mysql/mysql-connector-java//mysql-connector-java-.pom
https://repo1.maven.org/maven2/mysql/mysql-connector-java//mysql-connector-java-.jar
https://repo.spring.io/snapshot/mysql/mysql-connector-java//mysql-connector-java-.pom
https://repo.spring.io/snapshot/mysql/mysql-connector-java//mysql-connector-java-.jar
https://repo.spring.io/milestone/mysql/mysql-connector-java//mysql-connector-java-.pom
https://repo.spring.io/milestone/mysql/mysql-connector-java//mysql-connector-java-.jar
Required by:
project :cdna-common > project :cdna-data-access
> Could not find org.springframework.boot:spring-boot-starter-data-jpa:.
Searched in the following locations:
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-data-jpa//spring-boot-starter-data-jpa-.pom
https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-data-jpa//spring-boot-starter-data-jpa-.jar
https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-data-jpa//spring-boot-starter-data-jpa-.pom
https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-data-jpa//spring-boot-starter-data-jpa-.jar
https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-data-jpa//spring-boot-starter-data-jpa-.pom
https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-data-jpa//spring-boot-starter-data-jpa-.jar
Required by:
project :cdna-common > project :cdna-data-access
Any tips of what I am doing wrong?
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"]
]
}