From b996ac73fccb4e9cdb6d47af30d68b10315bc0f0 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Mon, 10 Aug 2015 06:06:57 -0700 Subject: [PATCH] Properly support gems which have a specific platform associated with them e.g. thread_safe --- .../groovy/com/github/jrubygradle/groovygem/Gem.groovy | 3 ++- .../jrubygradle/groovygem/internal/GemInstaller.groovy | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/com/github/jrubygradle/groovygem/Gem.groovy b/src/main/groovy/com/github/jrubygradle/groovygem/Gem.groovy index a781602..d83fe01 100644 --- a/src/main/groovy/com/github/jrubygradle/groovygem/Gem.groovy +++ b/src/main/groovy/com/github/jrubygradle/groovygem/Gem.groovy @@ -100,7 +100,8 @@ Gem::Specification.new do |s| s.description = ${JsonOutput.toJson(description)} s.homepage = "${homepage}" s.authors = ${JsonOutput.toJson(authors)} - s.email = "${email}" + s.email = ${JsonOutput.toJson(email)} + s.platform = "${platform}" s.require_paths = ${JsonOutput.toJson(requirePaths)} s.executables = ${JsonOutput.toJson(executables)} diff --git a/src/main/groovy/com/github/jrubygradle/groovygem/internal/GemInstaller.groovy b/src/main/groovy/com/github/jrubygradle/groovygem/internal/GemInstaller.groovy index fe05534..b25b720 100644 --- a/src/main/groovy/com/github/jrubygradle/groovygem/internal/GemInstaller.groovy +++ b/src/main/groovy/com/github/jrubygradle/groovygem/internal/GemInstaller.groovy @@ -145,7 +145,11 @@ class GemInstaller { /** Extract the gemspec file from the {@code Gem} provided into the ${installDir}/specifications */ protected void extractSpecification(File installDir, Gem gem) { - String outputFileName = "${gem.name}-${gem.version.version}.gemspec" + String fileName = "${gem.name}-${gem.version.version}" + if (gem.platform != 'ruby') { + fileName = "${fileName}-${gem.platform}" + } + String outputFileName = "${fileName}.gemspec" FileObject outputFile = fileSystemManager.resolveFile(new File(installDir, 'specifications'), outputFileName) PrintWriter writer = new PrintWriter(outputFile.content.outputStream) @@ -156,6 +160,9 @@ class GemInstaller { protected void extractData(File installDir, FileObject dataTarGz, Gem gem) { String dir = "${gem.name}-${gem.version.version}" + if (gem.platform != 'ruby') { + dir = "${dir}-${gem.platform}" + } logger.info("Extracting into ${installDir} from ${gem.name}") FileObject outputDir = fileSystemManager.resolveFile(new File(installDir, 'gems'), dir) outputDir.copyFrom(dataTarGz, new AllFileSelector())