Building iDempiere by tycho
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" and "Maven Tycho Utilities"
note:while server of "Tycho Build Tools" is down, you can install it from link
https://raw.githubusercontent.com/idempiere/binary.file/master/p2-third-party/tycho-build-tools
Install m2e Connector
- Go to Window/Preferences
- Menu Maven/Discovery
- Click Open Catalog
- On Find field, enter Tycho
- Select Tycho Configurator, click Finish to install it
- Restart Eclipse and use the same dialog to install m2e connector for maven-dependency-plugin
Note: Use Help > About Eclipse IDE > Installation Details > Installed Software to find out the list of m2e Connector and Tycho plugins that you have installed.
Steps to build and setup development environment
- Materialize and build (this step is needed for both headless build and setup of Eclipse)
- Clone source from bitbucket.org to a folder [idempiere-home]
- Open terminal, cd to [idempiere-home] and execute command "mvn verify" (in case you focus to setup eclipse, don't want to build product, use "mvn validate")
- Downloads all libraries on Bundle-ClassPath
- Build all projects and output binary to [idempiere-home]/org.idempiere.p2/target/products
- Setup Eclipse Workspace
- Import Projects
- Open Eclipse with Workspace at [idempiere-home]
- From Eclipse Menu, choose File/Import
- At Import dialog, choose Maven/Existing Maven Projects
- Click Next button and Browse to [idempiere-home]
- Select all projects, click Finish to complete the import
- All projects are loaded to workspace
- Set Target Platform
- From Eclipse Menu, choose File/Import
- At Import dialog, choose General/Existing Projects into Workspace
- Click Next button and Browse to [idempiere-home]/org.idempiere.p2.targetplatform. Click Finish to complete the import
- Open the org.idempiere.p2.targetplatform/org.idempiere.p2.targetplatform.target file. This is the default target platform definition with remote url
- At Target Editor, click the "Set as Active Target Platform" link
- Wait for Eclipse to download bundles onto target platform. Click the "Reload Target Platform" link if some download fail
- Say good bye to Buckminster
- Import Projects
- Know issue
- in case you do step "Import Projects" before "mvn validate" eclipse will auto change some classpath, so you you will build fail ever you run "mvn validate". Need to revert change of eclipse before you run "mvn validate"
Hengsin (talk) 05:54, 20 October 2018 (UTC), org.idempiere.p2.targetplatform/org.idempiere.p2.targetplatform.target is slow and error prone for me. I'm not sure that's the intended alternative but idempiere/org.idempiere.p2/target/repository works fine for me as Target Platform (add new empty target platform and add the idempiere/org.idempiere.p2/target/repository folder/directory to it) and without all the hassle with org.idempiere.p2.targetplatform/org.idempiere.p2.targetplatform.target
Config For Jenkins
- Setup Maven for Jenkins
- Create a Maven Project
- In "Source Code Management" Section
- Repository URL=ssh://hg@bitbucket.org/idempiere/idempiere-experimental (or the url of your target repository)
- Revision=experimental (or the revision of your target 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 on project and choose "Configure/Convert to Maven Project"
- At dialog, value of "Package" type field 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>
- Open MANIFEST.MF and continue checking..
- At Runtime tab, section classpath has item "." if not, you should create one
- In 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 that contains idempiere core plus dependency at idempiere/org.idempiere.p2/target/repository
- Host this repository with a web server. If you don't have one, you can use jetty-maven-plugin to host it
- Create a maven tycho target plugin point to the p2 repository server setup at step 2
- Build extra plugin by using 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 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 to feed all dependency bundle)
Summary about tycho use on idempiere (for full reference tycho API)
[idempiere-root]/pom.xml
setup list of module (bundle) that build with command "mvn verify -P online"
[idempiere-root]/org.idempiere.parent/pom.xml
- parent pom with common configuration, for other bundle to inherit from this pom
- profiles
- Set properties for build condition, currently use to setup online and offline repository
- repositories
- Setup list of repository to resolve dependency
- with P2 repository use "<layout>p2</layout>"
- dependencies
- define OSGi bundles feed from maven repositories
Known Issue
- Before the completion of step 2.2 (Set Target Platform), you should turn off "Project/Build Automatically". Before the setting of Active Target Platform, build will be slow and full with errors.
- Sometimes due to condition in Sourceforge, the setting of 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)
Explain about root-ui for feature
