Home Help Center

Ice Gradle Plugin

rspurgeonrspurgeon Member Rick SpurgeonOrganization: DV TradingProject: Distributed Trading Platform
I'm attempting to use the ICE Builder for Gradle (https://github.com/zeroc-ice/ice-builder-gradle). My slice files have includes for other slice files. They are in the same directory, but I cannot figure out how to pass the include directory to the gradle plugin.


Here is my basic gradle.build
group 'co.xxx.yyy'
version '1.0-SNAPSHOT'

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
}

buildscript {
    repositories {
        maven {
            url 'https://repo.zeroc.com/nexus/content/repositories/releases'
        }
    }
    dependencies {
        classpath group: 'com.zeroc.gradle.ice-builder', name: 'slice', version: '1.0.3'
    }
}

apply plugin: "com.zeroc.gradle.ice-builder.slice"

And the error I get is:
4:10:28 PM: Executing external task 'compileSlice'...
:compileSlice
... error: Can't open include file "myslicefile.ice"
    #include <myinclude.ice>
1 error in preprocessor.

The README doc on the Ice Builder describes the "slice" and "java" blocks where to put arguments and includes, but I cannot figure out where to put this in my rudimentary gradle script.

I realize this is something that is a result of not knowing gradle, but maybe if you could put a full very simple example up on the ice-builder-gradle github that would be helpful to others. The gradle scripts that come with Ice-Demos is quite in depth and includes sub projects.

Any help very much appreciated.

Comments

  • joegeorgejoegeorge Jupiter, FloridaAdministrators, ZeroC Staff Joe GeorgeOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi rspurgeon,

    The Ice minimal demo contains a simple Gradle build system which should help you get started.

    Cheers,
    Joe
  • rspurgeonrspurgeon Member Rick SpurgeonOrganization: DV TradingProject: Distributed Trading Platform
    Thanks Joe, exactly what I needed.

    Rick
  • rspurgeonrspurgeon Member Rick SpurgeonOrganization: DV TradingProject: Distributed Trading Platform
    Are you aware of an example that shows how to properly redirect the output of the ice builder for gradle plugin? The default for the generated (and compiled output) is the target directory of the module. I find that a little strange (and so does IntelliJ IDEA I think). If the generated code is placed in the target directory then I'm struggling to figure out how to use it as a dependency in my project from IntelliJ. I'm interested in redirecting the output of the gradle plugin to a "Generated Sources Root" in IDEA, but when i set
     [COLOR=#808080]slice[/COLOR].output = file([COLOR=#6a8759]"[/COLOR]${[COLOR=#9876aa]projectDir[/COLOR]}[COLOR=#6a8759]/src/generated/java"[/COLOR])
    

    I get the following error out of the plugin
    Execution failed for task ':compileSlice'.
    > java.io.FileNotFoundException: "<path>"\build\slice2java.df.xml (The system cannot find the path specified)
    
    Any help appreciated
  • joegeorgejoegeorge Jupiter, FloridaAdministrators, ZeroC Staff Joe GeorgeOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    By default the Ice Builder for Gradle will place its output in the ${project.buildDir}/generated-src folder. Are you using Gradle to build your IDEA project?
  • rspurgeonrspurgeon Member Rick SpurgeonOrganization: DV TradingProject: Distributed Trading Platform
    Thanks George-

    Yes, I'm trying to use Gradle integration in IntelliJ IDEA. The default for the Ice Builder for Gradle is to put generated code in the output (build) directory, which I find a touch confusing. I think if the generated code would go to a source directory outside the build folders, you can use IntelliJ to mark the folder as "generated root", and then the IDE can find that code as a dependency directly in the project. Just a thought.

    But anyway, I can't figure out how to change the output behavior of the ICE gradle plugin because of that error I listed above. I appreciate you replying.

    Rick
  • joegeorgejoegeorge Jupiter, FloridaAdministrators, ZeroC Staff Joe GeorgeOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    This seems to be a bug in the builder. As a temporary workaround, can you try creating the "build" directory (${projectDir}/build) manually.

    Cheers,
    Joe
  • rspurgeonrspurgeon Member Rick SpurgeonOrganization: DV TradingProject: Distributed Trading Platform
    Joe-

    I think my issue is being lost in translation... By default, the ICE Gradle builder outputs the generated code to the build folder, and that seems to work as expected (and it will create the build folder after a clean by the way).

    What I desire is to target the output of slice2java to a different folder. Something like src\generated, then I can market that folder as a generated-root in IDEA. I can't get the Grade Plugin to target this non-default folder without an error.

    Thanks for your efforts-
    Rick
  • joegeorgejoegeorge Jupiter, FloridaAdministrators, ZeroC Staff Joe GeorgeOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Rick,

    The builder expects to store dependency data in the "build" folder, which by default is where it also stores generated java files. However, there is a bug which causes the builder to crash if the build directory does not exist and you change the output directory to not be inside the build directory.

    As a temporary fix you should be able to just manually create the "build" directory. Your generated code should then end up in the right place.

    Cheers,
    Joe
  • joegeorgejoegeorge Jupiter, FloridaAdministrators, ZeroC Staff Joe GeorgeOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi Rick,

    We've published a new version of Ice Builder for Gradle (v1.0.5) to address this issue. Please let me know if this resolves your problem.

    Cheers,
    Joe
  • rspurgeonrspurgeon Member Rick SpurgeonOrganization: DV TradingProject: Distributed Trading Platform
    Joe-

    Thanks a ton, I believe this is working properly now.

    Rick
Sign In or Register to comment.