Source Code Cross Referenced for DefaultPluginMappingManager.java in  » Build » maven » org » apache » maven » plugin » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » maven » org.apache.maven.plugin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.maven.plugin;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *  http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import org.apache.maven.artifact.repository.ArtifactRepository;
023:        import org.apache.maven.artifact.repository.metadata.GroupRepositoryMetadata;
024:        import org.apache.maven.artifact.repository.metadata.Metadata;
025:        import org.apache.maven.artifact.repository.metadata.Plugin;
026:        import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
027:        import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
028:        import org.apache.maven.artifact.repository.metadata.RepositoryMetadataResolutionException;
029:        import org.codehaus.plexus.logging.AbstractLogEnabled;
030:
031:        import java.util.ArrayList;
032:        import java.util.Collections;
033:        import java.util.HashMap;
034:        import java.util.Iterator;
035:        import java.util.List;
036:        import java.util.Map;
037:
038:        /**
039:         * Manage plugin prefix to artifact ID mapping associations.
040:         * 
041:         * @author <a href="mailto:brett@apache.org">Brett Porter</a>
042:         * @version $Id: DefaultPluginMappingManager.java 495147 2007-01-11 07:47:53Z
043:         *          jvanzyl $
044:         */
045:        public class DefaultPluginMappingManager extends AbstractLogEnabled
046:                implements  PluginMappingManager {
047:            protected RepositoryMetadataManager repositoryMetadataManager;
048:
049:            private Map pluginDefinitionsByPrefix = new HashMap();
050:
051:            public org.apache.maven.model.Plugin getByPrefix(
052:                    String pluginPrefix, List groupIds,
053:                    List pluginRepositories, ArtifactRepository localRepository) {
054:                // if not found, try from the remote repository
055:                if (!pluginDefinitionsByPrefix.containsKey(pluginPrefix)) {
056:                    getLogger().info(
057:                            "Searching repository for plugin with prefix: \'"
058:                                    + pluginPrefix + "\'.");
059:
060:                    loadPluginMappings(groupIds, pluginRepositories,
061:                            localRepository);
062:                }
063:
064:                return (org.apache.maven.model.Plugin) pluginDefinitionsByPrefix
065:                        .get(pluginPrefix);
066:            }
067:
068:            private void loadPluginMappings(List groupIds,
069:                    List pluginRepositories, ArtifactRepository localRepository) {
070:                List pluginGroupIds = new ArrayList(groupIds);
071:
072:                // TODO: use constant
073:                if (!pluginGroupIds.contains("org.apache.maven.plugins")) {
074:                    pluginGroupIds.add("org.apache.maven.plugins");
075:                }
076:                if (!pluginGroupIds.contains("org.codehaus.mojo")) {
077:                    pluginGroupIds.add("org.codehaus.mojo");
078:                }
079:
080:                for (Iterator it = pluginGroupIds.iterator(); it.hasNext();) {
081:                    String groupId = (String) it.next();
082:                    getLogger().debug(
083:                            "Loading plugin prefixes from group: " + groupId);
084:                    try {
085:                        loadPluginMappings(groupId, pluginRepositories,
086:                                localRepository);
087:                    } catch (RepositoryMetadataResolutionException e) {
088:                        getLogger().warn(
089:                                "Cannot resolve plugin-mapping metadata for groupId: "
090:                                        + groupId + " - IGNORING.");
091:
092:                        getLogger().debug(
093:                                "Error resolving plugin-mapping metadata for groupId: "
094:                                        + groupId + ".", e);
095:                    }
096:                }
097:            }
098:
099:            private void loadPluginMappings(String groupId,
100:                    List pluginRepositories, ArtifactRepository localRepository)
101:                    throws RepositoryMetadataResolutionException {
102:                RepositoryMetadata metadata = new GroupRepositoryMetadata(
103:                        groupId);
104:
105:                repositoryMetadataManager.resolve(metadata, pluginRepositories,
106:                        localRepository);
107:
108:                Metadata repoMetadata = metadata.getMetadata();
109:                if (repoMetadata != null) {
110:                    for (Iterator pluginIterator = repoMetadata.getPlugins()
111:                            .iterator(); pluginIterator.hasNext();) {
112:                        Plugin mapping = (Plugin) pluginIterator.next();
113:
114:                        String prefix = mapping.getPrefix();
115:
116:                        //if the prefix has already been found, don't add it again.
117:                        //this is to preserve the correct ordering of prefix searching (MNG-2926)
118:                        if (!pluginDefinitionsByPrefix.containsKey(prefix)) {
119:                            String artifactId = mapping.getArtifactId();
120:
121:                            org.apache.maven.model.Plugin plugin = new org.apache.maven.model.Plugin();
122:
123:                            plugin.setGroupId(metadata.getGroupId());
124:
125:                            plugin.setArtifactId(artifactId);
126:
127:                            pluginDefinitionsByPrefix.put(prefix, plugin);
128:                        }
129:                    }
130:                }
131:            }
132:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.