Changeset 659


Ignore:
Timestamp:
2008-10-02 16:08:29 (5 years ago)
Author:
bruno
Message:

Introduce 'classifier' as necessary field to uniquely identify an (Maven) artifact.

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/kauri-runtime-testfw/src/main/java/org/kauriproject/runtime/testfw/AbstractRuntimeTest.java

    r641 r659  
    1313    protected ArtifactRepository dummyRepository = new ArtifactRepository() { 
    1414        public File resolve(RepoArtifactRef artifactRef) throws ArtifactNotFoundException { 
    15             return resolve(artifactRef.getGroupId(), artifactRef.getArtifactId(), artifactRef.getVersion()); 
     15            return resolve(artifactRef.getGroupId(), artifactRef.getArtifactId(), artifactRef.getClassifier(), artifactRef.getVersion()); 
    1616        } 
    1717 
    18         public File resolve(String groupId, String artifactId, String version) throws ArtifactNotFoundException { 
    19             throw new ArtifactNotFoundException(groupId, artifactId, version, Collections.<String>emptyList()); 
     18        public File resolve(String groupId, String artifactId, String classifier, String version) throws ArtifactNotFoundException { 
     19            throw new ArtifactNotFoundException(groupId, artifactId, classifier, version, Collections.<String>emptyList()); 
    2020        } 
    2121 
    22         public ResolvedArtifact tryResolve(String groupId, String artifactId, String version) throws ArtifactNotFoundException { 
     22        public ResolvedArtifact tryResolve(String groupId, String artifactId, String classifier, String version) throws ArtifactNotFoundException { 
    2323            return new ResolvedArtifact(new File("/dummy"), Collections.<String>emptyList(), false); 
    2424        } 
     
    3030    protected ArtifactRepository localRepository = 
    3131            new Maven2StyleArtifactRepository(new File(System.getProperty("localRepository"))) { 
    32                 public ResolvedArtifact tryResolve(String groupId, String artifactId, String version) throws ArtifactNotFoundException { 
     32                public ResolvedArtifact tryResolve(String groupId, String artifactId, String classifier, String version) throws ArtifactNotFoundException { 
    3333                    // If the artifact is the one of the project in which this test is running 
    3434                    // then the artifact won't be in the repository yet, so first try the target 
     
    4040                        return new ResolvedArtifact(file, Collections.singletonList(file.getAbsolutePath()), true); 
    4141                    else 
    42                         return super.tryResolve(groupId, artifactId, version); 
     42                        return super.tryResolve(groupId, artifactId, classifier, version); 
    4343                } 
    4444            }; 
  • trunk/core/kauri-runtime/src/main/java/org/kauriproject/runtime/classloading/XmlClassLoaderBuilder.java

    r318 r659  
    7070                    String groupId = DocumentHelper.getAttribute(classPathEl, "groupId", true); 
    7171                    String artifactId = DocumentHelper.getAttribute(classPathEl, "artifactId", true); 
     72                    String classifier = DocumentHelper.getAttribute(classPathEl, "classifier", false); 
    7273                    String version = DocumentHelper.getAttribute(classPathEl, "version", !groupId.startsWith("org.kauriproject")); 
    7374                    version = version == null ? KauriRuntime.getVersion() : version; 
    74                     ArtifactRef artifactRef = new RepoArtifactRef(groupId, artifactId, version); 
     75                    ArtifactRef artifactRef = new RepoArtifactRef(groupId, artifactId, classifier, version); 
    7576 
    7677                    // Check for double artifacts 
  • trunk/core/kauri-runtime/src/main/java/org/kauriproject/runtime/model/XmlKauriRuntimeConfigBuilder.java

    r553 r659  
    7373                    String groupId = DocumentHelper.getAttribute(importEl, "groupId", true); 
    7474                    String artifactId = DocumentHelper.getAttribute(importEl, "artifactId", true); 
     75                    String classifier = DocumentHelper.getAttribute(importEl, "classifier", false); 
    7576                    // Version is optional for org.kauriproject artifacts 
    7677                    String version = DocumentHelper.getAttribute(importEl, "version", !groupId.startsWith("org.kauriproject")); 
     
    8485                        sourceType = ModuleSourceType.SOURCE_DIRECTORY; 
    8586                    } else { 
    86                         fileToImport = repository.resolve(groupId, artifactId, version); 
     87                        fileToImport = repository.resolve(groupId, artifactId, classifier, version); 
    8788                        sourceType = ModuleSourceType.JAR; 
    8889                    } 
  • trunk/core/kauri-runtime/src/main/java/org/kauriproject/runtime/repository/ArtifactNotFoundException.java

    r21 r659  
    2121    private final String groupId; 
    2222    private final String artifactId; 
     23    private final String classifier; 
    2324    private final String version; 
    2425    private final List<String> searchLocations; 
    2526 
    26     public ArtifactNotFoundException(String groupId, String artifactId, String version, List<String> searchLocations) { 
     27    public ArtifactNotFoundException(String groupId, String artifactId, String classifier, String version, List<String> searchLocations) { 
    2728        this.groupId = groupId; 
    2829        this.artifactId = artifactId; 
     30        this.classifier = classifier; 
    2931        this.version = version; 
    3032        this.searchLocations = searchLocations; 
  • trunk/core/kauri-runtime/src/main/java/org/kauriproject/runtime/repository/ArtifactRepository.java

    r82 r659  
    1616package org.kauriproject.runtime.repository; 
    1717 
    18 import java.net.MalformedURLException; 
    1918import java.io.File; 
    2019 
     
    2524    File resolve(RepoArtifactRef artifactRef) throws ArtifactNotFoundException; 
    2625 
    27     File resolve(String groupId, String artifactId, String version) throws ArtifactNotFoundException; 
     26    File resolve(String groupId, String artifactId, String classifier, String version) throws ArtifactNotFoundException; 
    2827 
    29     ResolvedArtifact tryResolve(String groupId, String artifactId, String version) throws ArtifactNotFoundException; 
     28    ResolvedArtifact tryResolve(String groupId, String artifactId, String classifier, String version) throws ArtifactNotFoundException; 
    3029} 
  • trunk/core/kauri-runtime/src/main/java/org/kauriproject/runtime/repository/BaseArtifactRepository.java

    r82 r659  
    2020public abstract class BaseArtifactRepository implements ArtifactRepository { 
    2121    public File resolve(RepoArtifactRef artifactRef) throws ArtifactNotFoundException { 
    22         return resolve(artifactRef.getGroupId(), artifactRef.getArtifactId(), artifactRef.getVersion()); 
     22        return resolve(artifactRef.getGroupId(), artifactRef.getArtifactId(), artifactRef.getClassifier(), artifactRef.getVersion()); 
    2323    } 
    2424 
    25     public File resolve(String groupId, String artifactId, String version) throws ArtifactNotFoundException { 
    26         ResolvedArtifact resolvedArtifact = tryResolve(groupId, artifactId, version); 
     25    public File resolve(String groupId, String artifactId, String classifier, String version) throws ArtifactNotFoundException { 
     26        ResolvedArtifact resolvedArtifact = tryResolve(groupId, artifactId, classifier, version); 
    2727        if (!resolvedArtifact.exists()) 
    28             throw new ArtifactNotFoundException(groupId, artifactId, version, resolvedArtifact.getSearchedLocations()); 
     28            throw new ArtifactNotFoundException(groupId, artifactId, classifier, version, resolvedArtifact.getSearchedLocations()); 
    2929 
    3030        return resolvedArtifact.getFile(); 
  • trunk/core/kauri-runtime/src/main/java/org/kauriproject/runtime/repository/ChainedMaven2StyleArtifactRepository.java

    r82 r659  
    3333    } 
    3434 
    35     public ResolvedArtifact tryResolve(String groupId, String artifactId, String version) throws ArtifactNotFoundException { 
     35    public ResolvedArtifact tryResolve(String groupId, String classifier, String artifactId, String version) throws ArtifactNotFoundException { 
    3636        List<String> searchLocations = new ArrayList<String>(); 
    3737 
    3838        File file = null; 
    3939        for (ArtifactRepository repository : repositories) { 
    40             ResolvedArtifact artifact = repository.tryResolve(groupId, artifactId, version); 
     40            ResolvedArtifact artifact = repository.tryResolve(groupId, artifactId, classifier, version); 
    4141            searchLocations.addAll(artifact.getSearchedLocations()); 
    4242            if (artifact.exists()) { 
  • trunk/core/kauri-runtime/src/main/java/org/kauriproject/runtime/repository/Maven2StyleArtifactRepository.java

    r82 r659  
    1313    } 
    1414 
    15     public ResolvedArtifact tryResolve(String groupId, String artifactId, String version) throws ArtifactNotFoundException { 
     15    public ResolvedArtifact tryResolve(String groupId, String artifactId, String classifier, String version) throws ArtifactNotFoundException { 
    1616        String groupPath = groupId.replaceAll("\\.", Matcher.quoteReplacement(sep)); 
    17         File artifactFile = new File(repositoryLocation, groupPath + sep + artifactId + sep + version + sep + artifactId + "-" + version + ".jar"); 
     17        String classifierSuffix = classifier == null || classifier.length() == 0 ? "" : "-" + classifier; 
     18        File artifactFile = new File(repositoryLocation, groupPath + sep + artifactId + sep + version + sep + artifactId + "-" + version + classifierSuffix + ".jar"); 
    1819        return new ResolvedArtifact(artifactFile, Collections.singletonList(artifactFile.getAbsolutePath()), artifactFile.exists()); 
    1920    } 
  • trunk/core/kauri-runtime/src/main/java/org/kauriproject/runtime/repository/RepoArtifactRef.java

    r82 r659  
    66    private final String groupId; 
    77    private final String artifactId; 
     8    private final String classifier; 
    89 
    9     public RepoArtifactRef(String groupId, String artifactId, String version) { 
    10         super("kauri:repo:" + groupId + ":" + artifactId, version); 
     10    public RepoArtifactRef(String groupId, String artifactId, String classifier, String version) { 
     11        super("kauri:repo:" + groupId + ":" + artifactId + (classifier == null || classifier.equals("") ? "" : ":" + classifier), version); 
    1112 
    1213        if (groupId == null) 
     
    1920        this.groupId = groupId; 
    2021        this.artifactId = artifactId; 
     22        this.classifier = classifier == null ? "" : classifier; 
    2123    } 
    2224 
     
    2931    } 
    3032 
     33    public String getClassifier() { 
     34        return classifier; 
     35    } 
     36 
    3137    public File resolve(ArtifactRepository repository) throws ArtifactNotFoundException { 
    32         return repository.resolve(groupId, artifactId, getVersion()); 
     38        return repository.resolve(groupId, artifactId, classifier, getVersion()); 
    3339    } 
    3440 
    3541    public String toString() { 
    36         return groupId + ":" + artifactId + ":" + getVersion(); 
     42        return groupId + ":" + artifactId + ":" + classifier + ":" + getVersion(); 
    3743    } 
    3844 
    3945    public ArtifactRef clone(String version) { 
    40         return new RepoArtifactRef(groupId, artifactId, version); 
     46        return new RepoArtifactRef(groupId, artifactId, classifier, version); 
    4147    } 
    4248} 
  • trunk/modules/kauri-routing/kauri-routing-impl/src/test/java/org/kauriproject/routing/test/DefaultRoutingTest.java

    r252 r659  
    1414 
    1515        { 
    16             File moduleFile = localRepository.resolve("org.kauriproject", "kauri-routing-impl", projectVersion); 
     16            File moduleFile = localRepository.resolve("org.kauriproject", "kauri-routing-impl", null, projectVersion); 
    1717            ModuleDefinition module = new ModuleDefinition("routing", moduleFile, ModuleSourceType.JAR); 
    1818            config.addModule(module); 
  • trunk/modules/kauri-routing/kauri-routing-impl/src/test/java/org/kauriproject/routing/test/Routing1Test.java

    r252 r659  
    1414 
    1515        { 
    16             File moduleFile = localRepository.resolve("org.kauriproject", "kauri-routing-impl", projectVersion); 
     16            File moduleFile = localRepository.resolve("org.kauriproject", "kauri-routing-impl", null, projectVersion); 
    1717            ModuleDefinition module = new ModuleDefinition("routing", moduleFile, ModuleSourceType.JAR); 
    1818            config.addModule(module); 
  • trunk/modules/kauri-template/kauri-template-service-impl/src/test/java/org/kauriproject/template/service/test/RoutingExtensionTest.java

    r252 r659  
    1414 
    1515        { 
    16             File moduleFile = localRepository.resolve("org.kauriproject", "kauri-routing-impl", projectVersion); 
     16            File moduleFile = localRepository.resolve("org.kauriproject", "kauri-routing-impl", null, projectVersion); 
    1717            ModuleDefinition module = new ModuleDefinition("routing", moduleFile, ModuleSourceType.JAR); 
    1818            config.addModule(module); 
     
    2020 
    2121        { 
    22             File moduleFile = localRepository.resolve("org.kauriproject", "kauri-template-service-impl", projectVersion); 
     22            File moduleFile = localRepository.resolve("org.kauriproject", "kauri-template-service-impl", null, projectVersion); 
    2323            ModuleDefinition module = new ModuleDefinition("templating", moduleFile, ModuleSourceType.JAR); 
    2424            config.addModule(module); 
  • trunk/tools/kauri-genclassloader-plugin/src/main/java/org/kauriproject/tools/plugin/genclassloader/ClassloaderMojo.java

    r480 r659  
    4141 
    4242import org.apache.commons.lang.builder.HashCodeBuilder; 
     43import org.apache.commons.lang.ObjectUtils; 
    4344import org.apache.maven.artifact.Artifact; 
    4445import org.apache.maven.plugin.AbstractMojo; 
     
    322323                ch.startDocument(); 
    323324                AttributesImpl atts = new AttributesImpl(); 
    324                 ch.startElement("", "", "classloader", atts); 
    325                 ch.startElement("", "", "classpath", atts); 
     325                ch.startElement("", "classloader", "classloader", atts); 
     326                ch.startElement("", "classpath", "classpath", atts); 
    326327                SortedSet<Artifact> sortedArtifacts = new TreeSet<Artifact>(dependenciesToList); 
    327328                for (Artifact artifact : sortedArtifacts) { 
    328                     atts.addAttribute("", "", "groupId", "CDATA", artifact.getGroupId()); 
    329                     atts.addAttribute("", "", "artifactId", "CDATA", artifact.getArtifactId()); 
     329                    atts.addAttribute("", "groupId", "groupId", "CDATA", artifact.getGroupId()); 
     330                    atts.addAttribute("", "artifactId", "artifactId", "CDATA", artifact.getArtifactId()); 
     331                    if (artifact.getClassifier() != null) 
     332                        atts.addAttribute("", "classifier", "classifier", "CDATA", artifact.getClassifier()); 
    330333                    if (!artifact.getGroupId().startsWith("org.kauriproject")) 
    331                         atts.addAttribute("", "", "version", "CDATA", artifact.getVersion()); 
     334                        atts.addAttribute("", "version", "version", "CDATA", artifact.getVersion()); 
    332335                    // atts.addAttribute("", "", "share", "CDATA", SHARE_DEFAULT); 
    333                     ch.startElement("", "", "artifact", atts); 
    334                     ch.endElement("", "", "artifact"); 
     336                    ch.startElement("", "artifact", "artifact", atts); 
     337                    ch.endElement("", "artifact", "artifact"); 
    335338                    atts.clear(); 
    336339                } 
    337                 ch.endElement("", "", "classpath"); 
    338                 ch.endElement("", "", "classloader"); 
     340                ch.endElement("", "classpath", "classpath"); 
     341                ch.endElement("", "classloader", "classloader"); 
    339342                ch.endDocument(); 
    340343                fos.close(); 
     
    374377            Entry entry; 
    375378            String groupId; 
     379            String classifier; 
    376380            String artifactId; 
    377381            String version; 
     
    382386                groupId = extractAttVal(map, "groupId"); 
    383387                artifactId = extractAttVal(map, "artifactId"); 
     388                classifier = extractAttVal(map, "classifier"); 
    384389                version = extractAttVal(map, "version"); 
    385                 entry = new Entry(groupId, artifactId, version); 
     390                entry = new Entry(groupId, artifactId, classifier, version); 
    386391                entryMap.put(entry, domArtifact); 
    387392            } 
     
    389394            // now add missing dependencies 
    390395            for (Artifact artifact : dependenciesToList) { 
    391                 entry = new Entry(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()); 
     396                entry = new Entry(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getVersion()); 
    392397                if (entryMap.containsKey(entry)) { 
    393398                    // complete existing entry 
     
    451456        protected String groupId; 
    452457        protected String artifactId; 
     458        protected String classifier; 
    453459        protected String version; 
    454460 
    455         public Entry(String groupId, String artifactId, String version) { 
     461        public Entry(String groupId, String artifactId, String classifier, String version) { 
    456462            this.groupId = groupId; 
    457463            this.artifactId = artifactId; 
     464            this.classifier = classifier; 
    458465            this.version = version; 
    459466        } 
     
    463470            art.setAttribute("groupId", groupId); 
    464471            art.setAttribute("artifactId", artifactId); 
     472            if (classifier != null) 
     473                art.setAttribute("classifier", classifier); 
    465474            art.setAttribute("version", version); 
    466475            return art; 
     
    476485        public int hashCode() { 
    477486            return new HashCodeBuilder(715542779, 122039963).append(this.groupId).append(this.artifactId) 
    478                     .toHashCode(); 
     487                    .append(this.classifier).toHashCode(); 
    479488        } 
    480489 
     
    492501            } else if (!this.artifactId.equals(rhs.artifactId)) { 
    493502                equal = false; 
     503            } else if (!ObjectUtils.equals(this.classifier, rhs.classifier)) { 
     504                equal = false; 
    494505            } 
    495506 
     
    499510        @Override 
    500511        public String toString() { 
    501             return "artifact(" + groupId + "," + artifactId + "," + version + ")"; 
     512            return "artifact(" + groupId + "," + artifactId + "," + classifier + "," + version + ")"; 
    502513        } 
    503514 
Note: See TracChangeset for help on using the changeset viewer.