Skip to Content

There are two ways to build SAPUI5 application in Maven.


1)  As explained by Ted Castelijns in How to use Maven to build your SAPUI5 application

2)  Simply convert and build SAPUI5 application in Maven. I will explain it in this blog


In option 1 you need to add SAPUI5 libraries to local Maven repository. I found it little tedious as it is not an one time job, we need to update it whenever there is a new version of SAPUI5 library available. The second option may not be a typical way of Maven build where you can specify SAPUI5 dependencies as well but it does the build & versioning job.

Assumptions:

  1. Maven plugin is installed in your eclipse. Note: It comes by default with Eclipse Luna onwards.
  2. SAPUI5 libraries are installed in eclipse

Create a SAPUI5 application. This is how a basic SAPUI5 project looks like, I have just replaced the generated folder with “app” folder, it has all sub-folders for the app. You are free to create your folder structure the way you want it but remember to change the assembly.xml file accordingly as below.

/wp-content/uploads/2015/01/1_618217.png

1) Convert it to a Maven project in Eclipse (Right click on project->Configure->Convert to Maven project), POM (pom.xml) wizard will pop up, change accordingly as in screen shot below.

/wp-content/uploads/2015/01/2_618278.png

/wp-content/uploads/2015/01/3_618279.png

Now the project is converted into a Maven project and pom.xml file is created.

There are few steps here:

1) Refer the pom.xml below and insert the build tag.


<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>SAPUI5_Maven</groupId>
  <artifactId>SAPUI5_Maven</artifactId>
  <version>1.0.0.001</version>
  <packaging>pom</packaging>
  <name>SAPUI5toMaven</name>
  <description>SAPUI5 to Maven</description>
  <build>
  <sourceDirectory>./WebContent</sourceDirectory>
  <plugins>
  <plugin>
  <artifactId>maven-clean-plugin</artifactId>
  <version>2.4.1</version>
  <executions>
  <execution>
  <id>clean</id>
  <phase>clean</phase>
  <goals>
  <goal>clean</goal>
  </goals>
  </execution>
  </executions>
  </plugin>
  <plugin>
  <artifactId>maven-release-plugin</artifactId>
  <version>2.4.2</version>
  <configuration>
  <releaseProfiles>release</releaseProfiles>
  <goals>deploy assembly:single</goals>
  </configuration>
  </plugin>
  <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-assembly-plugin</artifactId>
  <executions>
  <execution>
  <id>create-webcontent-distribution</id>
  <phase>package</phase>
  <goals>
  <goal>single</goal>
  </goals>
  <configuration>
  <finalName>WebContent</finalName>
  <appendAssemblyId>false</appendAssemblyId>
  <descriptors>
  <descriptor>assembly.xml</descriptor>
  </descriptors>
  </configuration>
  </execution>
  </executions>
  </plugin>
  </plugins>
  </build>
</project>




2) Insert assembly.xml file to your project at the same level as pom.xml. assembly.xml files is easy to understand. It builds the Target folder. It has the source directory/file path to Target directory/file mapping

3) Insert manifest.properties file (attached) at index.html level. It contains the app version number.

4) Go to your work space, find your project and insert .Ui5RepositoryTextFiles file (attached) in WebContent folder. I will explain the use of it when we upload/deploy the project in my next blog.


Now the project should look like this:

4.PNG

Project is ready to be build by Maven now.

1) Right click on project->Run As->Maven build .

2) Then “clean install” in the pop up->Run. Check the console for the build log “BUILD SUCCESS” should come up.

5.PNG

/wp-content/uploads/2015/01/6_618282.png

7.PNG

Refresh the project to see the Target folder with version number, folders & files as per assembly.xml file.

8.PNG

Remember to change the version number, Maven clean & Maven build every time you change the project for every new upload. You can create a template project and use it for new projects to avoid these steps.

Any suggestions are welcome.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Ted Castelijns

    Hi Amaresh,

    Nice blog, always good to have different options for different environments. At this moment we are using Nexus to host the SAPUI5 jars. Now we only have to add the jars once (per version we use). The upside is that you can easily switch between different versions and no extra work for the developers.

    We also use Jenkins for CI which uses the same libraries.

    kind regards,

    Ted

    (0) 
  2. Jatin Bhasin

    Hi Amaresh,

    I want to create a maven build for a ui5 library project.

    When I try to do so I am not getting the right jar file and also their.

    Earlier we used to create an archive of a library project, but now that is obsolete.

    It gives a message saying create a maven build.outdatedFunctionality.JPG

    Best Regards,

    Jatin

    (0) 
  3. Steffen Retz

    Hello,

    Unfortunately, I couldn’t findĀ the assembly.xml and theĀ  .Ui5RepositoryTextFiles. Is it possible that you upload the files again?

    Very thanks,

    Steffen

    (0) 

Leave a Reply