App Connect

 View Only
  • 1.  Compiling Java projects from the ACE container image

    Posted Fri October 29, 2021 06:52 AM
    Hi,

    We are creating a CI/CD pipeline (CP4I and OpenShift Pipelines). In the pipeline we have a "build" step which builds a BAR file from source code. Some of our applications use Java functionality, and the Java projects need to be compiled before they are added to the BAR file.

    When developing locally, this can be done from the ACE toolkit or with the mqsicreatebar command. However, these options are not available in the default ACE docker image (which we use in our pipeline).

    One option is to compile the Java projects from the toolkit and add the JAR to the repository which the BAR is built from, but then we are kind of straying away from the whole "build from source code" idea.

    Another option is to compile with javac and jar commands from the pipeline.

    Any tips or best practices for how to handle this?

    ------------------------------
    Andreas Bradahl
    ------------------------------


  • 2.  RE: Compiling Java projects from the ACE container image

    Posted Fri October 29, 2021 09:48 AM
    This is a common issue in pipelines these days, and you're absolutely right that simply putting JAR files into the repo isn't the best way forward. There are a few solutions to this, and some examples online for some of the techniques (some of which may depend on using ACE v12).

    One solution that fits quite well into the open-source Java world is to switch the ACE Java projects to use Maven, and then use Maven to build the projects in the pipeline. The Eclipse Maven integration is quite good, so the toolkit builds would pick up any options provided to Maven in the pom.xml files, pull in dependencies, etc, so the developers can be reasonably sure their local builds match the pipeline builds. Maven can also be used to run the ACE commands to build applications, populate work directories, etc. https://github.com/ot4i/ace-demo-pipeline shows this approach (amongst other thing), showing an application with Java projects, Maven builds, Tekton pipelines, GitHub Actions, etc, and also includes unit testing as part of the pipeline (v12 only).

    Another solution for v12 is to use the "ibmint" command to build and package the applications: ibmint will compile Java projects and is intended to provide a non-toolkit way to build everything mqsicreatebar can build. ibmint can be run from pretty much any build system, and a Gradle example is shown at https://github.com/ot4i/ace-demo-pipeline/blob/master/build.gradle with projects being built and unit-tested. This is in addition to the Maven build setup in the same repo, and is there to show an alternative approach.

    As you say, you could also run javac and jar from a script and build that way, but tools like Maven and Gradle are often preferable as they are built for that purpose. Mixing and matching, with Maven/Gradle/Ant building the Java libraries and mqsipackagebar building the applications and packaging them, is another similar way to go.

    It's also possible (though not ideal) to run mqsicreatebar in a container, and build that way. See https://github.com/tdolby-at-uk-ibm-com/ace-docker/tree/master/experimental/ace-full for a container that will allow this, but be aware it will be quite large!

    Hope this helps - more info available if needed.


  • 3.  RE: Compiling Java projects from the ACE container image

    Posted Mon November 01, 2021 04:16 AM

    Thank you very much for your informative answer. Will try out the Maven approach.

    We're still running v11.0.0.10 at the moment, with a plan to upgrade to v12 sometime in 2022. By the way, how is the compatibility between ACE v11 applications and the build tools in ACE v12 - will we still be able to build our "old" v11 applications when using the v12 Docker image? Or will we have to do some migration work for them to work?



    ------------------------------
    Andreas Bradahl
    ------------------------------



  • 4.  RE: Compiling Java projects from the ACE container image

    Posted Mon November 01, 2021 05:12 AM
    Compatibility is really good in that direction, so you should be fine building ACE v11 applications with ACE v12 tools. Going the other way isn't as good, as any v12 content in any of the projects could cause the v11 tools to fail.

    The demo pipeline referred to above actually started out as a v11 application (see the older branches such as https://github.com/ot4i/ace-demo-pipeline/tree/demo-pipeline-21-02 ) and moving the pipeline to v12 didn't cause any issues. In fact, v12 brought significant benefits such as the ability to easily run unit tests in the pipeline, which is much faster and nicer than the v11 approach used in the earlier branches. Unit tests can be added to pre-existing projects, too, so older applications can be enabled in the same way as new ones.



  • 5.  RE: Compiling Java projects from the ACE container image

    Posted Mon November 01, 2021 08:33 AM
    Sounds awesome. Looking forward to upgrading to v12 and exploring the unit test functionality then, as we are actually in the process of leveling up our test regime at the moment.

    ------------------------------
    Andreas Bradahl
    ------------------------------



  • 6.  RE: Compiling Java projects from the ACE container image

    Posted Tue October 10, 2023 10:03 PM
    Edited by madhu ram Tue October 10, 2023 10:03 PM

    Hello Trevor,

    i am trying to build a bar file in build.gradle.i have  a seperate task as below in gradle.build

    task createBar(type: Exec) {
         commandLine baseFilePath + '/'+'server' +'/'+ 'bin/ibmint', 'package', '--input-path', './', '--output-bar-file', '/build/libs/test.bar', '--project', 'common-app' }

    i have the  the basefilepath set to def baseFilePath='C:/Program Files/IBM/ACE/12.0.5.0' in my local...

    the task execution shows error.

    Process 'command 'C:/Program Files/IBM/ACE/12.0.5.0/server/bin/ibmint'' finished with non-zero exit value -1

    could you please help

    Regards

    Madhu



    ------------------------------
    madhu ram
    ------------------------------



  • 7.  RE: Compiling Java projects from the ACE container image

    Posted Thu October 12, 2023 11:12 PM

     Hello Madhu,

     It's a little hard to be sure what's happening, but a couple of things might be causing some issues:

    1. It looks like you're running on Windows, and using the forward slash character for paths; I set fileSep to be System.getProperty("file.separator") in the ACE demo pipeline build.gradle as a good practice, even though I haven't run it on Windows recently.
    2. Depending on how Gradle executes commands, the space in C:/Program Files/ might be causing problems. It might be possible to use quotes around the command path, or else to use C:\PROGRA~1\ instead to avoid the space entirely.
    3. I would expect baseFilePath to be set from the env var MQSI_BASE_FILEPATH rather than specified as a fixed string. Gradle will almost certainly need to be run from an ACE console to make sure other env vars are set, too.

    It definitely doesn't look like ibmint is failing, as there don't seem to be any error messages to indicate issues with ibmint itself, so this is probably down to issues finding the command.

    Hope this makes sense!

    -- Trevor D.



    ------------------------------
    Trevor Dolby
    IBM Expert Labs
    ------------------------------



  • 8.  RE: Compiling Java projects from the ACE container image

    Posted Mon October 16, 2023 11:31 AM

    Hello Trevor,

    Thanks for your reply.I  created a seperate .cmd file with the command
    cd C:/Program Files/IBM/ACE/12.0.5.0/ & ACE.cmd & ibmint package  --input-path (the project path) --output-bar-file (path for bar file) --project (the project name) and using the commandLine in gradle.build it was able to package in  windows environment

    Right now  my library is present in the git repo as a gradle project.I tried issuing the command ibmint package as per  the  build.gradle file in the ace demo pipeline.I get the below error while, creating the bar

     commandLine baseFilePath + fileSep + 'server' + fileSep + 'bin/ibmint', 'package', '--input-path', "$projectDir",'--output-bar-file','xxx/sample.bar','--do-not-compile-java' ,'--project','yyy'
    BIP2113E: IBM App Connect Enterprise internal error: diagnostic information 'Invalid project descriptor', '18', 'filteredResources'

    Note:projectDir here refers to the XXX /lib directory.

    I tried with different combination but did not work.Please help.



    ------------------------------
    madhu ram
    ------------------------------