Building iDempiere by tycho
From iDempiere en
Why move to Maven Tycho?
- Buckminster is no longer maintained
- Maven has huge following
More discussion at IDEMPIERE-3531 and group
Prepare Eclipse to handle Tycho Project
Install Tycho Support
- Go to Eclipse Marketplace
- Search for Tycho
- Choose to install "Tycho Build Tools", "maven tycho utility"
Install m2e Connector
- Go to Window/Preferences
- Menu Maven/Discovery
- Click to open Catalog
- On find field type "Tycho"
- Choose tycho configurator and install it
- Do same for "m2e connector for the maven dependency plugin"
Step to build and setup development environment
- Materialize and build (this step use for headless build also use for setup development for eclipse)
- Clone source from bitbucket.org to folder [idempiere-home]
- Open terminal, cd to [idempiere-home] and execute command "mvn verify"
- It downloads all libraries on Bundle-ClassPath
- Compiles all projects
- Package a binary at [idempiere-home]/org.idempiere.p2/target/products
- Setup Eclipse
- Import projects
- Open Eclipse with Workspace at [idempiere-home]
- From Eclipse Menu, choose File/Import
- From dialog, choose Maven/Exist maven project
- Next dialog, browse to [idempiere-home]
- Select all projects and finish dialog
- All projects are loaded to workspace
- Activate a target file
- From Eclipse Menu, choose File/Import
- From dialog, choose "Existing projects into workspace"
- Choose [idempiere-home]/org.idempiere.p2.targetplatform and click finish
- Open a target file org.idempiere.p2.targetplatform/org.idempiere.p2.targetplatform.target is default with remote url
- From Target Editor, click to "Set as active target platform"
- Wait for Eclipse to download bundles onto target platform
- Now your environment is similar to previous Buckminster's.
- Import projects
Config For Jenkins
- Setup Maven for Jenkins
- Create a Maven Project
- In "Source Code Management" Section
- Repository URL=[[1]] (up to your actual repository)
- Revision=experimental (up to your actual repository)
- On build step, setup with value:
- Root POM=pom.xml
- Goals and options=verify
How to set an OSGi Plugin as a Maven Project
- Create a normal plugin/feature project on eclipse
- Right click to project and choose "Configure/Convert to Maven Project"
- In dialog, field "Package" type value depends on type of plug-in
- Eclipse feature => "Eclipse-feature"
- Eclipse plugin/fragment => "Eclipse-plugin"
- After eclipse has converted project, there will be a pom.xml inside project space, please adjust value as below:
- 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>
- Add parent section
- Open MANIFEST.MF and continue checking..
- At Runtime tab, section classpath has item "." if not, you should create one
- on build.properties
- Adjust Output to "/target/classes"
- In case your project has source, make sure it is stated: "source.. = src/"
- Reference:
Build Extra Plugin
Build by Run Script from local
- Build idempiere core so we have a p2 repository contain all idempiere core also dependency at idempiere/org.idempiere.p2/target/repository
- Host this repository to a web server. can use jetty-maven-plugin
- Create a maven tycho target plugin point to server setup at step 2
- 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
Besides, 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/
Steps to build
- Setup a web server (like apache httpd at port 80 on same server jenkin, for access by localhost), assume document dir at /var/www/html
- Setup a jenkins job to build idempiere core.
- Successful build will copy artifact to /var/www/html/idempiere-core/latest
- This is pipeline 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') { } }
- Setup other jenkins job to build extra plugin
- This's pipeline scriptnote: you still have to checkout idempire on this job, because some plugin refer to parent pom on idempiere
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') { } }
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
- 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 becomes slow and cannot complete.
- Sometimes due to condition in Sourceforge, the active Target Platform ends with errors, hindering a complete clean build. Take a look bellow for tips:
Reference
More API to configure tycho plugin
Sync bundle version on manifest with version on pom.xml
Idempiere maven tycho is MANIFEST-First
A complete guide about tycho setup (Must read)
