Source Code Cross Referenced for InstallModulesMojo.java in  » EJB-Server-geronimo » car-maven-plugin » org » apache » geronimo » mavenplugins » car » 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 » EJB Server geronimo » car maven plugin » org.apache.geronimo.mavenplugins.car 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  Licensed to the Apache Software Foundation (ASF) under one
003:         *  or more contributor license agreements.  See the NOTICE file
004:         *  distributed with this work for additional information
005:         *  regarding copyright ownership.  The ASF licenses this file
006:         *  to you under the Apache License, Version 2.0 (the
007:         *  "License"); you may not use this file except in compliance
008:         *  with the License.  You may obtain a copy of the License at
009:         *
010:         *    http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         *  Unless required by applicable law or agreed to in writing,
013:         *  software distributed under the License is distributed on an
014:         *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         *  KIND, either express or implied.  See the License for the
016:         *  specific language governing permissions and limitations
017:         *  under the License.
018:         */package org.apache.geronimo.mavenplugins.car;
019:
020:        import java.io.File;
021:        import java.util.HashMap;
022:        import java.util.HashSet;
023:        import java.util.List;
024:        import java.util.Set;
025:
026:        import org.apache.geronimo.kernel.Kernel;
027:        import org.apache.geronimo.kernel.basic.BasicKernel;
028:        import org.apache.geronimo.kernel.repository.Artifact;
029:        import org.apache.geronimo.system.configuration.RepositoryConfigurationStore;
030:        import org.apache.geronimo.system.plugin.DownloadResults;
031:        import org.apache.geronimo.system.plugin.PluginInstallerGBean;
032:        import org.apache.geronimo.system.plugin.SourceRepository;
033:        import org.apache.geronimo.system.plugin.model.ArtifactType;
034:        import org.apache.geronimo.system.plugin.model.PluginArtifactType;
035:        import org.apache.geronimo.system.plugin.model.PluginListType;
036:        import org.apache.geronimo.system.plugin.model.PluginType;
037:        import org.apache.geronimo.system.plugin.model.AttributesType;
038:        import org.apache.geronimo.system.resolver.AliasedArtifactResolver;
039:        import org.apache.maven.artifact.repository.ArtifactRepository;
040:        import org.codehaus.mojo.pluginsupport.dependency.DependencyTree;
041:
042:        /**
043:         * Installs Geronimo module CAR files into a target repository to support assembly.
044:         *
045:         * @version $Rev: 620730 $ $Date: 2008-02-12 01:21:38 -0800 (Tue, 12 Feb 2008) $
046:         * @goal install-modules
047:         */
048:        public class InstallModulesMojo extends AbstractCarMojo {
049:            /**
050:             * The location of the server repository.
051:             *
052:             * @parameter expression="${project.build.directory}/assembly"
053:             * @required
054:             */
055:            private File targetServerDirectory = null;
056:
057:            /**
058:             * The location of the target repository.
059:             *
060:             * @parameter expression="repository"
061:             * @required
062:             */
063:            private String targetRepositoryPath = null;
064:
065:            /**
066:             * The location of the target config files.
067:             *
068:             * @parameter expression="var/config"
069:             * @required
070:             */
071:            private String targetConfigPath = null;
072:
073:            /**
074:             * ServerInstance specific in plugin configuration, to specify where config.xml and properties updates go.
075:             * @parameter
076:             */
077:            private List<ServerInstance> servers;
078:
079:            /**
080:             * Configuration to be installed specified as groupId/artifactId/version/type
081:             * if none specified, plugin will install all dependencies of type "car"
082:             *
083:             * @parameter
084:             * @optional
085:             */
086:            private String artifact = null;
087:
088:            /**
089:             * Location of the source repository for the dependencies
090:             *
091:             * @parameter expression="${localRepository}"
092:             * @required
093:             */
094:            private ArtifactRepository sourceRepository = null;
095:
096:            /**
097:             * The location where the properties mapping will be generated.
098:             *
099:             * @parameter expression="${project.build.directory}/explicit-versions.properties"
100:             * @required
101:             */
102:            private File explicitResolutionProperties = null;
103:
104:            /**
105:             * The Geronimo repository artifact resolver.
106:             * <p/>
107:             * <p/>
108:             * Using a custom name here to prevent problems that happen when Plexus
109:             * injects the Maven resolver into the base-class.
110:             * </p>
111:             */
112:            private AliasedArtifactResolver geronimoArtifactResolver;
113:
114:            private RepositoryConfigurationStore sourceStore;
115:
116:            /**
117:             * @parameter expression="${project.build.directory}/classes/var/config/overrides"
118:             * @required
119:             */
120:            private File overridesDir;
121:
122:            /**
123:             * @parameter
124:             */
125:            private List<Override> overrides;
126:
127:            /**
128:             * Set of artifacts which have already been installed, so we can skip any processing.
129:             */
130:            private Set installedArtifacts = new HashSet();
131:
132:            protected void doExecute() throws Exception {
133:                DependencyTree dependencies = dependencyHelper
134:                        .getDependencies(project);
135:                Maven2RepositoryAdapter.ArtifactLookup lookup = new ArtifactLookupImpl(
136:                        new HashMap<Artifact, org.apache.maven.artifact.Artifact>());
137:                SourceRepository sourceRepo = new Maven2RepositoryAdapter(
138:                        dependencies, lookup);
139:                PluginListType pluginList = new PluginListType();
140:                String localRepo = sourceRepository.getUrl();
141:                if ("file".equals(sourceRepository.getProtocol())) {
142:                    File localRepoDir = new File(sourceRepository.getBasedir());
143:                    localRepo = localRepoDir.toURI().toString();
144:                }
145:                pluginList.getDefaultRepository().add(localRepo);
146:                for (org.apache.maven.model.Repository repository : (List<org.apache.maven.model.Repository>) project
147:                        .getRepositories()) {
148:                    pluginList.getDefaultRepository().add(repository.getUrl());
149:                }
150:
151:                if (artifact != null) {
152:                    pluginList.getPlugin().add(
153:                            toPluginType(Artifact.create(artifact)));
154:                } else {
155:                    addDependencies(pluginList);
156:                }
157:                DownloadResults downloadPoller = new DownloadResults();
158:                String targetServerPath = targetServerDirectory
159:                        .getAbsolutePath();
160:
161:                Kernel kernel = new BasicKernel("Assembly");
162:                try {
163:                    PluginInstallerGBean installer = new PluginInstallerGBean(
164:                            targetRepositoryPath, targetServerPath, servers,
165:                            kernel, getClass().getClassLoader());
166:                    installer.install(pluginList, sourceRepo, true, null, null,
167:                            downloadPoller);
168:                    if (overrides != null) {
169:                        for (Override override : this .overrides) {
170:                            AttributesType attributes = override
171:                                    .getOverrides(overridesDir);
172:                            installer.mergeOverrides(override.getServer(),
173:                                    attributes);
174:                        }
175:                    }
176:                } finally {
177:                    kernel.shutdown();
178:                }
179:                log.info("Installed plugins: ");
180:                for (Artifact artifact : downloadPoller.getInstalledConfigIDs()) {
181:                    log.info("    " + artifact);
182:                }
183:                log.info("Installed dependencies: ");
184:                for (Artifact artifact : downloadPoller
185:                        .getDependenciesInstalled()) {
186:                    log.info("    " + artifact);
187:                }
188:                if (downloadPoller.isFailed()) {
189:                    throw downloadPoller.getFailure();
190:                }
191:            }
192:
193:            private PluginType toPluginType(Artifact artifact) {
194:                PluginType plugin = new PluginType();
195:                PluginArtifactType instance = new PluginArtifactType();
196:                ArtifactType artifactType = PluginInstallerGBean
197:                        .toArtifactType(artifact);
198:                instance.setModuleId(artifactType);
199:                plugin.getPluginArtifact().add(instance);
200:                return plugin;
201:            }
202:
203:            /**
204:             * Retrieves all artifact dependencies.
205:             *
206:             * @param pluginList PluginListType to add dependencies to as PluginType instances.
207:             */
208:            protected void addDependencies(PluginListType pluginList) {
209:
210:                org.apache.maven.artifact.Artifact artifact = project
211:                        .getArtifact();
212:                if (artifact != null
213:                        && ("car".equals(artifact.getType()) || "jar"
214:                                .equals(artifact.getType()))
215:                        && artifact.getFile() != null) {
216:                    pluginList.getPlugin().add(
217:                            toPluginType(mavenToGeronimoArtifact(artifact)));
218:                }
219:
220:                List<org.apache.maven.model.Dependency> projectArtifacts = project
221:                        .getModel().getDependencies();
222:                if (projectArtifacts != null) {
223:                    for (org.apache.maven.model.Dependency dependency : projectArtifacts) {
224:                        if (dependency.getScope() == null
225:                                || "compile".equals(dependency.getScope())) {
226:                            pluginList
227:                                    .getPlugin()
228:                                    .add(
229:                                            toPluginType(mavenToGeronimoArtifact(dependency)));
230:                        }
231:                    }
232:                }
233:
234:            }
235:
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.