1 | |
package com.aurea.maven.plugins.sonic.esb; |
2 | |
|
3 | |
import java.io.File; |
4 | |
import java.util.List; |
5 | |
|
6 | |
import org.codehaus.plexus.util.FileUtils; |
7 | |
import org.codehaus.plexus.util.xml.Xpp3Dom; |
8 | |
|
9 | |
import com.aurea.maven.plugins.sonic.utils.FileUtilities; |
10 | |
import com.aurea.maven.plugins.sonic.utils.ZipUtilities; |
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | 0 | public class EsbDxsiPackageMojo extends EsbPackageMojo { |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
protected File targetDxsiDir; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
protected File unpackDxsiDir; |
36 | |
|
37 | |
@Override |
38 | |
protected File createXarFile() throws Exception { |
39 | |
|
40 | |
|
41 | |
|
42 | 0 | String[] xarExtension = { |
43 | |
"xar" |
44 | |
}; |
45 | 0 | String[] xarFiles = FileUtils.getFilesFromExtension(targetDxsiDir.getPath(), xarExtension); |
46 | 0 | for (String xarFilename : xarFiles) { |
47 | 0 | ZipUtilities.doUnzipAction(xarFilename, unpackDxsiDir.getPath()); |
48 | |
} |
49 | |
|
50 | 0 | FileUtilities.copyFiles(unpackDxsiDir.getCanonicalPath(), getPackageXarDir() + "", "**/*", |
51 | |
getXarExcludePatterns(), "", false); |
52 | |
|
53 | |
|
54 | 0 | return super.createXarFile(); |
55 | |
} |
56 | |
|
57 | |
@Override |
58 | |
protected void addArtifactReplaceRules(final List<Xpp3Dom> _replaceRules) { |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | 0 | String originalValue = "sonicfs:///DataXtend/" + getProjectName(); |
67 | 0 | String updatedValue = "sonicfs:///" |
68 | |
+ getSonicFSProjectRoot() + "/" |
69 | |
+ getGroupId().replace(".", "/") + "/" |
70 | |
+ getArtifactId() + "/" |
71 | |
+ getVersion(); |
72 | |
|
73 | 0 | Xpp3Dom projectReplace = new Xpp3Dom("stringReplaceMap"); |
74 | 0 | projectReplace.setAttribute("name", originalValue); |
75 | 0 | projectReplace.setAttribute("updatedName", updatedValue); |
76 | 0 | _replaceRules.add(projectReplace); |
77 | 0 | getLog().info("Adding stringReplaceMap: " + originalValue + " -> " + updatedValue); |
78 | |
|
79 | 0 | } |
80 | |
|
81 | |
private String getTargetDxsiDirRelativeToBasedir() { |
82 | |
|
83 | 0 | return targetDxsiDir.getAbsolutePath().replace(project.getBasedir().getAbsolutePath(), "").replace("\\", "/"); |
84 | |
} |
85 | |
|
86 | |
} |