From 963ed7c59ef16e5190be6e9e2ba9843dd4d36170 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Fri, 21 Aug 2015 17:53:07 -0700 Subject: [PATCH] Avoid caching gem files unnecessarily Fixes #5 --- .../jrubygradle/jem/internal/GemInstaller.java | 16 +--------------- .../jem/internal/GemInstallerSpec.groovy | 5 +---- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/github/jrubygradle/jem/internal/GemInstaller.java b/src/main/java/com/github/jrubygradle/jem/internal/GemInstaller.java index df464c6..df9cb12 100644 --- a/src/main/java/com/github/jrubygradle/jem/internal/GemInstaller.java +++ b/src/main/java/com/github/jrubygradle/jem/internal/GemInstaller.java @@ -23,7 +23,7 @@ import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; public class GemInstaller { - public static final String[] GEM_HOME_DIRS = {"bin", "build_info", "cache", "doc", + public static final String[] GEM_HOME_DIRS = {"bin", "build_info", "doc", "extensions", "gems", "specifications"}; protected Logger logger = LoggerFactory.getLogger(GemInstaller.class); @@ -52,14 +52,6 @@ public class GemInstaller { public Gem installGem(File installDir, File gem, DuplicateBehavior onDuplicate) { /* TODO: isValidGem? */ - try { - cacheGemInInstallDir(installDir, gem); - } - catch (IOException ex) { - logger.error("Failed to cache our gem in %s", installDir, ex); - return null; - } - Gem gemMetadata; GenericArchive gemArchive = ShrinkWrap.create(TarImporter.class) .importFrom(gem).as(GenericArchive.class); @@ -155,12 +147,6 @@ public class GemInstaller { return fullName; } - /** Cache the gem in GEM_HOME/cache */ - protected void cacheGemInInstallDir(File installDir, File gem) throws IOException { - File cacheDir = new File(installDir, "cache"); - Files.copy(gem.toPath(), (new File(cacheDir, gem.getName())).toPath()); - } - /** Extract the gemspec file from the {@code Gem} provided into the ${installDir}/specifications */ protected void extractSpecification(File installDir, Gem gem) throws Exception { String outputFileName = String.format("%s.gemspec", gemFullName(gem)); diff --git a/src/test/groovy/com/github/jrubygradle/jem/internal/GemInstallerSpec.groovy b/src/test/groovy/com/github/jrubygradle/jem/internal/GemInstallerSpec.groovy index b2ea2d2..23512bb 100644 --- a/src/test/groovy/com/github/jrubygradle/jem/internal/GemInstallerSpec.groovy +++ b/src/test/groovy/com/github/jrubygradle/jem/internal/GemInstallerSpec.groovy @@ -121,10 +121,7 @@ class GemInstallerIntegrationSpec extends Specification { when: installer.install() - then: "the gem should be cached in ${installDir}/cache" - (new File(installDir, ['cache', GemInstallerSpec.GEM_FILENAME].join(File.separator))).exists() - - and: "the ${installDir}/specifications dir should contain the gemspec" + then: "the ${installDir}/specifications dir should contain the gemspec" File specification = new File(installDir, ['specifications', "${GemInstallerSpec.GEM_NAME}.gemspec"].join(File.separator)) specification.isFile() specification.size() > 0