Clover Coverage Report - Maven Oracle Plugin 1.0.0-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
62   114   13   6.2
4   101   0.21   10
10     1.3  
1    
 
  DeployUtils       Line # 13 62 0% 13 76 0% 0.0
 
No Tests
 
1    package org.kuali.maven.plugins;
2   
3    import java.io.File;
4    import java.io.IOException;
5    import java.util.ArrayList;
6    import java.util.List;
7   
8    import org.apache.maven.artifact.Artifact;
9    import org.apache.maven.artifact.DefaultArtifact;
10    import org.apache.maven.artifact.handler.ArtifactHandler;
11    import org.apache.maven.artifact.handler.DefaultArtifactHandler;
12   
 
13    public class DeployUtils {
 
14  0 toggle public static void main(String[] args) {
15  0 try {
16  0 String basedir = System.getProperty("user.home") + "/.oracle";
17  0 DeployUtils du = new DeployUtils();
18  0 System.out.println(du.getShellScript(basedir));
19    } catch (Throwable t) {
20  0 t.printStackTrace();
21    }
22    }
23   
 
24  0 toggle public String getShellScript(String basedir) throws IOException {
25  0 File directory = new File(basedir);
26  0 DeployUtils du = new DeployUtils();
27  0 List<Artifact> artifacts = du.getArtifacts(directory, "com.oracle");
28  0 return getShellScript(artifacts);
29    }
30   
 
31  0 toggle public String getShellScript(List<Artifact> artifacts) throws IOException {
32  0 StringBuilder sb = new StringBuilder();
33  0 sb.append("#!/bin/sh\n");
34  0 for (Artifact artifact : artifacts) {
35  0 sb.append(getCommandLine(artifact) + "\n");
36    }
37  0 return sb.toString();
38    }
39   
 
40  0 toggle protected String getCommandLine(Artifact artifact) throws IOException {
41  0 StringBuilder sb = new StringBuilder();
42  0 sb.append("mvn process-resources -Pprivate");
43  0 sb.append(" -Ddeployment.groupId=" + artifact.getGroupId());
44  0 sb.append(" -Ddeployment.artifactId=" + artifact.getArtifactId());
45  0 sb.append(" -Ddeployment.version=" + artifact.getVersion());
46  0 sb.append(" -Ddeployment.file=" + artifact.getFile().getCanonicalPath());
47  0 return sb.toString();
48    }
49   
 
50  0 toggle public String getGAVString(Artifact artifact) {
51  0 StringBuilder sb = new StringBuilder();
52  0 sb.append(artifact.getGroupId());
53  0 sb.append(":");
54  0 sb.append(artifact.getArtifactId());
55  0 sb.append(":");
56  0 sb.append(artifact.getVersion());
57  0 return sb.toString();
58    }
59   
 
60  0 toggle public List<Artifact> getArtifacts(File directory, String groupId) {
61  0 List<File> files = getFiles(directory);
62  0 List<Artifact> artifacts = new ArrayList<Artifact>();
63  0 for (File file : files) {
64  0 Artifact artifact = getArtifact(directory, file, groupId);
65  0 artifacts.add(artifact);
66    }
67  0 return artifacts;
68    }
69   
 
70  0 toggle protected Artifact getArtifact(File baseDirectory, File file, String groupId) {
71  0 ArtifactHandler handler = new DefaultArtifactHandler("jar");
72  0 String artifactId = getArtifactId(file);
73  0 String version = getVersion(baseDirectory, file);
74  0 Artifact artifact = new DefaultArtifact(groupId, artifactId, version, null, "jar", null, handler);
75  0 artifact.setFile(file);
76  0 return artifact;
77    }
78   
 
79  0 toggle protected String getVersion(File baseDirectory, File file) {
80  0 String path1 = baseDirectory.getAbsolutePath();
81  0 String path2 = file.getAbsolutePath();
82  0 int pos = path2.indexOf(path1) + path1.length();
83  0 String version = path2.substring(pos);
84  0 String filename = file.getName();
85  0 pos = version.indexOf(filename);
86  0 version = version.substring(0, pos);
87  0 String fileSeparator = System.getProperty("file.separator");
88  0 version = version.replace(fileSeparator, "");
89  0 return version;
90    }
91   
 
92  0 toggle protected String getArtifactId(File file) {
93  0 String filename = file.getName();
94  0 int pos = filename.indexOf(".");
95  0 return filename.substring(0, pos);
96    }
97   
 
98  0 toggle public List<File> getFiles(File directory) {
99  0 if (!directory.isDirectory()) {
100  0 throw new IllegalArgumentException(directory + " is not a directory");
101    }
102  0 File[] fileList = directory.listFiles();
103  0 List<File> files = new ArrayList<File>();
104  0 for (File file : fileList) {
105  0 if (file.isDirectory()) {
106  0 files.addAll(getFiles(file));
107    } else {
108  0 files.add(file);
109    }
110    }
111  0 return files;
112    }
113   
114    }