I've has a project for at least a year and would compile fine. now when i try to compile the metamodels are missing and the compilejava task is failing. I'm not sure if the issues is because there is a version issue or what. keep in mind that before hand i had no issue with running the build with the current gradle build script and project file structure.
the code is in java with netBeans:
Product Version: NetBeans IDE 8.2 (Build 201609300101)
Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 2
Java: 1.8.0_171; Java HotSpot(TM) 64-Bit Server VM 25.171-b11
Runtime: Java(TM) SE Runtime Environment 1.8.0_171-b11
System: Windows 10 version 10.0 running on amd64; Cp1252; en_US (nb)
Gradle Support 1.4.4
i've attempted to "set the generated path" but that didn't work.
i've also tried to create me own copies of the metamodel class then reference it in the dynamic query builder. it would compile but the when i tested the query and i keep getting a null pointer exception.
if i ctrl click the metamodel in the class file using the metamodel it loads the metamodel class file i think there is some issue with the generator creating the metamodel object on compile.
apply plugin: 'java'
apply plugin: 'war'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
war.archiveName "ApplicationWarehouseService.war"
war {
webInf {from 'src/main/resources/application.xml' }
}
if (!hasProperty('mainClass')) {
ext.mainClass = 'test'
}
repositories {
mavenCentral()
maven {
url "http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts/"
}
}
dependencies {
compile 'javax.servlet:javax.servlet-api:4.0.0'
compile 'commons-validator:commons-validator:1.6'
compile 'org.springframework:spring-webmvc:5.0.5.RELEASE'
compile 'org.springframework.security:spring-security-web:5.0.4.RELEASE'
compile 'org.springframework.security:spring-security-config:5.0.4.RELEASE'
compile 'org.springframework:spring-jdbc:5.1.6.RELEASE'
compile 'org.springframework:spring-aop:5.1.6.RELEASE'
compile 'org.springframework:spring-context:5.1.6.RELEASE'
compile 'org.springframework:spring-context-support:5.1.6.RELEASE'
compile 'org.springframework.data:spring-data-jpa:2.1.6.RELEASE'
compile 'org.springframework:spring-orm:5.1.6.RELEASE'
compile 'com.microsoft.sqlserver:mssql-jdbc:6.4.0.jre8'
compile 'org.hibernate:hibernate:3.5.4-Final'
compile 'org.hibernate:hibernate-core:5.4.2.Final'
compile 'org.hibernate:hibernate-jpamodelgen:5.4.3.Final'
compile 'org.aspectj:aspectjrt:1.9.0'
compile 'org.aspectj:aspectjweaver:1.9.0'
compile 'org.apache.tomcat:tomcat-jdbc:9.0.7'
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.5'
compile 'commons-fileupload:commons-fileupload:1.3.3'
compile 'javax.mail:javax.mail-api:1.6.1'
compile 'javax:javaee-api:8.0'
compile 'javax.servlet:jstl:1.2'
compile 'org.hibernate.validator:hibernate-validator:6.0.9.Final'
compile 'org.apache.logging.log4j:log4j-core:2.11.0'
compile files('C:/Program Files (x86)/Microsoft JDBC Driver 4.1 for SQL Server/sqljdbc_4.1/enu/jre7/sqljdbc41.jar')
//compile 'com.lowagie:itext:4.2.2'
compile 'com.lowagie:itext:2.1.7'
compile 'net.sf.jasperreports:jasperreports:6.1.0'
// compile 'com.itextpdf:itextpdf:5.5.13'
// compile 'net.sf.jasperreports:jasperreports:6.5.1'
compile 'javax.money:money-api-bp:1.0'
compile 'org.json:json:20180130'
compile 'javax.xml.bind:jaxb-api:2.3.0'
compile group: 'ar.com.fdvs', name: 'DynamicJasper', version: '5.1.1'
compile group: 'ar.com.fdvs', name: 'DynamicJasper-core-fonts', version: '1.0'
testCompile group: 'junit', name: 'junit', version: '4.10'
testCompile 'org.springframework:spring-test:5.0.5.RELEASE'
}
configurations.all*.dependencies*.withType(ModuleDependency)*.each {
it.exclude group: "org.bouncycastle", module: "*"
it.exclude group: "bouncycastle", module: "*"
}
ideally i'd like to have my project create the metamodels and compile successfully.
I found the Solution I Added
annotationProcessor('org.hibernate:hibernate-jpamodelgen:5.4.3.Final')
in the dependencies section. Compiled just fine.
Related
Currently I am learning Nexus and gradle integration and stuck with one issue.
One file OJDBC14.jar is has already been uploaded on nexus earlier. So when we mentioned that jar in build.gradle dependency, it downloads from nexus.
OJDBC14
dependencies {
compile 'mysql:mysql-connector-java:8.0.9-rc'
compile 'ojdbc:ojdbc:14'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5'
compile 'org.apache.poi:poi:4.0.0'
compile 'org.apache.poi:poi-ooxml:4.0.0'
compile 'com.aventstack:extentreports:3.1.2'
compile 'org.jsoup:jsoup:1.11.3'
compile 'com.google.code.gson:gson:2.8.5'
compile 'com.sparkjava:spark-core:2.8.0'
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.0'}
Recently I have uploaded new jar file OJDBC8.jar on nexus using UI but build.gradle cannot download that file from nexus.
OJDBC8
dependencies {
compile 'mysql:mysql-connector-java:8.0.9-rc'
compile 'ojdbc:ojdbc:14'
compile 'ojdbc:ojdbc:8'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5'
compile 'org.apache.poi:poi:4.0.0'
compile 'org.apache.poi:poi-ooxml:4.0.0'
compile 'com.aventstack:extentreports:3.1.2'
compile 'org.jsoup:jsoup:1.11.3'
compile 'com.google.code.gson:gson:2.8.5'
compile 'com.sparkjava:spark-core:2.8.0'
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.0'}
I checked the .gradle log but it does not showing any error message.
Is there any other settings to do when we upload the jar using UI?
You are trying to add two different versions of the same module ojdbc:ojdbc for the same configuration compile, but this is not supported by Gradle, see more details about dependencies resolution here. In your case, unless you change the default resolution strategy, the latest version of this module will be used, so version 14.
So I think your issue is not connected to this particular library version 8 in your Nexus: you can try to remove/comment the dependency compile 'ojdbc:ojdbc:14' and keep only compile 'ojdbc:ojdbc:14': Gradle should be able to download/use this version 8.
I am having difficulty combing through the Kotlinlang and Gradle documentation. There seems to be a confusing mix of examples on how to make a native compiling kotlin project. I was looking at this tutorial:
https://kotlinlang.org/docs/tutorials/native/gradle-for-kotlin-native.html
but it seems to be wildly different from this other gradle setup:
https://kotlinlang.org/docs/reference/using-gradle.html#configuring-dependencies
I generated a new Kotlin-native-common project in Intellij and the resulting auto-generated build script looks like this:
plugins {
id 'java'
id 'kotlin-platform-common' version '1.2.71'
}
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-common"
testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common"
testCompile "org.jetbrains.kotlin:kotlin-test-common"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
The above build-script doesn't look like the examples given in the above tutorials. What exactly should this build-script look like to compile to MacOSX native and why does the tutorial example show using konan for native compiling while the auto-generated script does not?
Thanks
This error occurred while running my project, unable to run my application for the build.
I have clean the build and rebuild the project again results in same problem.
* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/common/annotations/Beta.class
I have shared my gradle file below. Kindly help me to find the changes to be done in gradle file to run my application.
Gradle File
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.crashlytics.sdk.android:crashlytics:2.5.0#aar') {
transitive = true;
}
compile 'com.uber.sdk:rides-android:0.5.3'
compile 'com.twitter.sdk.android:twitter:3.1.1'
compile project(':branchsdk')
compile project(':squarecamera')
compile 'com.google.code.gson:gson:2.5'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.facebook.rebound:rebound:0.3.8'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
compile 'se.emilsjolander.stickylistheaders:library:2.1.0'
compile ('com.android.support:support-v4:26.0.0')
{ exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude module: 'support-annotations'
}
compile ('com.android.support:appcompat-v7:26.0.0'){
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'com.android.support'
}
compile 'com.github.siyamed:android-shape-imageview:0.9.2'
compile 'com.adobe.creativesdk.foundation:auth:0.5.3'
compile 'com.adobe.creativesdk.foundation:assets:0.5.3'
compile 'com.adobe.creativesdk:image:4.0.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile ('com.google.android.gms:play-services:11.6.2'){
exclude group: 'com.google.guava'
}
compile 'com.parse:parse-android:1.10.2'
compile 'org.altbeacon:android-beacon-library:2.5.1'
compile 'org.apache.commons:commons-collections4:4.0'
compile 'org.solovyev.android.views:linear-layout-manager:0.5#aar'
compile 'de.greenrobot:eventbus:2.4.0'
compile ('com.android.support:recyclerview-v7:26.0.0')
{
exclude group: 'com.android.support'
}
compile ('com.android.support:multidex:1.0.1')
{
exclude group: 'com.android.support'
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
compile 'me.relex:circleindicator:1.2.2#aar'
compile 'com.google.firebase:firebase-config:11.6.2'
compile 'com.google.firebase:firebase-messaging:11.6.2'
compile project(':ucrop')
compile project(':library')
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.guava:guava:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
Kindly help me to solve this problem.
Thanks in Advance...
I think you're getting stung by the Google collections rename to guava and you probably have both on your classpath.
See Using module replacement rules
Eg:
dependencies {
modules {
module("com.google.collections:google-collections") {
replacedBy("com.google.guava:guava", "google-collections is now part of Guava")
}
}
}
Or another problem could be this
fileTree(include: ['*.jar'], dir: 'libs')
The jars in this libs folder can't participate in dependency resolution because there's no meta-data (eg group/artifact/version) so it's possible that there are duplicates here too
See here to store local jars in a maven directory layout instead
I am developing Spring project.
I would like to load credentials from the command line not storying them in the code. I'm trying to execute this gradle command
gradlew build -Dspring.datasource.username=tester
and when I startup the Spring project, the program stops on a breakpoint and I see whether variable is declared or not. I have tried using -P instead of -D but it still didn't help.
I deploy the spring app remotely using bmuschko plugin I've tried to use, but also without success. I checked in java code Properties by using System.getProperties() and Environment object supported by Spring.
gradlew cargoredeployremote -Dspring.datasource.username=tester
Application properties are loaded succesfully.
IMPORTANT: I saw many tutorials how to make it but using Spring Boot I use just selected components from Spring.
For instance: http://nixmash.com/post/passing-arguments-to-spring-boot - this doesn't work in my case because I have no bootRun task.
Any ideas? Am I missing something in my steps?
Here is my build.gradle
group 'example'
version '1.0.0'
apply plugin: 'application'
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'com.bmuschko.cargo'
apply plugin: 'org.liquibase.gradle'
compileJava.options.encoding = 'UTF-8'
mainClassName = 'api.optic.config.WebAppInitializer'
sourceCompatibility = 1.8
buildscript {
repositories{
jcenter()
mavenCentral()
}
dependencies{
classpath 'com.bmuschko:gradle-cargo-plugin:2.2.3'
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-RC3'
classpath 'org.liquibase:liquibase-core:3.4.1'
classpath "org.liquibase:liquibase-gradle-plugin:1.2.4"
classpath "mysql:mysql-connector-java:5.1.13"
}
}
project.ext {
springVersion = "4.3.6.RELEASE"
junitVersion = "5.0.0-RC3"
}
repositories {
mavenCentral()
}
dependencies {
compile "org.springframework:spring-core:${springVersion}"
compile "org.springframework:spring-context:${springVersion}"
compile "org.springframework:spring-context-support:${springVersion}"
compile "org.springframework:spring-beans:${springVersion}"
compile "org.springframework:spring-web:${springVersion}"
compile "org.springframework:spring-webmvc:${springVersion}"
compile "org.springframework:spring-orm:${springVersion}"
compile "org.springframework:spring-oxm:${springVersion}"
compile "org.springframework:spring-jdbc:${springVersion}"
compile "org.springframework:spring-test:${springVersion}"
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.38'
compile group: 'javax.mail', name: 'javax.mail-api', version: '1.5.6'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.2'
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-parameter-names', version: '2.9.0.pr2'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jdk8', version: '2.9.0.pr2'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.9.0.pr2'
compile 'javax.servlet:javax.servlet-api:3.1.0'
testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testRuntime("org.junit.jupiter:junit-jupiter-engine:${junitVersion}")
}
cargo {
containerId = 'tomcat8x'
port = 8080
deployable {
context = 'example'
}
remote {
hostname = 'host.name.com'
username = 'tomcat'
password = 'pass'
}
Basically were 2 issues
1. Name mismatch: in application.properties the name inside the ${} was different than this provided from command-line
Solution:
application.properties
spring.datasource.username=${username}
and in gradle command-line
gradle build -Pusername=tester
2. Dot issue with gradle:
Can't put
gradle build -Pspring.datasource.username=tester
even if you have in application.properties
spring.datasource.username=${spring.datasource.username}
because you get an exception:
Execution failed for task ':processResources'.
Could not copy file '.\src\main\resources\application.properties' to '.\build\resources\main\application.properties'.
Solution:
Instead of dots use _ sign
gradle build -Pspring_datasource_username=tester
and in Application properties
spring.datasource.username=${spring_datasource_username}
I'm trying to execute some .sql scripts and then deploy web app using gradle tomcat plugin.
But when I make any attempt to run gradle I've got an error
My buildscript looks like this
buildscript {
//repository location
repositories {
mavenCentral()
jcenter()
}
//dependencies
//did not divide them into runtime&compile
dependencies {
//aspectJ dependencies
compile 'org.aspectj:aspectjlib:1.6.2'
compile 'org.aspectj:aspectjrt:1.7.4'
compile 'org.aspectj:aspectjweaver:1.7.4'
//servlet
compile 'javax.servlet:javax.servlet-api:3.0.1'
//jdbc postresql
compile 'org.postgresql:postgresql:9.2-1004-jdbc4'
//commons dbcp
compile 'commons-dbcp:commons-dbcp:1.2.2'
//spring & spring MVC dependencies
compile 'org.springframework:spring-core:' + spring_version
compile 'org.springframework:spring-web:' + spring_version
compile 'org.springframework:spring-webmvc:' + spring_version
compile 'org.springframework:spring-jdbc:' + spring_version
compile 'org.springframework:spring-aspects:' + spring_version
//spring security
compile 'org.springframework.security:spring-security-core:' + spring_security_version
compile 'org.springframework.security:spring-security-web:' + spring_security_version
compile 'org.springframework.security:spring-security-config:' + spring_security_version
//JSTL
compile 'jstl:jstl:1.2'
//slf4j-log4j
compile 'org.slf4j:slf4j-api:1.7.0'
compile 'org.slf4j:slf4j-log4j12:1.7.0'
compile 'log4j:log4j:1.2.17'
//mybatis
compile 'org.mybatis:mybatis:3.2.4'
compile 'org.mybatis:mybatis-spring:1.2.2'
//gson
compile 'com.google.code.gson:gson:2.2.4'
//validation jsr303
compile 'javax.validation:validation-api:1.0.0.GA'
//junit4(test?)
compile 'junit:junit:4.11'
//spring test(test?)
compile 'org.springframework:spring-test:' + spring_version
//java mail
compile 'javax.mail:mail:1.4'
//tomcat plugin
def tomcatVersion = '7.0.53'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}
//additional classpath
classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3'
classpath 'org.postgresql:postgresql:9.2-1004-jdbc4'
}
}
In build.gradle there are also several tasks and several apply plugin.
What's the problem? Full stack trace
My build.gradle is in a project folder.
The build script is mixing up buildscript dependencies (i.e.
dependencies of the build itself; typically this means Gradle plugins
with regular dependencies (i.e. dependencies of the code to be compiled/run).
2 needs to go into dependencies { ... }, not into buildscript { dependencies { ... } }.
Everything but the classpath dependencies are regular dependencies.
I get this error sometimes after Android Studio does some operation that tries to automatically add things to my build.gradle file, and then it messes up lines of code in the dependencies block that end with quotes or double-quotes. So I end up with a line like this:
def gpsVersion = '9.4.0'
compile "com.google.android.gms:play-services-wearable:${gpsVersion}" compile "com.google.android.gms:play-services-places:${gpsVersion}"
And as you can see it looks like the method compile has many arguments now. Fix the line spacing and resync to fix it.