Difference between revisions of "Building iDempiere by tycho"

From iDempiere en
m (continue english edits)
m (continue english edits)
Line 181: Line 181:
 
** define Osgi bundle feed from maven repositorys
 
** define Osgi bundle feed from maven repositorys
  
== Know issue ==
+
== Known issue ==
# before step 2.2.1 "on eclipse menu choose file/import" un-tick "project/automatically", because that time not yet active target platform, so build make slow and can't complete.
+
# Before step 2.2.1 "On eclipse menu choose file/import" uncheck "project/automatically", because that time the target platform is still inactive, so build became slow and can't complete.
# some time by sourceforge, active target platform done with error, so can't build complete. check like bellow
+
# Sometimes due to sourceforge, active target platform done with errors, so can't complete build complete. Follow bellow:
 
[[File:TargetIssue.png|none|thumb]]
 
[[File:TargetIssue.png|none|thumb]]
  

Revision as of 08:07, 23 March 2018

Why move to Maven Tycho?

  1. Buckminster is no longer maintained
  2. Maven has huge following

More discussion at IDEMPIERE-3531 and group

Prepare Eclipse to handle Tycho Project

Install Tycho Support

  1. Go to Eclipse Marketplace
  2. Search for Tycho
  3. Choose to install "Tycho Build Tools", "maven tycho utility"

Install m2e Connector

  1. Go to Window/Preferences
  2. Menu Maven/Discovery
  3. Click to open Catalog
  4. On find field type "Tycho"
  5. Choose tycho configurator and install it
  6. Do same for "m2e connector for the maven dependency plugin"

Step to build and setup development environment

  1. Materialize and build (this step use for headless build also use for setup development for eclipse)
    1. Clone source from bitbucket.org to folder [idempiere-home]
    2. Open terminal, cd to [idempiere-home] and fire command "mvn verify"
      • It downloads all library on Bundle-ClassPath
      • Compiles all project
      • Package a binary at [idempiere-home]/org.idempiere.p2/target/products
  2. Setup eclipse
    1. Import projects
      1. Open Eclipse with Workspace at [idempiere-home]
      2. From Eclipse Menu, choose file/import
      3. From dialog, choose Maven/Exist maven project
      4. Next dialog, browse to [idempiere-home]
      5. Select all projects and finish dialog
      6. All projects are loaded to workspace
    2. Activate a target file
      1. From Eclipse Menu, choose File/Import
      2. From Dialog, choose "Existing projects into workspace"
      3. Choose [idempiere-home]/org.idempiere.p2.targetplatform and click finish
      4. Open a target file org.idempiere.p2.targetplatform/org.idempiere.p2.targetplatform.target is default with remote url
      5. From Target Editor, click to "Set as active target platform"
      6. Wait for Eclipse to download bundles onto target platform
    3. Now your environment is similar to Buckminster's.

Config a jenkins

  1. setup maven for jenkins
  2. create a maven project
  3. on "Source Code Management" section
    • Repository URL=[[1]] (up to your actual repository)
    • Revision=experimental (up to your actual repository)
  4. on build step, setup below value
    • Root POM=pom.xml
    • Goals and options=verify

Make a Osgi plugin become maven project

  1. create a normal plugin/feature project on eclipse
  2. right click to project and choose "Configure/Convert to Maven Project"
  3. on dialog, field "Package" type value depend on type of plug-in
    • eclipse feature => "eclipse-feature"
    • eclipse plugin/fragment => "eclipse-plugin"
  4. after eclipse do convert project. it add a pom.xml to project, i advice you adjust below value
    • add parent section
      • <parent>
        		<groupId>org.idempiere</groupId>
        		<artifactId>org.idempiere.parent</artifactId>
        		<version>5.1.0-SNAPSHOT</version>
        		<relativePath>../org.idempiere.parent/pom.xml</relativePath>
        	</parent>
        
  5. open MANIFEST.MF and make sure below thing
    • on runtime tab, section classpath have item "." if don't have one, you should create new one
  6. on build.properties
    • adjust output to "/target/classes"
    • in case your project have source, make sure it list on "source.. = src/"
  7. reference:

Build extra plugin

Build by run script from local

  1. build idempiere core so we have a p2 repository contain all idempiere core also dependency at idempiere/org.idempiere.p2/target/repository
  2. host this repository to a web server. can use jetty-maven-plugin
  3. create a maven tycho target plugin point to server setup at step 2
  4. build extra plugin by use target at step 3

Full example and step by step guideline here

Build by run jenkins job

because you have to check out from multi repository, i prefer to use jenkins pipeline

beside normal pipeline plugin you have to install "Pipeline Maven Integration Plugin"

for newbie to jenkins pipeline, i suggest to use this tool to generate script http://%5Bjenkins_server%5D/job/%5Bjob_name%5D/pipeline-syntax/

Pipeline syntax.png

Step to build

  1. Setup a web server (like apache httpd at port 80 on same server jenkin, so access by localhost), assume document dir at /var/www/html
  2. Setup a jenkins job to build idempiere core.
  3. when success build copy artifact to /var/www/html/idempiere-core/latest
  4. this is pipe line for build idempiere-core
    node {
       def mvnHome
       stage('Preparation') { // for display purposes
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', revision: 'hsv', source: 'ssh://hg@bitbucket.org/hasuvimex/idempiere', subdir: 'idempiere'])
       }
       stage('Build') {
                
            withMaven(jdk: 'openjdk', maven: 'build-in maven', publisherStrategy: 'EXPLICIT') {
                sh "cd ${WORKSPACE}/idempiere && mvn verify"
            }
            
            sh '''p2OutputDir="${WORKSPACE}/idempiere/org.idempiere.p2/target/repository"
                webDir="/var/www/html/repository/idempiere-hsv-core/latest"
                mkdir -p ${webDir}
                cp -r ${p2OutputDir}/* ${webDir}'''
       }
       stage('Results') {
     
       }
    }
    
  5. Setup other jenkins job to build extra plugin
  6. This's pipeline script
    node {
       def mvnHome
       stage('Preparation') { // for display purposes
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', revision: 'hsv', source: 'ssh://hg@bitbucket.org/hasuvimex/idempiere', subdir: 'idempiere'])
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', revision: 'hsv', source: 'ssh://hg@bitbucket.org/idplugin/idempiere.maven.tycho.build.extra.bundle', subdir: 'idempiere.maven.tycho.build.extra.bundle'])
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', source: 'ssh://hg@bitbucket.org/hasuvimex/project.extra.bundle', subdir: 'project.extra.bundle'])
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', revision: 'hsv', source: 'ssh://hg@bitbucket.org/hasuvimex/org.idempiere.customize-feature', subdir: 'project.extra.bundle/org.idempiere.customize-feature'])
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', source: 'ssh://hg@bitbucket.org/idplugin/th.motive.idempiere.base', subdir: 'project.extra.bundle/th.motive.idempiere.base'])
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', source: 'ssh://hg@bitbucket.org/idplugin/th.motive.jasper.report.font', subdir: 'project.extra.bundle/th.motive.jasper.report.font'])
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', source: 'ssh://hg@bitbucket.org/idplugin/th.motive.utility', subdir: 'project.extra.bundle/th.motive.utility'])
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', source: 'ssh://hg@bitbucket.org/hasuvimex/vn.hsv.editor.currencyrate', subdir: 'project.extra.bundle/vn.hsv.editor.currencyRate'])
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', source: 'ssh://hg@bitbucket.org/hasuvimex/vn.hsv.idempiere.base', subdir: 'project.extra.bundle/vn.hsv.idempiere.base'])
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', source: 'ssh://hg@bitbucket.org/hasuvimex/vn.hsv.idempiere.override', subdir: 'project.extra.bundle/vn.hsv.idempiere.override'])
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', source: 'ssh://hg@bitbucket.org/hasuvimex/vn.hsv.jasperreport.install', subdir: 'project.extra.bundle/vn.hsv.jasperreport.install'])
            checkout([$class: 'MercurialSCM', clean: true, credentialsId: 'mainSshKey', source: 'ssh://hg@bitbucket.org/idplugin/th.motive.jasperreport.configuration', subdir: 'project.extra.bundle/th.motive.jasperreport.configuration'])
            
       }
       stage('Build') {
                
            withMaven(jdk: 'openjdk', maven: 'build-in maven', publisherStrategy: 'EXPLICIT') {
                sh  '''
                        ${WORKSPACE}/idempiere.maven.tycho.build.extra.bundle/update.version.sh "/var/www/html/repository/idempiere-hsv-core/latest/plugins" "org.adempiere.base_*.jar"
                    '''
            }
            
            
            sh '''newP2Url="http://localhost/repository/idempiere-hsv-core/latest"
                oldP2Url=http://localhost:8080/idempiere-core
                sed -ri "s|${oldP2Url}|${newP2Url}|g" ${WORKSPACE}/idempiere.maven.tycho.build.extra.bundle/org.idempiere.p2.build.extra.bundle.targetplatform/org.idempiere.p2.build.extra.bundle.targetplatform.target'''
            
            withMaven(jdk: 'openjdk', maven: 'build-in maven', publisherStrategy: 'EXPLICIT') {
                sh '''cd ${WORKSPACE}/idempiere.maven.tycho.build.extra.bundle && mvn verify -Didempiere.target="org.idempiere.p2.build.extra.bundle.targetplatform"'''
            }
       }
       stage('Results') {
     
       }
    }
    
    note: you still have to checkout idempire on this job, because some plugin refer to parent pom on idempiere

Common command

  • mvn verify -P online
    • build idempiere with online profile (will use remote repository for feed all dependency bundle)

Summary about tycho use on idempiere (for full reference tycho API)

[idempiere-root]/pom.xml

setup list of module (bundle) will build with command "mvn -P online"

[idempiere-root]/org.idempiere.parent/pom.xml

  • is parent pom with almost configuration, other bundle will inheritance from this pom
  • profiles
    • Set properties for build condition, current use to setup online and offline repository
  • repositories
    • Setup list of repository use to resolve dependency
    • with P2 repository use "<layout>p2</layout>"
  • dependencies
    • define Osgi bundle feed from maven repositorys

Known issue

  1. Before step 2.2.1 "On eclipse menu choose file/import" uncheck "project/automatically", because that time the target platform is still inactive, so build became slow and can't complete.
  2. Sometimes due to sourceforge, active target platform done with errors, so can't complete build complete. Follow bellow:
TargetIssue.png

Reference

API to configuration tycho

API to configuration extra tycho plugin

Sync bundle version on manifest with version on pom.xml

Tycho package type

A good summary

Idempiere maven tycho is MANIFEST-First

A complete guild about tycho setup (Have to read)

Explain about root-ui for feature

Cookies help us deliver our services. By using our services, you agree to our use of cookies.