Compile CORBA IDL to Java


(Mark Himsley) #1

To compile CORBA IDL to Java:

  • For Ant I used the java task to fork org.jacorb.idl.parser with parameters.
  • For Maven I used idlj-maven-plugin.

Can anyone suggest anything better than mimicking the Ant method when I port the build into Gradle?


(uklance) #2

You could write a gradle task which invokes the ant task under the hood. I’ve seen many gradle integrations done this way

Be sure to correctly configure task inputs/outputs to benefit from up-to-date checking


(Mark Himsley) #3

In the end I dynamically created tasks based on JavaExec to run the JacORB IDL Parser. Dynamic tasks because I wanted to ‘pass in’ parameters for the files to compile and the i2j package mappings. I’m not checking inputs/outputs though, so thanks for reminding me of that.

tasks.create(taskName, JavaExec) {
        main = 'org.jacorb.idl.parser'
        classpath = classPath
        args = [
            '-i2jpackagefile', "${filePath}/jacorb.i2jpackage",
            '-d', 'build/generated-sources/jacorbIDL',
            '-all', '-forceOverwrite',
            fileName]
    }

(uklance) #4

As I said, you should configure the task inputs/outputs to benefit from up-to-date checking. I’m not familiar with JacORB but guessing it’s something like

tasks.create(taskName, JavaExec) {
    inputs.file "${filePath}/jacorb.i2jpackage"
    inputs.file fileName
    outputs.dir 'build/generated-sources/jacorbIDL'
    // rest of the config here
}

(Fernando Marino`) #5

Hi there,
sorry to intrude. I’m new to gradle and I need to do the same. Can you please add more details?

My gradle.build is the following:

description = 'UMARF POF Generated CORBA Interfaces'
dependencies {
compile group: 'org.jacorb', name: 'jacorb-omgapi', version: '3.6.1'
}

apply plugin: 'java'

tasks.create("buildCorba", JavaExec) {
main = 'org.jacorb.idl.parser'
classpath = classPath
dependencies {
    compile 'org.jacorb:jacorb-idl-compiler:3.6.1'
}

args = [
        "-i2jpackage", "UMARFPFDModule:org.eumetsat.pof.corba.pfd",
        "-i2jpackage", "UMARFPFDMMIModule:org.eumetsat.pof.corba.pfd.mmi",
        "PDF.idl"]
}

Running anyway gives me this error:
Error: Could not find or load main class org.jacorb.idl.parser

I suppose I shall add jacorb dependency but I can’t understand how.

Thank you for your help.

Fernando


(uklance) #6

I think you’ll want a “corba” configuration to build up the classpath. eg

confgurations {
   corba
}
dependencies {
   corba 'org.jacorb:jacorb-idl-compiler:3.6.1'
   corba 'org.jacorb:jacorb-omgapi:3.6.1'
}
task buildCorba(type: JavaExec) {
   main = 'org.jacorb.idl.parser'
   classpath = configurations.corba
   args = [
        "-i2jpackage", "UMARFPFDModule:org.eumetsat.pof.corba.pfd",
        "-i2jpackage", "UMARFPFDMMIModule:org.eumetsat.pof.corba.pfd.mmi",
        "PDF.idl"
   ]   
}