Difference between revisions of "Building iDempiere by tycho"

From iDempiere en
m (editing english)
m (continuing english edits)
Line 1: Line 1:
 
== Why move to [http://www.eclipse.org/tycho/ Maven Tycho]? ==
 
== Why move to [http://www.eclipse.org/tycho/ Maven Tycho]? ==
1. Buckminster is no longer maintained
+
# Buckminster is no longer maintained
2. Maven has huge following
+
# Maven has huge following
  
 
More discussion at [http://idempiere.atlassian.net/browse/IDEMPIERE-3531 IDEMPIERE-3531] and [http://groups.google.com/forum/#!msg/idempiere/yBU69qw8ZDk/_ZVjwF7vBAAJ group]
 
More discussion at [http://idempiere.atlassian.net/browse/IDEMPIERE-3531 IDEMPIERE-3531] and [http://groups.google.com/forum/#!msg/idempiere/yBU69qw8ZDk/_ZVjwF7vBAAJ group]

Revision as of 08:00, 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 download all library on Bundle-ClassPath
      • compiler 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. on eclipse menu choose file/import
      3. on dialog choose Maven/Exist maven project
      4. next dialog browse to [idempiere-home]
      5. select all project and finish dialog
      6. all project is loaded to workspace
    2. Active a target file
      1. on eclipse menu choose file/import
      2. on 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. on target editor click to "Set as active target platform"
      6. waiting eclipse download bundles to target platform
    3. now you have environment same buckminster age

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

Know issue

  1. 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.
  2. some time by sourceforge, active target platform done with error, so can't build complete. check like 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.