Create ear for non gradle project


(selvarajchennappan) #1

I want to create a ear using gradle to an existing projects.
The existing projects don’t have gradle file and I can’t add it as well.

Is it possible to compile and create ear file?


(Kashif Ur Rehman) #2

@selvarajc yes it is possible to create a war/jar/ear if existing project is not gradle based project. But for this you have to create a file named as “build.gradle” and write script to create war/jar/ear , and then place that file to root of your peoject. and then run that. An example of that script to create and WAR is :-

buildscript {
repositories {
jcenter()
}
}

apply plugin: 'java’
apply plugin: ‘war’

// JDK version source compatibility
sourceCompatibility = 1.8
// project version
version = ‘1.0’
// War file name
war.baseName = ‘EmailServiceGradle1’
// Web directory, this overrides the default value "webapp"
project.webAppDirName = ‘WebContent’

repositories {
mavenLocal()
mavenCentral()
}

// Set source directory
sourceSets {
main {
java {
srcDir ‘src’
}
resources {
srcDir ‘configs’
}
}
}

dependencies {
compile group: ‘commons-collections’, name: ‘commons-collections’, version: ‘3.2’
// https://mvnrepository.com/artifact/org.jdom/jdom2
compile group: ‘org.jdom’, name: ‘jdom2’, version: ‘0.0.6-BETA’
// https://mvnrepository.com/artifact/net.iharder/base64
compile group: ‘net.iharder’, name: ‘base64’, version: ‘2.3.9’
// https://mvnrepository.com/artifact/javax.persistence/persistence-api
compile group: ‘javax.persistence’, name: ‘persistence-api’, version: ‘1.0.2’

    // https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
    compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
    // https://mvnrepository.com/artifact/org.jdom/jdom
    compile group: 'org.jdom', name: 'jdom', version: '1.1'
    // https://mvnrepository.com/artifact/javax.ejb/ejb-api
    compile group: 'javax.ejb', name: 'ejb-api', version: '3.0'


     compile group: 'javax.mail', name: 'mail', version: '1.4'
  compile group: 'org.springframework', name: 'spring-aop', version: '4.0.1.RELEASE'
  compile group: 'org.springframework', name: 'spring-aspects', version: '4.0.1.RELEASE'
  // https://mvnrepository.com/artifact/org.springframework/spring-beans
  compile group: 'org.springframework', name: 'spring-beans', version: '4.0.1.RELEASE'
  compile group: 'org.springframework', name: 'spring-web', version: '4.0.1.RELEASE'
  compile group: 'org.springframework', name: 'spring-context', version: '4.0.1.RELEASE'
  // https://mvnrepository.com/artifact/org.springframework/spring-context-support
  compile group: 'org.springframework', name: 'spring-context-support', version: '4.0.1.RELEASE'
  // https://mvnrepository.com/artifact/org.springframework/spring-core
  compile group: 'org.springframework', name: 'spring-core', version: '4.0.1.RELEASE'
     // https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore
  compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.0.1'
}