| 1 | |
package com.aurea.maven.plugins.sonic.sdm; |
| 2 | |
|
| 3 | |
import java.io.File; |
| 4 | |
|
| 5 | |
import org.apache.maven.plugin.MojoExecutionException; |
| 6 | |
import org.apache.maven.plugin.MojoFailureException; |
| 7 | |
import org.codehaus.plexus.archiver.Archiver; |
| 8 | |
import org.codehaus.plexus.archiver.manager.ArchiverManager; |
| 9 | |
import org.codehaus.plexus.util.FileUtils; |
| 10 | |
|
| 11 | |
import com.aurea.maven.plugins.sonic.sdm.container.impl.DefaultContainerMap; |
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | 0 | public class SdmPackageMojo extends AbstractSdmMojo { |
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
protected boolean forcePropertyGeneration ; |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
protected File containerPropFile; |
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
protected File queueMappingsFile; |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
protected ArchiverManager archiverManager; |
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
protected DefaultContainerMap containerMap; |
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
protected void doExecute() throws MojoExecutionException, MojoFailureException { |
| 72 | |
|
| 73 | |
|
| 74 | 0 | String[] excludeFiles = { getGeneratedPropertiesFile().getName() }; |
| 75 | 0 | if(forcePropertyGeneration){ |
| 76 | 0 | excludeFiles[0] = ""; |
| 77 | |
} |
| 78 | |
try { |
| 79 | |
|
| 80 | |
|
| 81 | 0 | File sdmFile = new File(getOutputDirectory(), getFinalAssemblyFileName()); |
| 82 | 0 | Archiver archiver = archiverManager.getArchiver("zip"); |
| 83 | 0 | archiver.setDestFile(sdmFile); |
| 84 | 0 | archiver.addDirectory(getTargetSDMDir(), null, excludeFiles); |
| 85 | 0 | archiver.createArchive(); |
| 86 | 0 | project.getArtifact().setFile(sdmFile); |
| 87 | |
|
| 88 | 0 | FileUtils.forceDelete ( new File("target" + File.separatorChar + "unzip")); |
| 89 | 0 | } catch (Exception e) { |
| 90 | 0 | throw new MojoExecutionException("Error creating SDM Model - " + e.getMessage(), e); |
| 91 | 0 | } |
| 92 | |
|
| 93 | |
|
| 94 | 0 | } |
| 95 | |
|
| 96 | |
} |