Difference between revisions of "Building iDempiere by tycho"
From iDempiere en
m (continuing english edits) |
m (continue english edits) |
||
| Line 20: | Line 20: | ||
== Step to build and setup development environment == | == Step to build and setup development environment == | ||
# Materialize and build (this step use for headless build also use for setup development for eclipse) | # Materialize and build (this step use for headless build also use for setup development for eclipse) | ||
| − | ## | + | ## Clone source from [http://bitbucket.org/idempiere/idempiere bitbucket.org] to folder [idempiere-home] |
| − | ## | + | ## 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 |
# Setup eclipse | # Setup eclipse | ||
## Import projects | ## 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 Buckminster's. |
== Config a jenkins == | == Config a jenkins == | ||
Revision as of 08:04, 23 March 2018
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 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
- 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 Buckminster's.
- Import projects
Config a jenkins
- setup maven for jenkins
- create a maven project
- on "Source Code Management" section
- Repository URL=[[1]] (up to your actual repository)
- Revision=experimental (up to your actual repository)
- on build step, setup below value
- Root POM=pom.xml
- Goals and options=verify
Make a Osgi plugin become maven project
- create a normal plugin/feature project on eclipse
- right click to project and choose "Configure/Convert to Maven Project"
- on dialog, field "Package" type value depend on type of plug-in
- eclipse feature => "eclipse-feature"
- eclipse plugin/fragment => "eclipse-plugin"
- 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>
- add parent section
- 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
- on build.properties
- adjust output to "/target/classes"
- in case your project have source, make sure it list on "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
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/
Step to build
- 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
- Setup a jenkins job to build idempiere core.
- when success build copy artifact to /var/www/html/idempiere-core/latest
- 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') { } }
- 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
Know 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.
- some time by sourceforge, active target platform done with error, so can't build complete. check like bellow
Reference
API to configuration extra tycho plugin
Sync bundle version on manifest with version on pom.xml
Idempiere maven tycho is MANIFEST-First
A complete guild about tycho setup (Have to read)
