I am trying to build ear using gradle build and ear is building fine.In my project ejb module is creating multiple custom jar along with ejb jar .How to add them onto ear root directory instead of adding them in lib folder
I am able to include them in ear lib folder but not in EAR root directory
EAR/APP-INF/lib/A.jar
should be EAR/A.jar
project(':A-project')
earproject(path: ':A-project',configurations:'provided')
earfiles(project(':A-project').tasks.findByName('ATask'))
Try adding deploy(A.jar) to your dependencies{} code block. This will create an ejb entry in the application.xml
build.gradle
dependencies {
deploy(A.jar)
}
Reference
dependencies
{
deploy project(path: ':A-Project')//jar files
deploy project(path: ':B-Project',configuration:'archives')//war files
deploy project(project(':C-Project').tasks.findByName("app"))//project in built jars
}
Related
I have multi-module project. I am using the following Gradle script to build zip which contains the sub-project's jar along with its dependencies.
dependencies {
api(project(":sub-project1"))
implementation(project(":sub-project2"))
implementation("some:lib:1")
implementation("some:lib:2")
}
tasks.register<Zip>("buildZip") {
archiveFileName.set("filename.zip")
from(tasks.jar)
from(configurations.runtimeClasspath)
}
The generated zip file will have all the jars of project1 and project2 along with dependency jars mentioned in the current sub-project.
My requirement is, I want to exclude jar files from project1 and project2 (along with dependency jars from there) and only include this sub-project's jar and dependencies mentioned in this sub-project.
How can this be achieved ? Any help is appreciated. Thanks.
Gradle war plugin: how to build a jar and add it to war?
projectRoot/
src/main/java
src/main/resources
src/main/webapp
build a jar (foo.jar) from the java source code and resources.
add the jar under the WEB-INF/lib of the war.
WEB-INF/lib/foo.jar
The war task will not build a jar by default, and add all java classes and resources under WEB-INF/classes.
UPDATE
The War plugin extends the Java plugin to add support for assembling web
application WAR files. It disables the default JAR archive generation of the
Java plugin and adds a default WAR archive task.
There is a way to enable the Jar generation and let task war depends on task jar?
not sure if eastwater still needs the answer, hope others with the same problem will find this helpful
you can add/configure the war task in build.gradle
war {
classpath = classpath - sourceSets.main.output
from (jar) {
into 'WEB-INF/lib'
}
}
once build succeed, in build/libs folder you'll see the generated jar and the war containing the generated jar instead of classes
Add those into your root build.gradle
plugins {
id 'java'
id 'idea'
}
jar{
String somestr=''
configurations.runtime.each{somestr=somestr+" lib\\"+it.name}
manifest{
attributes 'Main-Class':'your_class_name'
attributes 'Class-Path':somestr
}
}
task copyJar(type:Copy){
from configurations.runtime
into ('build/libs/lib')
}
task release(type: Copy,dependsOn:[build,copyJar]){
}
add finally run this command
gradle release
I have the following project structure. Gradle 3.1
RootProject
-- Project A <-- RESTful JAX-RS Project
-- Project B <-- Services Project containing EJB's
I want to assemble this project into one single WAR archive such as RootProject.war which would include Project A & B for deployment in an EAR archive (totally separate from this project).
How do I setup the root level build.gradle and the sub projects build.gradle files?
If I set the apply plugin: 'war' to the root build.gradle i get options for creating war archives from each project!
I'm using Gradle to create an ear, but I'm having a hard time figuring out how to properly include dependencies in the lib folder.
I know that I can use
earlib project (group:name:version)
to include jars there. And that also those jars' compile dependencies are going to be added in the ear's lib folder.
My problem is that I also have jars that are listed in the ear's build.gradle as
deploy project (':jar-name')
How can I add their dependencies in the lib folder?
The only way I found is to add them as earlib or as dependencies of an earlib, but this forces me to write them twice and feels harder than it should be (with Maven you just need to specify your dependencies in the subprojects and they will be added in the ear\lib directory)
EDIT
Basically what I would like to end up with, is a transitive deploy configuration.
I have a spring boot gradle project with multiple modules in it. The parent project (metadata) is just the root folder for child projects and there are 3 child projects (api, security and ui).
security is a standalone project that uses spring security. here is its pom
dependencies {
compile "org.springframework.boot:spring-boot-starter-security"
compile "com.att.security:csp-cookies:1.0"
compile "javax.servlet:javax.servlet-api"
}
api project uses some of classes from security project so it depends on that
dependencies {
compile ("org.springframework.boot:spring-boot-starter-data-rest") {
exclude module: "spring-boot-starter-tomcat"
}
compile "org.apache.httpcomponents:httpclient:4.4"
compile(project(":metadata-security"))
}
3.finally the UI project is the runnable project that combines everything together.
dependencies {
compile "org.springframework.boot:spring-boot-starter-thymeleaf"
compile project(":api:metadata-api-invenio")
compile(project(":metadata-security"))
}
When I do gradle build spring boot gradle plugin generates the fat jar for all 3 projects. Upon extracting the jar file it seems like all the transitive deps from all projects are available in the libs folder inside the fat jar. This is good but for some reason the security project jar file is a fat jar and contains its dependencies inside its lib folder which is not needed. In contrast to that, api project jar is not a fat one and only contains its classes because its jars are already available in the ui fat jar.
Any ideas why security project jar is being created different from api project.