Skip to content

Best Practices #15

@lfeagan

Description

@lfeagan

Hi,

I am a recent convert from edu.sc.seis.version-class to your simple, yet nicely configurable, versioning plugin. I think for new users, an example of using variables might get them closer to the right solution for their needs. In my case, I created a simple gradle file to apply elsewhere with some sensible, imho, defaults:

  1. the gversion srcDir is in the build folder, specifically: "build/generated-src/version/java"
  2. the sourceSet for main is updated to add this directory
  3. the classPackage is programmatically defined as: project.group + "." + project.name.replace('-','.')
  4. A compileJava task dependsOn for createVersionFile is added.
apply plugin: "com.peterabeles.gversion"

// configure build version output
gversion {
    srcDir = "build/generated-src/version/java"
    classPackage = project.group + "." + project.name.replace('-','.')
    className = "BuildVersion"
}

// Add generated-src/version folder to main source set
sourceSets {
    main {
        java {
            srcDir layout.buildDirectory.get().getAsFile().toString() + "/generated-src/version/java"
        }
    }
}

// add dependency to ensure correct ordering
tasks.named('compileJava') {
    dependsOn(createVersionFile)
}

If you think this would be useful, happy to write it up as a markdown and submit a PR. Otherwise, feel free to ignore. I appreciate the nice plugin.

Thanks Again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions