Source Code Cross Referenced for AndroMDAMojo.java in  » UML » AndroMDA-3.2 » org » andromda » maven » plugin » bootstrap » 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 » UML » AndroMDA 3.2 » org.andromda.maven.plugin.bootstrap 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.andromda.maven.plugin.bootstrap;
002:
003:        import java.io.File;
004:        import java.io.FileNotFoundException;
005:
006:        import java.net.MalformedURLException;
007:        import java.net.URL;
008:
009:        import java.util.List;
010:
011:        import org.andromda.core.AndroMDA;
012:        import org.andromda.core.common.ExceptionUtils;
013:        import org.andromda.core.common.ResourceUtils;
014:        import org.andromda.core.configuration.Configuration;
015:        import org.andromda.core.configuration.Model;
016:        import org.andromda.core.configuration.Repository;
017:        import org.andromda.maven.plugin.configuration.AbstractConfigurationMojo;
018:        import org.apache.maven.artifact.factory.ArtifactFactory;
019:        import org.apache.maven.artifact.repository.ArtifactRepository;
020:        import org.apache.maven.plugin.MojoExecutionException;
021:        import org.apache.maven.project.MavenProject;
022:        import org.apache.maven.settings.Settings;
023:
024:        /**
025:         * This is exactly the same as the regular AndroMDAMojo in the
026:         * andromda-maven-plugin, however this is the <em>bootstrap</em> plugin which
027:         * is used to run AndroMDA in bootstrap mode (with the bootstrap artifacts).
028:         *
029:         * @author Chad Brandon
030:         * @goal run
031:         * @phase generate-sources
032:         * @requiresDependencyResolution runtime
033:         */
034:        public class AndroMDAMojo extends AbstractConfigurationMojo {
035:            /**
036:             * This is the URI to the AndroMDA configuration file.
037:             *
038:             * @parameter expression="file:${basedir}/conf/andromda.xml"
039:             * @required
040:             */
041:            private String configurationUri;
042:
043:            /**
044:             * @parameter expression="${project}"
045:             * @required
046:             * @readonly
047:             */
048:            private MavenProject project;
049:
050:            /**
051:             * @parameter expression="${project.build.filters}"
052:             */
053:            private List propertyFiles;
054:
055:            /**
056:             * Whether or not a last modified check should be performed before running
057:             * AndroMDA again.
058:             *
059:             * @parameter expression="false"
060:             * @required
061:             */
062:            private boolean lastModifiedCheck;
063:
064:            /**
065:             * The directory to which the build source is located (any generated
066:             * source).
067:             *
068:             * @parameter expression="${project.build.directory}/src/main/java"
069:             */
070:            private String buildSourceDirectory;
071:
072:            /**
073:             * The current user system settings for use in Maven. (allows us to pass the
074:             * user settings to the AndroMDA configuration).
075:             *
076:             * @parameter expression="${settings}"
077:             * @required
078:             * @readonly
079:             */
080:            private Settings settings;
081:
082:            /**
083:             * @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
084:             * @required
085:             * @readonly
086:             */
087:            private ArtifactFactory factory;
088:
089:            /**
090:             * The registered plugin implementations.
091:             *
092:             * @parameter expression="${project.build.plugins}"
093:             * @required
094:             * @readonlya
095:             */
096:            protected List plugins;
097:
098:            /**
099:             * @parameter expression="${localRepository}"
100:             * @required
101:             * @readonly
102:             */
103:            protected ArtifactRepository localRepository;
104:
105:            public void execute() throws MojoExecutionException {
106:                try {
107:                    final URL configurationUri = ResourceUtils
108:                            .toURL(this .configurationUri);
109:                    if (configurationUri == null) {
110:                        throw new MojoExecutionException(
111:                                "Configuration could not be loaded from '"
112:                                        + this .configurationUri + "'");
113:                    }
114:                    final Configuration configuration = this 
115:                            .getConfiguration(configurationUri);
116:                    boolean execute = true;
117:                    if (this .lastModifiedCheck) {
118:                        final File directory = new File(
119:                                this .buildSourceDirectory);
120:                        execute = ResourceUtils.modifiedAfter(ResourceUtils
121:                                .getLastModifiedTime(configurationUri),
122:                                directory);
123:                        if (!execute) {
124:                            final Repository[] repositories = configuration
125:                                    .getRepositories();
126:                            int repositoryCount = repositories.length;
127:                            for (int ctr = 0; ctr < repositoryCount; ctr++) {
128:                                final Repository repository = repositories[ctr];
129:                                if (repository != null) {
130:                                    final Model[] models = repository
131:                                            .getModels();
132:                                    final int modelCount = models.length;
133:                                    for (int ctr2 = 0; ctr2 < modelCount; ctr2++) {
134:                                        final Model model = models[ctr2];
135:                                        execute = ResourceUtils.modifiedAfter(
136:                                                model.getLastModified(),
137:                                                directory);
138:                                        if (execute) {
139:                                            break;
140:                                        }
141:                                    }
142:                                }
143:                            }
144:                        }
145:                    }
146:                    if (execute) {
147:                        this 
148:                                .initializeClasspathFromClassPathElements(this .project
149:                                        .getRuntimeClasspathElements());
150:                        final AndroMDA andromda = AndroMDA.newInstance();
151:                        andromda.run(configuration);
152:                        andromda.shutdown();
153:                    } else {
154:                        this 
155:                                .getLog()
156:                                .info(
157:                                        "Files are up-to-date, skipping AndroMDA execution");
158:                    }
159:                    final File buildSourceDirectory = this .buildSourceDirectory != null ? new File(
160:                            this .buildSourceDirectory)
161:                            : null;
162:                    if (buildSourceDirectory != null) {
163:                        this .getProject().addCompileSourceRoot(
164:                                buildSourceDirectory.toString());
165:                    }
166:                } catch (Throwable throwable) {
167:                    String message = "Error running AndroMDA";
168:                    throwable = ExceptionUtils.getRootCause(throwable);
169:                    if (throwable instanceof  MalformedURLException
170:                            || throwable instanceof  FileNotFoundException) {
171:                        message = "Configuration is not valid '"
172:                                + this .configurationUri + "'";
173:                    }
174:                    throw new MojoExecutionException(message, throwable);
175:                }
176:            }
177:
178:            /**
179:             * @param configurationUri The configurationUri to set.
180:             */
181:            public void setConfigurationUri(String configurationUri) {
182:                this .configurationUri = configurationUri;
183:            }
184:
185:            /**
186:             * @param project The project to set.
187:             */
188:            public void setProject(MavenProject project) {
189:                this .project = project;
190:            }
191:
192:            /**
193:             * Sets the current settings for this Mojo.
194:             *
195:             * @param settings The settings to set.
196:             */
197:            public void setSettings(Settings settings) {
198:                this .settings = settings;
199:            }
200:
201:            /**
202:             * Sets the property files for this project.
203:             *
204:             * @param propertyFiles
205:             */
206:            public void setPropertyFiles(List propertyFiles) {
207:                this .propertyFiles = propertyFiles;
208:            }
209:
210:            /**
211:             * @see org.andromda.maven.plugin.configuration.AbstractConfigurationMojo#getProject()
212:             */
213:            protected MavenProject getProject() {
214:                return this .project;
215:            }
216:
217:            /**
218:             * @see org.andromda.maven.plugin.configuration.AbstractConfigurationMojo#getPropertyFiles()
219:             */
220:            protected List getPropertyFiles() {
221:                return this .propertyFiles;
222:            }
223:
224:            /**
225:             * @see org.andromda.maven.plugin.configuration.AbstractConfigurationMojo#getSettings()
226:             */
227:            protected Settings getSettings() {
228:                return this .settings;
229:            }
230:
231:            /**
232:             * @see org.andromda.maven.plugin.configuration.AbstractConfigurationMojo#getFactory()
233:             */
234:            protected ArtifactFactory getFactory() {
235:                return this .factory;
236:            }
237:
238:            /**
239:             * @see org.andromda.maven.plugin.configuration.AbstractConfigurationMojo#getPlugins()
240:             */
241:            protected List getPlugins() {
242:                return this .plugins;
243:            }
244:
245:            /**
246:             * @see org.andromda.maven.plugin.configuration.AbstractConfigurationMojo#getLocalRepository()
247:             */
248:            protected ArtifactRepository getLocalRepository() {
249:                return this.localRepository;
250:            }
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.