Skip to content

Commit

Permalink
GRIFFON-459 Delete all previous versions of a plugin when installing …
Browse files Browse the repository at this point in the history
…a new one
  • Loading branch information
aalmiray committed Feb 18, 2012
1 parent be1be6c commit 60e16db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ class ArtifactInstallEngine {

eventHandler 'StatusUpdate', "Software license of ${releaseName} is '${release.artifact.license}'"

for (dir in findAllArtifactDirsForName(type, releaseName)) {
for (dir in findAllArtifactDirsForName(type, artifactName)) {
ant.delete(dir: dir, failonerror: false)
}
ant.mkdir(dir: artifactInstallPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import java.util.regex.Matcher
import java.util.regex.Pattern
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.core.io.FileSystemResource
import org.springframework.core.io.Resource
import org.springframework.core.io.support.PathMatchingResourcePatternResolver
Expand All @@ -39,6 +41,7 @@ import org.codehaus.griffon.artifacts.model.*
* @since 0.9.5
*/
class ArtifactUtils {
private static final Logger LOG = LoggerFactory.getLogger(ArtifactUtils)
static final String PLUGIN_DESCRIPTOR_SUFFIX = 'GriffonPlugin.groovy'
static final String ARCHETYPE_DESCRIPTOR_SUFFIX = 'GriffonArchetype.groovy'
static final String ADDON_DESCRIPTOR_SUFFIX = 'GriffonAddon.groovy'
Expand Down Expand Up @@ -152,9 +155,10 @@ class ArtifactUtils {
}

static File findArtifactDirForName(String type, String name) {
// name = getHyphenatedName(name)
String basedir = artifactBase(type)
Resource[] resources = resolveResources("file://${basedir}/${name}-*")
if (LOG.debugEnabled) {
LOG.debug("Searching dir matching file://${artifactBase(type)}/${name}-*")
}
Resource[] resources = resolveResources("file://${artifactBase(type)}/${name}-*")
for (resource in resources) {
Matcher matcher = ARTIFACT_NAME_VERSION_PATTERN.matcher(resource.file.name)
if (matcher[0][1] == name) return resource.file
Expand All @@ -163,9 +167,10 @@ class ArtifactUtils {
}

static File[] findAllArtifactDirsForName(String type, String name) {
// name = getHyphenatedName(name)
String basedir = artifactBase(type)
Resource[] resources = resolveResources("file://${basedir}/${name}-*")
if (LOG.debugEnabled) {
LOG.debug("Searching all dirs matching file://${artifactBase(type)}/${name}-*")
}
Resource[] resources = resolveResources("file://${artifactBase(type)}/${name}-*")
if (resources) {
List<File> files = []
for (resource in resources) {
Expand All @@ -175,7 +180,6 @@ class ArtifactUtils {
return files as File[]
}
return new File[0]

}

static Resource[] findAllArtifactDirsForType(String type) {
Expand Down

0 comments on commit 60e16db

Please sign in to comment.