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' "
Related
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
Another strange behaviour of gradle...
So I've found this post:
Gradle exclude module for Copy task
Totally fine and works like a charm to exclude things from copying.
But here is where it gets interesting. This is how my Copy Task looks:
task copyDependencies(type: Copy) {
into "$buildDir/libs/dependencies"
from configurations.runtime {
exclude module: 'groovy'
exclude module: 'aws-java-sdk-s3'
exclude module: 'commons-io'
}
}
If I try to run the Application through Gradles 'application run' task. It fails with "Main Class xxx couldn't be found or loaded". Digging deeper into the problem I noticed that Groovy couldn't be resolved.
I don't even run this Task, or depend on it.
But if I comment out line 4 like this:
task copyDependencies(type: Copy) {
into "$buildDir/libs/dependencies"
from configurations.runtime {
//exclude module: 'groovy'
exclude module: 'aws-java-sdk-s3'
exclude module: 'commons-io'
}
}
The Application starts like normal, until it reaches a point where it needs Commons-IO. I still want to use this copyDependencies Task at other times, without changing the code there though.
Can somebody explain me this behaviour ?
I imagine manipulating the configuration.runtime anywhere in the gradle file, changes it for every other task ?
In your from configuration block, you are referencing the runtime configuration, but in the same time you are altering this configuration by adding some exclusion rules. This will alter the original (and unique) runtime configuration which will be used by all other tasks in your build project, as you have guessed. This explains the "Main Class xxx couldn't be found or loaded" error you get when trying to execute the run task, since the runtime configuration (classpath) does not contain the needed library.
If you want to write exclusions rules by group and/or module in your copyDependencies task, one possible way would be to work on a copy of the original runtime configuration; you could define a new Configuration for this purpose:
configurations{
runtimeDeps.extendsFrom runtime
}
task copyDependencies(type: Copy) {
into "$buildDir/libs/dependencies"
from configurations.runtimeDeps {
exclude module: 'groovy'
exclude module: 'aws-java-sdk-s3'
exclude module: 'commons-io'
}
}
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"
this syntax may be not yet provided but I am asking to avoid redundant code.
Right now I am excluding jars like this
compile ('com.mygroup:myJar:0.1.1-M1-SNAPSHOT+') {
exclude group: 'org.apache.xmlgraphics'
exclude group:'org.apache.avalon.framework'
exclude group:'net.engio'
exclude group: 'com.google.guava'
}
How can i exclude multiple groups/modules on a single line of code, for example, this syntax
compile ('com.mygroup:myJar:0.1.1-M1-SNAPSHOT+'){
exclude group: ['org.apache.xmlgraphics', 'org.apache.avalon.framework', 'net.engio', 'com.google.guava']
}
Or is there any other short code which does the same thing.
Thank You.
You could do something like this:
compile ('com.mygroup:myJar:0.1.1-M1-SNAPSHOT+'){
['org.apache.xmlgraphics', 'org.apache.avalon.framework', 'net.engio', 'com.google.guava'].each {
exclude group: it
}
}
Note that this is leveraging a Groovy feature, not a Gradle feature.
Note also that I don't believe that include is a thing in this context (see the method summary here).
compile ('com.mygroup:myJar:0.1.1-M1-SNAPSHOT+'){dep ->
['org.apache.xmlgraphics', 'org.apache.avalon.framework', 'net.engio', 'com.google.guava'].each {group -> dep.exclude group: group }
}
Refer to this.
I am trying to declare a compile dependency in Gradle 1.12, with multiple items that shares the same exclude clauses (this is to avoid repeating the exclusion everywhere). I know I can do something like this:
configurations {
compile.exclude group: 'com.google.gwt'
all*.exclude group: 'com.google.guava'
}
but this will affect ALL configurations. What I want is something like this (which does not work in Gradle 1.12 as written below):
compile (
["org.jboss.errai:errai-data-binding:2.4.4.Final"]
,["org.jboss.errai:errai-data-ioc:2.4.4.Final"]
){
exclude group: 'com.google.gwt'
exclude group: 'com.google.guava'
}
so I can gather together all dependencies for which I need exclusion in one place, and still be able to have elsewhere this:
compile 'com.google.guava:guava:17.0'
Update:
Just to clarify, my only goal is to replace this piece of code:
compile ('bla.bla.bla:1.0'){
exclude 'same.component:1.0' //Ugly repeat
}
compile ('boo.boo.boo:1.0'){
exclude 'same.component:1.0' //Ugly repeat
}
compile ('uh.uh.uh:1.0'){
exclude 'same.component:1.0' //Ugly repeat
}
compile ('oh.oh.oh:1.0'){
exclude 'same.component:1.0' //Ugly repeat
}
with something short and sweet like this (not working currently):
compile( 'bla.bla.bla:1.0'
,'boo.boo.boo:1.0'
,'uh.uh.uh:1.0'
,'oh.oh.oh:1.0'
)
{
exclude 'same.component:1.0' //Only once! Sweet!
}
There is no way to have per-dependency excludes while still being able to use the compile 'com.google.guava:guava:17.0' syntax. configurations.compile.exclude ... will only affect the compile configuration (and configurations inheriting from it), and is almost always preferable over per-dependency excludes.
Another solution is to factor out dependency declarations with something like:
ext.libs = [
error_data_ioc: dependencies.create("org.jboss.errai:errai-data-ioc:2.4.4.Final") {
exclude group: 'com.google.gwt'
exclude group: 'com.google.guava'
}
]
Then you can reuse these declarations wherever you need them (e.g. dependencies { compile libs.error_data_io }; also works from a subproject). If you really wanted, you could also share the same { exclude ... } block among multiple declarations (by assigning it to a local variable).