Adding an external library facet to a J2EE Server Component Library DC
Starting with NW 7.0 SP13 the software component provided by SAP SAP_BUILDT (includes the main build plugins) is enhanced with a new Development Component with the name tc/bi/fct/extlib. This facet DC can be used to simplify DC structures a bit by allowing developers to combine the functionality of an “External Library” DC with a “J2EE Server Component Library” DC.
You want to use some Java libraries that were produced outside of NWDI. Since you want to reuse those libraries within your application development you need to package these libaries in a component model format – a Development Component (DC).
For developments prior to NW 7.0 SP13 this meant you had to do the following:
- Create a new DC of type “External Library”
- Put the jar file(s) into the folder “library” of the “External Library” DC
- Create two public parts (compilation and assembly)
- Add the jar file(s) as entities to both public parts
- Build the “External Library” DC
- Create a second DC of type “J2EE Server Component Library”
- Add a build-time dependency to both public parts of the “External Library” DC
- Build the “J2EE Server Component Library” DC
With the new external library facet included since NW 7.0 SP13 the process is much simplier:
- Create a new DC of type “J2EE Server Component Library”
- Add a build-time dependency to the “def” public part of the new facet DC tc/bi/fct/extlib
- Create a local “libs” folder below the root folder and put the jar file(s) into that folder
- Define that libs folder as source folder in the DC Metadata >
- Build the DC
While this may not look much shorter in this list here you will find that it takes much less time and keeps the DC structure much more simple. Just try it.
Verifying the result
If you kept to the explanation above you should have
- a public part with the name deflib that contains your jar file
- an SDA file in the gen/default/deploy folder that contains the added jar file(s)
- a provider.xml descriptor file contained in the SDA file with appropriate entries for each jar file
Problem: The jar files of the external libraries are neither packaged into the SDA file nor copied to the public part.
The build log should contain some lines like these:
[pppacker] Packed 1 file or entity my-external.jar (Archive/Java Library)
Your DC MetaData should look like this. The libs folder is added as source folder in the DC metadata and a build-time dependency to tc/bi/fct/extlib exists.
How does it work?
The DC tc/bi/fct/extlib provides an extension to the build plugin framework that adds special handling for a “libs” source folder. Effectively this extension creates an additional Ant build file and wraps the jar files from the libs folder into a public part structure and adds that internal public part to the build. The standard build process for the J2EE Server Component Library will just see an addtional public part that is packaged like any other used public part. For the developer in the developer studio no additional public part is visible.