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: 

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.

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.

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:

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.

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

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.

4 Comments
Labels in this area