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


001:        package org.andromda.maven.plugin.andromdapp;
002:
003:        import java.io.File;
004:
005:        import java.util.ArrayList;
006:        import java.util.Iterator;
007:        import java.util.List;
008:
009:        import org.apache.commons.io.FileUtils;
010:        import org.apache.maven.model.Build;
011:        import org.apache.maven.plugin.MojoExecutionException;
012:        import org.apache.maven.plugin.MojoFailureException;
013:        import org.codehaus.plexus.util.DirectoryScanner;
014:
015:        /**
016:         * Provides the deployment of applications to a given directory.
017:         *
018:         * @goal deploy
019:         * @phase install
020:         * @author Chad Brandon
021:         */
022:        public class DeployMojo extends AppManagementMojo {
023:            /**
024:             * Indicates whether or not this plugin should perform the deploy.
025:             *
026:             * @parameter expression="${deploy}"
027:             */
028:            private String deploy;
029:
030:            /**
031:             * The string indicating whether or not the deploy should be exploded or not.
032:             */
033:            private static final String EXPLODED = "exploded";
034:
035:            /**
036:             * Any additional files to include in the deploy liked datasource files etc
037:             * (the files must reside in the project build directory).
038:             * By default nothing besides the file artifact is deployed.
039:             *
040:             * @parameter
041:             */
042:            private String[] includes = new String[0];
043:
044:            /**
045:             * Any files to exclude in the deploy.
046:             *
047:             * @parameter
048:             */
049:            private String[] excludes = new String[0];
050:
051:            /**
052:             * @see org.apache.maven.plugin.AbstractMojo#execute()
053:             */
054:            public void execute() throws MojoExecutionException,
055:                    MojoFailureException {
056:                File artifactFile = this .project.getArtifact().getFile();
057:
058:                // - if we're deploying within a phase then deploy has to be set, otherwise
059:                //   its not needed (we know we're not deploying in a phase when the artifactFile is null).
060:                if (this .deploy != null
061:                        && !this .deploy.equals(Boolean.FALSE.toString())
062:                        || artifactFile == null) {
063:                    final Build build = this .project.getBuild();
064:                    if (EXPLODED.equalsIgnoreCase(this .deploy)) {
065:                        artifactFile = new File(build.getDirectory(), build
066:                                .getFinalName());
067:                    } else if (artifactFile == null) {
068:                        artifactFile = new File(build.getDirectory(), build
069:                                .getFinalName()
070:                                + '.' + this .getPackaging());
071:                    }
072:                    if (artifactFile.exists()) {
073:                        final File deployFile = this .getDeployFile();
074:                        final File deployDirectory = new File(
075:                                this .deployLocation);
076:                        if (deployDirectory.exists()
077:                                && deployDirectory.isDirectory()) {
078:                            try {
079:                                if (EXPLODED.equalsIgnoreCase(this .deploy)) {
080:                                    this .getLog().info(
081:                                            "Deploying exploded "
082:                                                    + artifactFile + " to "
083:                                                    + deployFile);
084:                                    FileUtils.copyDirectory(artifactFile,
085:                                            deployFile);
086:                                } else {
087:                                    // - if the deploy file is a directory, then attempt to delete it first before we 
088:                                    //   attempting deploying
089:                                    if (deployFile.exists()
090:                                            && deployFile.isDirectory()) {
091:                                        this .getLog().info(
092:                                                "Removing exploded artifact: "
093:                                                        + deployFile);
094:                                        FileUtils.deleteDirectory(deployFile);
095:                                    }
096:                                    final List deployFiles = this 
097:                                            .getAdditionalFiles();
098:                                    deployFiles.add(0, artifactFile);
099:                                    for (final Iterator iterator = deployFiles
100:                                            .iterator(); iterator.hasNext();) {
101:                                        final File file = (File) iterator
102:                                                .next();
103:                                        this .getLog().info(
104:                                                "Deploying file " + file
105:                                                        + " to "
106:                                                        + deployDirectory);
107:                                        FileUtils.copyFileToDirectory(file,
108:                                                deployDirectory);
109:                                    }
110:                                }
111:                            } catch (final Throwable throwable) {
112:                                throw new MojoExecutionException(
113:                                        "An error occurred while attempting to deploy artifact",
114:                                        throwable);
115:                            }
116:                        } else {
117:                            this 
118:                                    .getLog()
119:                                    .error(
120:                                            "Deploy did not occur because the specified deployLocation '"
121:                                                    + deployLocation
122:                                                    + "' does not exist, or is not a directory");
123:                        }
124:                    } else {
125:                        this .getLog().warn(
126:                                "Deploy did not occur because file '"
127:                                        + artifactFile + "' does not exist");
128:                    }
129:                }
130:            }
131:
132:            /**
133:             * Retrieves any additional files to include in the deploy.
134:             *
135:             * @return all poms found.
136:             * @throws MojoExecutionException
137:             */
138:            private List getAdditionalFiles() {
139:                final DirectoryScanner scanner = new DirectoryScanner();
140:                scanner.setBasedir(this .project.getBuild().getDirectory());
141:                scanner.setIncludes(this .includes);
142:                scanner.setExcludes(this .excludes);
143:                scanner.scan();
144:
145:                final List files = new ArrayList();
146:                for (int ctr = 0; ctr < scanner.getIncludedFiles().length; ctr++) {
147:                    final File file = new File(this.project.getBuild()
148:                            .getDirectory(), scanner.getIncludedFiles()[ctr]);
149:                    if (file.exists()) {
150:                        files.add(file);
151:                    }
152:                }
153:
154:                return files;
155:            }
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.