Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
kevin_hu
Active Participant

Background

As an Agentry developer supporting a few customers at the same time, it is easily getting lost in the various Agentry or Work Manager versions and source files.

Also whenever SAP released any notes on the java layer, it is important to get it updated into the Java project to ensure a correct order of the classpath before making a new build jar file. Takes this note (2268218) and this note (2256914) as example.

Another example can be that we need to include some 3rd-party java libraries into Agentry, such as Olingo to connect Odata which is discussed in this post.

Old Ant build tool cannot help us for all these. However we can use Maven. If you are new to Maven, please check the official link of Apache Maven.

Get Started

Here is the general steps to follow.

1. Install m2e Maven plugin for eclipse.

2. Create a Maven project with a baseline configuration.

3. Import your existing Agentry / Work Manager Java source code.

4. update the pom.xml for all the dependencies.

5. update the pom.xml for building steps.

First, we need to install the m2e Maven plugin. We use eclipse Juno 4.2.2 as example in this tutorial.

Once done, choose File->New Project. Select Maven Project.

Check "Create a simple project" and hit Next. Give a group id and artifact id, select Packaging as "Jar".

Remove the following created source folders as we do not need them.

src/test/java

src/test/resources

src/main/resources

And import your existing Agentry Java source file into src/main/java folder. Make sure you include this folder in the source Path.

Obviously there will be some errors because we have not included any of the dependency jar files of SAP Work Manager. We are going to do it in the next few steps. Before that we create a lib folder and import all the required jar files of work manager. Please note that we also include two jar files from those SAP notes we need to implement.

open the pom.xml as a text file. It is the main configuration file for Maven. Update the dependencies as follow. The sequence is important for the build path.


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.sap.customer</groupId>
  <artifactId>workmanagerjava</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
  <dependency>
  <groupId>com.syclo.sap</groupId>
  <artifactId>note-2268218-6.3</artifactId>
  <scope>system</scope>
  <version>1.0</version>
  <systemPath>${basedir}\lib\2268218-6.3.jar</systemPath>
  </dependency>
  <dependency>
  <groupId>com.syclo.sap</groupId>
  <artifactId>workmanager-6.3.0.0</artifactId>
  <scope>system</scope>
  <version>1.0</version>
  <systemPath>${basedir}\lib\workmanager-6.3.0.0.jar</systemPath>
  </dependency>
  <dependency>
  <groupId>com.syclo.sap</groupId>
  <artifactId>2256914-6.3</artifactId>
  <scope>system</scope>
  <version>1.0</version>
  <systemPath>${basedir}\lib\2256914-6.3.jar</systemPath>
  </dependency>
  <dependency>
  <groupId>com.syclo.sap</groupId>
  <artifactId>Agentry-v5</artifactId>
  <scope>system</scope>
  <version>1.0</version>
  <systemPath>${basedir}\lib\Agentry-v5.jar</systemPath>
  </dependency>
  <dependency>
  <groupId>com.syclo.sap</groupId>
  <artifactId>common-20151103</artifactId>
  <scope>system</scope>
  <version>1.0</version>
  <systemPath>${basedir}\lib\common-20151103.jar</systemPath>
  </dependency>
  <dependency>
  <groupId>com.syclo.sap</groupId>
  <artifactId>sapsso</artifactId>
  <scope>system</scope>
  <version>1.0</version>
  <systemPath>${basedir}\lib\sapsso.jar</systemPath>
  </dependency>
  <dependency>
  <groupId>com.syclo.sap</groupId>
  <artifactId>sapjco3</artifactId>
  <scope>system</scope>
  <version>1.0</version>
  <systemPath>${basedir}\lib\sapjco3.jar</systemPath>
  </dependency>
  <dependency>
  <groupId>com.syclo.sap</groupId>
  <artifactId>ini4j</artifactId>
  <scope>system</scope>
  <version>1.0</version>
  <systemPath>${basedir}\lib\ini4j.jar</systemPath>
  </dependency>
  </dependencies>
</project>











After saving the pom.xml, you can see all the compiling errors have been resolved. And you can also see the icons of the libraries jar files have been changed. The project structure will look like this.

Now we need to config the build part of the pom.xml file. In here we can specify the output we build. Append the following into the pom.xml and put it after the dependency section.





<build>

<finalName>ZSAPWM63</finalName>

<plugins>

<!-- Maven Shade Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-shade-plugin</artifactId>

<version>2.4.3</version>

<executions>

<!-- Run shade goal on package phase -->

<execution>

<phase>package</phase>

<goals>

<goal>shade</goal>

</goals>

<configuration>

<artifactSet>

<excludes>

<exclude>>com.syclo.sap:*</exclude>

</excludes>

</artifactSet>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</build>

In here we also set up the "Shade" plugin, which we use to bundle all our sources together into one jar. It can also include some 3rd party libraries we use. Take an example of utilizing the olingo library and export all the things into one (uber) jar file, the scenario is discussed in this blog. Check here for more information about Shade as well.

Start a command and navigate to the root directory of your project, put the command "mvn clean package"


Run it and in a few seconds you will get the ZSAPWM63.jar in the /target folder. Copy it to our SMP server and start testing. Done.


Some tips

The m2 plugin is a bit difficult to play with. If possible, use the command line.



Happy coding!

Labels in this area