Multi-project EAR not coming out right


(David) #1

Hi everyone, I need help with building a proper EAR file within a multi-project. I appreciate anyone that can help me solve this.

I need the EAR to generate the following…

—EAR
—Project-A-JAR.jar located in the EAR in a folder called “libs”
—Project-B-EJB.jar located on the root of the EAR (**** This step builds correctly and is present in the EAR root.)
—All dependency jars located in the EAR in a folder called “libs”

My structure as follows…

-root folder
build.gradle

buildscript {
repositories {
    maven {
        url 'http://172.31.255.122:8081/artifactory/plugins-release'
        credentials {
            username = 'admin'
            password = 'password'
        }
    }
    
}
dependencies {
    //Check for the latest version here: http://plugins.gradle.org/plugin/com.jfrog.artifactory
    classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
}

}

allprojects {
apply plugin: “com.jfrog.artifactory”
}

artifactory {
contextUrl = “${artifactory_contextUrl}” //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = 'libs-release-local’
username = 'admin’
password = 'password’
maven = true

    }
}
resolve {
    repository {
        repoKey = 'libs-release'
        username = 'admin'
        passwor`d = 'password'
        maven = true
        
    }
}

}

gradle.properties

artifactory_user=admin
artifactory_password=password
artifactory_contextUrl=http://172.31.255.122:8081/artifactory

settings.gradle

include “:Project-A-JAR”, “:Project-B-EJB-JAR”, “:Project-C-EAR”

-Project A – JAR
build.gradle

apply plugin: 'java’
apply plugin: ‘eclipse’

sourceCompatibility = 1.8
jar {
manifest {
attributes ‘Implementation-Title’: ‘Project-A-JAR’
}
}

dependencies {
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final’
compile 'org.apache.cassandra:cassandra-all:2.1.5’
compile 'com.datastax.cassandra:cassandra-driver-core:2.0.1’
compile 'org.apache.hadoop:hadoop-core:1.2.1’
compile ‘org.apache.hbase:hbase:0.90.3’
}

apply plugin: “com.jfrog.artifactory”

repositories {
mavenCentral()
jcenter()
}

test {
systemProperties ‘property’: ‘value’
}

*src/main/java

-Project B – EJB JAR
build.gradle

apply plugin: 'java’
apply plugin: ‘eclipse’

sourceCompatibility = 1.8
jar {
manifest {
attributes ‘Implementation-Title’: ‘Project-B-EJB-JAR’
}
}

dependencies {
compile project(’:Project-A-JAR’)
compile ‘javax:javaee-api:6.0’
}

apply plugin: “com.jfrog.artifactory”

repositories {
mavenCentral()
jcenter()
}

test {
systemProperties ‘property’: ‘value’
}

*src/main/java

-Project C – EAR
build.gradle

apply plugin: ‘ear’

repositories {
mavenCentral()
jcenter()
}

apply plugin: “com.jfrog.artifactory”

dependencies {
deploy project(’:Project-B-EJB-JAR’)
}

ear {
appDirName 'EarContent’
deploymentDescriptor {
displayName = "app-ear"
description = “my application”
}
}

*EarContent
*src/main/java

Many thanks!