0

I have weblogic 10.3.6 installed on local. I usually add wlserver_10.3\server\lib\weblogic.jar in classpath of my eclipse project and it brings all other weblogic runtime jars to the classpath from MANIFEST.MF file of weblogic.jar.

See image showing content of MANIFEST.MF. content of MANIFEST.MF

The problem I have is with gradle project when I add weblogic jar as flat dir dependency.

weblogic.jar gradle dependency

It pulls only weblogic.jar to the classpath but does not respect it's MANIFEST.MF and does not bring all other jars.

Is there any standard way in gradle to pull dependencies from MANIFEST.MF of included jar?

Rakesh Prajapati
  • 1,078
  • 8
  • 17

1 Answers1

0

There is no standard approach to this but a workaround can be applied though. You can define a method which reads the classpath of weblogic.jar manifest file and return the list of files which can then be used in the dependency.

// Method to return files mentioned in manifest file
import java.util.jar.Attributes;
def getWeblogicDependencyFiles() {

    def fileList = []
    def weblogicJarDir = '/path/to/webLogic/folder/10.3.6/wlserver_10.3/server/lib'
    def classPathJars = new java.util.jar.JarFile(weblogicJarDir+'/weblogic.jar').manifest.mainAttributes.get(Attributes.Name.CLASS_PATH).split(' ')
    for(String jarName : classPathJars) {
        if("".equals(jarName.trim())) {
            continue;
        }
        fileList.add(file(weblogicJarDir+'/'+jarName))
    }

    return fileList
}

next assign the output of this method to a variable

// Make te output available to project
project.ext.weblogicDependencyFiles = getWeblogicDependencyFiles();

Now you can use these files as dependency in your project

// Dependency
dependencies {
    compile files(weblogicDependencyFiles)
}

Again this is just a workaround. A better approach would be define dependencies from a central repository.