Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide Gradle plugin #132

Open
jacek99 opened this issue Nov 8, 2013 · 12 comments
Open

Provide Gradle plugin #132

jacek99 opened this issue Nov 8, 2013 · 12 comments
Milestone

Comments

@jacek99
Copy link

jacek99 commented Nov 8, 2013

Most of our dev teams have left Maven behind and moved on to Gradle.

Would it be possible to provide a native Gradle plugin?

Thank you

@ebourg
Copy link
Collaborator

ebourg commented Nov 8, 2013

Hi Jacek, did you consider using the jdeb Ant task with Gradle? It should integrate nicely.

http://www.gradle.org/docs/current/userguide/ant.html

@mgarmash
Copy link

I have some working code for jdeb and Gradle integration, but now it's just a few tasks using jdeb-ant. I plan to rewrite it and release as gradle plugin.

@tcurdt tcurdt added this to the 2.0 milestone Feb 26, 2014
@tbroyer
Copy link

tbroyer commented Apr 28, 2014

👍

@bedge
Copy link

bedge commented Jun 19, 2014

Ditto on the up-vote.

@rspieldenner
Copy link
Contributor

We wrote one over at nebula-plugins on github https://github.com/nebula-plugins/gradle-ospackage-plugin

@bedge
Copy link

bedge commented May 29, 2015

@rspieldenner - gradle-ospackage-plugin is friggin cool. Worked right out of the proverbial box.

@tbroyer
Copy link

tbroyer commented Jun 12, 2015

gradle-ospackage-plugin has a few show-stopper limitations, so I used the JDeb API right from my Gradle build file:

  def resolver = new MapVariableResolver([
      name:        ext.packageName.toString(),
      version:     ext.getVersion().toString(),
      description: '',
      homeDir:     ext.homeDir.toString(),
      userName:    ext.userName.toString(),
      groupName:   ext.groupName.toString(),
  ])
  def dataProducers = [
      new DataProducerFiles(configurations.distLib.asList() as String[], "${ext.homeDir}/lib", [
          new PermMapper(-1, -1, userName, groupName, -1, -1, 0, null)
      ] as Mapper[]),
      new DataProducerFile(file('src/main/resources/bin/launcher.sh'), "${ext.homeDir}/bin/${ext.packageName}", null, null, [
          new PermMapper(-1, -1, userName, groupName, 0775, -1, 0, null)
      ] as Mapper[]),
      new DataProducerFile(file("$buildDir/tmp/init.d/service.sh"), "/etc/init.d/${ext.packageName}", null, null, [
          new PermMapper(-1, -1, userName, groupName, 0755, -1, 0, null)
      ] as Mapper[]),
      new DataProducerPathTemplate(["/var/log/${ext.packageName}"] as String[], null, null, [
          new PermMapper(-1, -1, userName, groupName, -1, -1, 0, null)
      ] as Mapper[]),
  ]
  def conffileProducers = [
      new DataProducerDirectory(file("$buildDir/tmp/etc/"), null, null, [
          new PermMapper(-1, -1, userName, groupName, -1, -1, 0, "/etc/${ext.packageName}")
      ] as Mapper[]),
  ]

  DebMaker maker = new DebMaker(new LoggerConsole(logger), dataProducers + conffileProducers, conffileProducers)

  maker.deb = file("${buildDir}/distributions/${ext.packageName}.deb")
  maker.control = file("${projectDir}/src/deb/control/")
  maker.resolver = resolver

  maker.validate()
  maker.makeDeb()

I had to make a LoggerConsole class for that to work:

class LoggerConsole implements Console {

  private logger

  LoggerConsole(logger) {
    this.logger = logger
  }

  @Override
  void debug(String message) {
    logger.debug(message)
  }

  @Override
  void info(String message) {
    logger.info(message)
  }

  @Override
  void warn(String message) {
    logger.warn(message)
  }
}

FWIW, I also created a DataProducerFilteredFile that copies a file (like DataProducerFile) while resolving variables (with Utils.resolveVariables()); so I don't actually use the $buildDir/tmp like shown above.

A few of those things are internal classes so it could break when I update JDeb.

The alternative was using the Ant task from Gradle, which I did in another project but it doesn't support "path templates" like in Maven (same project, before we moved to Gradle) so I had to hack something using a temporary folder, and do the filtering using a Gradle Copy/Sync task as an intermediate step. I find my "direct" approach above "cleaner".

One thing that really bothers me though: JDeb is only one JAR with dependencies on both Ant (needed anyway for various things) and Maven. It'd be so much cleaner if there was a "core" API separated from the build-tool integrations.

@rspieldenner
Copy link
Contributor

Could you add the showstoppers as issues so we can address them on gradle-ospackage?

Sent from my iPhone

On Jun 12, 2015, at 9:18 AM, Thomas Broyer notifications@github.com wrote:

gradle-ospackage-plugin has a few show-stopper limitations, so I used the JDeb API right form my Gradle build file:

def resolver = new MapVariableResolver([
name: ext.packageName.toString(),
version: ext.getVersion().toString(),
description: '',
homeDir: ext.homeDir.toString(),
userName: ext.userName.toString(),
groupName: ext.groupName.toString(),
])
def dataProducers = [
new DataProducerFiles(configurations.distLib.asList() as String[], "${ext.homeDir}/lib", [
new PermMapper(-1, -1, userName, groupName, -1, -1, 0, null)
] as Mapper[]),
new DataProducerFile(file('src/main/resources/bin/launcher.sh'), "${ext.homeDir}/bin/${ext.packageName}", null, null, [
new PermMapper(-1, -1, userName, groupName, 0775, -1, 0, null)
] as Mapper[]),
new DataProducerFilteredFile(file("$buildDir/tmp/init.d/service.sh"), "/etc/init.d/${ext.packageName}", null, null, [
new PermMapper(-1, -1, userName, groupName, 0755, -1, 0, null)
] as Mapper[]),
new DataProducerPathTemplate(["/var/log/${ext.packageName}"] as String[], null, null, [
new PermMapper(-1, -1, userName, groupName, -1, -1, 0, null)
] as Mapper[]),
]
def conffileProducers = [
new DataProducerDirectory(file("$buildDir/tmp/etc/"), null, null, [
new PermMapper(-1, -1, userName, groupName, -1, -1, 0, "/etc/${ext.packageName}")
] as Mapper[]),
]

DebMaker maker = new DebMaker(new LoggerConsole(logger), dataProducers + conffileProducers, conffileProducers)

maker.deb = file("${buildDir}/distributions/${ext.packageName}.deb")
maker.control = file("${projectDir}/src/deb/control/")
maker.resolver = resolver

maker.validate()
maker.makeDeb()
I had to make a LoggerConsole class for that to work:

class LoggerConsole implements Console {

private logger

LoggerConsole(logger) {
this.logger = logger
}

@OverRide
void debug(String message) {
logger.debug(message)
}

@OverRide
void info(String message) {
logger.info(message)
}

@OverRide
void warn(String message) {
logger.warn(message)
}
}
FWIW, I also created a DataProducerFilteredFile that copies a file (like DataProducerFile) while resolving variables (with Utils.resolveVariables()); so I don't actually use the $buildDir/tmp like shown above.

A few of those things are internal classes so it could break when I update JDeb.

The alternative was using the Ant task from Gradle, which I did in another project but it doesn't support "path templates" like in Maven (same project, before we moved to Gradle) so I had to hack something using a temporary folder, and do the filtering using a Gradle Copy/Sync task as an intermediate step. I find my "direct" approach above "cleaner".

One thing that really bothers me though: JDeb is only one JAR with dependencies on both Ant (needed anyway for various things) and Maven. It'd be so much cleaner if there was a "core" API separated from the build-tool integrations.


Reply to this email directly or view it on GitHub.

@tbroyer
Copy link

tbroyer commented Jun 15, 2015

Could you add the showstoppers as issues so we can address them on gradle-ospackage?

Done: nebula-plugins/gradle-ospackage-plugin#84, nebula-plugins/gradle-ospackage-plugin#114 and nebula-plugins/gradle-ospackage-plugin#115 (to be fair, only # 114 was a real showstopper actually)

@tcurdt
Copy link
Owner

tcurdt commented Jan 23, 2016

also see #228

@gesellix
Copy link
Contributor

Have you seen this: https://github.com/gesellix/gradle-debian-plugin as alternative to the nebula plugins?

Disclaimer: I'm the owner/maintainer of that plugin, but didn't invest much time recently in giving it some love.

I won't be able to tell you about pros and cons, because I didn't compare them, yet. Only one thing to note: "My" plugin acts as wrapper to JDeb, so that it's less opinionated. For some folks this might be good, others consider it to be bad ;-)

@tcurdt
Copy link
Owner

tcurdt commented Jan 23, 2016

@gesellix if you have some minutes to spare I would appreciate contributions/feedback for #228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants