How can i have a property in the compile group gradle file - maven

Hi I want to use a gradle property in my gradle build file like this:
compile group: 'org.hibernate', name: 'hibernate-core', version: '${hibernateVersion}'
and i have in the gradle.properties this entry
hibernateVersion:5.2.6.Final
But each time it gives me error:
Could not create an instance of type org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency_Decorated

Try:
compile "org.hibernate:hibernate-core:$hibernateVersion"

Related

Liferay 7.2 No value has been specified for property 'apiDir'

I created a module project using servicebuild template (gradebook-api, gradebook-service), but i have an error after an export package com.liferay.training.gradebook.validator in api below
Bundle-Name: gradebook-api
Bundle-SymbolicName: com.liferay.training.gradebook.api
Bundle-Version: 1.0.0
Export-Package: \
com.liferay.training.gradebook.exception,\
com.liferay.training.gradebook.model,\
com.liferay.training.gradebook.service,\
com.liferay.training.gradebook.service.persistence,\
com.liferay.training.gradebook.validator
-check: EXPORTS
-includeresource: META-INF/service.xml=../gradebook-service/service.xml
i have a problem in the BuildService gradle task that's says :
Some problems were found with the configuration of task
':modules:gradebook:gradebook-api:buildService' (type
'BuildServiceTask').
File 'C:\Liferay\ide-workspace\training-workspace\modules\gradebook\gradebook-api\service.xml'
specified for property 'inputFile' does not exist.
No value has been specified for property 'apiDir'.
And this is a how I add the api module as dependency in service.
dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.io"
compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
compileOnly group: "com.liferay", name: "com.liferay.petra.string"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
compileOnly group: "org.osgi", name: "org.osgi.core"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
compileOnly group: "javax.portlet", name: "portlet-api"
compileOnly group: "javax.servlet", name: "javax.servlet-api"
compile project(":modules:gradebook:gradebook-api")
}
buildService {
apiDir = "../gradebook-api/src/main/java"
}
group = "com.liferay.training.gradebook"
I am trying to create new Liferay workspace but i got the same error (May be this is an error with Gradle)
Be sure, you run gradle task in the corresponding folder (in gradebook-service folder). I got similar error when I ran it in upper folder which contains api and service folder.
Until recently I have only worked on LR 7.0, but the last day or so have been playing with 7.3. I encountered the exact issue you describe.
The only solution I found was to copy service.xml from gradebook-service into the root of both my gradebook-api and gradebook-web modules and also add the following to the build.gradle files of both the gradebook-api and gradebook-web modules:
buildService {
apiDir = "../gradebook-api/src/main/java"
}
After that service builder ran successfully. There may be a cleaner way around it, but this worked for me.
service.xml should stay in service module only. Here, it look you need few checks.
api module dependency should be compileonly. not in compile
scope.
block order also matters in gradle file. move below block
at the top of the file.
buildService {
apiDir = "../gradebook-api/src/main/java"
}
not sure why you need -check:exports header in bnd file. As, that is not required normally.
In the Gradle task tab, go to your specific module service folder and then build it from there. Don't forget to refresh your gradle by pressing Cntrl+F5.
This Worked for me.
I had the same situation and just added the buildService{...} in build.gradle in the api module.
buildService {
apiDir = "../gradebook-api/src/main/java"
}
After: BUILD SUCCESSFUL

Unable to load class grails.plugins.rendering.image.ImageRenderingService Grails 4 Rendering:2.03

I am trying to use the plugin rendering:2.0.3 in grails 4 but i get the compilation error:
Unable to load class grails.plugins.rendering.image.ImageRenderingService
The solution was to add the missing clasess in the file build.gradle
compile group: 'org.xhtmlrenderer', name: 'flying-saucer-core', version: '9.1.6' //class org.xhtmlrenderer.simple.Graphics2DRenderer
compile group: 'io.github.msalaslo', name: 'flying-saucer-pdf', version: '9.1.20' //class org/xhtmlrenderer/pdf/ITextRenderer
compile 'org.grails.plugins:rendering:2.0.3'
thanks to the website for providing it
https://jar-download.com/artifacts/org.xhtmlrenderer/flying-saucer-core/9.1.8/source-code/org/xhtmlrenderer/simple/Graphics2DRenderer.java

How to disable gradle plugin by environments

I have two different environments say lower env and production. I have few gradle dependencies which should not get downloaded or used in production. So I want to block those plugins to get downloaded or activated in PROD.
I want the below plugins not to get added in prod, but in development and test environments .
// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-sleuth-zipkin-stream
compile group: 'org.springframework.cloud', name: 'spring-cloud-sleuth-zipkin-stream', version: '1.0.0.RELEASE'
// https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-sleuth
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-sleuth', version: '2.1.1.RELEASE'
There are two recommended ways to disable the Daemon persistently for
an environment: Via environment variables: add the flag
-Dorg.gradle.daemon=false to the GRADLE_OPTS environment variable. Via properties file: add org.gradle.daemon=false to the
«GRADLE_USER_HOME»/gradle.properties file.

How to exclude specific jars when using gradle in IntelliJ

I think there is a function to exculde from the pop-up menu by right-clicking on the screen below.
And I added my own build.gradle like below, but the dependency I want is not removed.
dependencies {
compile ('org.springframework.boot:spring-boot-starter-data-jpa:2.0.5.RELEASE') {
exclude group: 'org.apache.logging', module: 'log4j-to-slf4j'
}
....
....
}
Is that right?
Seems you missed "log4j" at the end of group name: "exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' "

Gradle configuration/dependency syntax

I am struggling to understand the gradle groovy syntax for dependencies and what is going on behind the scenes. As a starter I don't see what is exactly happening in this code snippet ....
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
}
What I (hope to) understand (please correct if I am wrong):
dependecies is a method of the org.gradle.api.Project interface /
org.gradle.api.internal.project.DefaultProject class which expects a
Closure to configure the dependencies of the project.
compile is a org.gradle.api.artifacts.Configuration which has been added by the org.gradle.api.plugins.JavaPlugin
What I don't understand:
What exactly is happening by specifying group: 'commons-collections', name: 'commons-collections', version: '3.2' ?
Does this invoke some magic method of the compile configuration object (if so, which one)?
Are group, name and version named parameters of a method call or are they method calls themselves?
Does this create a new org.gradle.api.artifacts.Dependency instance which is added to the compile configuration?
Gradle (like other tools built with Groovy) makes lots of use of methodMissing(...): http://www.groovy-lang.org/metaprogramming.html#_methodmissing
So what happens in the case of dependencies is that you invoke a method that does not exist. The method name is the name of the configuration, and its arguments are the dependency specification.
methodMissing(...) will be called and this will in turn call one of the add(...) methods of DependencyHandler: https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/dsl/DependencyHandler.html

Resources