Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos

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.

Use Case


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:

  1. Create a new DC of type "External Library"

  2. Put the jar file(s) into the folder "library" of the "External Library" DC

  3. Create two public parts (compilation and assembly)

  4. Add the jar file(s) as entities to both public parts

  5. Build the "External Library" DC

  6. Create a second DC of type "J2EE Server Component Library"

  7. Add a build-time dependency to both public parts of the "External Library" DC

  8. Build the "J2EE Server Component Library" DC


With the new external library facet included since NW 7.0 SP13 the process is much simplier:



    1. Create a new DC of type "J2EE Server Component Library"

    2. Add a build-time dependency to the "def" public part of the new facet DC tc/bi/fct/extlib








    1. Create a local "libs" folder below the root folder and put the jar file(s) into that folder

    2. Define that libs folder as source folder in the DC Metadata >








  1. 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


Troubleshooting


Problem: The jar files of the external libraries are neither packaged into the SDA file nor copied to the public part.

Check:

The build log should contain some lines like these:
packExternalLibraries:
[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.

11 Comments