1
2
3
4 package ch.syabru.maven.timemachine;
5
6 import org.apache.commons.lang.SystemUtils;
7 import org.apache.maven.plugin.AbstractMojo;
8 import org.apache.maven.plugin.MojoExecutionException;
9
10 import java.io.File;
11 import java.io.IOException;
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 public class TimeMachineMojo extends AbstractMojo
28 {
29
30
31
32
33
34 private File outputDirectory;
35
36 public void execute() throws MojoExecutionException
37 {
38 if (SystemUtils.IS_OS_MAC_OSX) {
39 File f = outputDirectory;
40
41 if (!f.exists())
42 {
43 f.mkdirs();
44 }
45 String cmd = "xattr -w com.apple.metadata:" +
46 "com_apple_backup_excludeItem com.apple.backupd " +
47 outputDirectory.getAbsolutePath();
48 try {
49 Runtime.getRuntime().exec(cmd);
50 } catch (IOException e) {
51 throw new MojoExecutionException("Error executing " + cmd, e);
52 }
53 }
54 }
55 }