2424
2525import org .apache .commons .io .IOUtils ;
2626import org .apache .commons .lang3 .StringUtils ;
27- import org .apache .maven .plugin .MojoExecutionException ;
2827
2928
3029public class FileUtils {
@@ -41,26 +40,26 @@ public static File mkdir(File parent, String name) {
4140 return mkdir (dir );
4241 }
4342
44- public static void copyFileToFile (File source , File dest ) throws MojoExecutionException {
43+ public static void copyFileToFile (File source , File dest ) throws Exception {
4544 Logger .info ("Copying file [" + source + "] to folder [" + dest + "]" );
4645 try {
4746 copyFile (source , dest );
4847 } catch (IOException e ) {
49- throw new MojoExecutionException (e .getMessage (), e );
48+ throw new Exception (e .getMessage (), e );
5049 }
5150 }
5251
53- public static void copyFileToFolder (File source , File destFolder ) throws MojoExecutionException {
52+ public static void copyFileToFolder (File source , File destFolder ) throws Exception {
5453 Logger .info ("Copying file [" + source + "] to folder [" + destFolder + "]" );
5554 if (new File (destFolder , source .getName ()).exists ()) return ;
5655 try {
5756 copyFileToDirectory (source , destFolder );
5857 } catch (IOException e ) {
59- throw new MojoExecutionException (e .getMessage (), e );
58+ throw new Exception (e .getMessage (), e );
6059 }
6160 }
6261
63- public static void concat (File dest , File ... sources ) throws MojoExecutionException {
62+ public static void concat (File dest , File ... sources ) throws Exception {
6463 Logger .info ("Concatenating files [" + StringUtils .join (sources , "," ) + "] into file [" + dest + "]" );
6564 try {
6665 FileOutputStream fos = new FileOutputStream (dest );
@@ -72,25 +71,25 @@ public static void concat(File dest, File ... sources) throws MojoExecutionExcep
7271 fos .flush ();
7372 fos .close ();
7473 } catch (IOException e ) {
75- throw new MojoExecutionException ("Error concatenating streams" , e );
74+ throw new Exception ("Error concatenating streams" , e );
7675 }
7776 }
7877
79- public static void copyFolderToFolder (File from , File to ) throws MojoExecutionException {
78+ public static void copyFolderToFolder (File from , File to ) throws Exception {
8079 Logger .info ("Copying folder [" + from + "] to folder [" + to + "]" );
81- if (!from .isDirectory ()) throw new MojoExecutionException ("Source folder " + from + " is not a directory" );
80+ if (!from .isDirectory ()) throw new Exception ("Source folder " + from + " is not a directory" );
8281 try {
8382 copyDirectoryToDirectory (from , to );
8483 } catch (IOException e ) {
85- throw new MojoExecutionException (e .getMessage (), e );
84+ throw new Exception (e .getMessage (), e );
8685 }
8786 }
8887
89- public static void copyFolderContentToFolder (File from , File to ) throws MojoExecutionException {
88+ public static void copyFolderContentToFolder (File from , File to ) throws Exception {
9089 Logger .info ("Copying folder content [" + from + "] to folder [" + to + "]" );
91- if (!from .isDirectory ()) throw new MojoExecutionException ("Source folder " + from + " is not a directory" );
90+ if (!from .isDirectory ()) throw new Exception ("Source folder " + from + " is not a directory" );
9291 if (!to .exists ()) to .mkdirs ();
93- else if (!to .isDirectory ()) throw new MojoExecutionException ("Destination folder " + to + " is not a directory" );
92+ else if (!to .isDirectory ()) throw new Exception ("Destination folder " + to + " is not a directory" );
9493 for (File file : from .listFiles ()) {
9594 if (file .isDirectory ())
9695 copyFolderToFolder (file , to );
@@ -99,21 +98,21 @@ public static void copyFolderContentToFolder(File from, File to) throws MojoExec
9998 }
10099 }
101100
102- public static void moveFolderToFolder (File from , File to ) throws MojoExecutionException {
101+ public static void moveFolderToFolder (File from , File to ) throws Exception {
103102 Logger .info ("Moving folder [" + from + "] to folder [" + to + "]" );
104- if (!from .isDirectory ()) throw new MojoExecutionException ("Source folder " + from + " is not a directory" );
105- else if (to .exists () && !to .isDirectory ()) throw new MojoExecutionException ("Destination folder " + to + " is not a directory" );
103+ if (!from .isDirectory ()) throw new Exception ("Source folder " + from + " is not a directory" );
104+ else if (to .exists () && !to .isDirectory ()) throw new Exception ("Destination folder " + to + " is not a directory" );
106105 try {
107106 moveDirectoryToDirectory (from , to , true );
108107 } catch (IOException e ) {
109- throw new MojoExecutionException (e .getMessage (), e );
108+ throw new Exception (e .getMessage (), e );
110109 }
111110 }
112111
113- public static void moveFolderContentToFolder (File from , File to ) throws MojoExecutionException {
112+ public static void moveFolderContentToFolder (File from , File to ) throws Exception {
114113 Logger .info ("Moving folder content [" + from + "] to folder [" + to + "]" );
115- if (!from .isDirectory ()) throw new MojoExecutionException ("Source folder " + from + " is not a directory" );
116- else if (!to .isDirectory ()) throw new MojoExecutionException ("Destination folder " + to + " is not a directory" );
114+ if (!from .isDirectory ()) throw new Exception ("Source folder " + from + " is not a directory" );
115+ else if (!to .isDirectory ()) throw new Exception ("Destination folder " + to + " is not a directory" );
117116 try {
118117 for (File file : from .listFiles ()) {
119118 if (file .isDirectory ())
@@ -122,36 +121,36 @@ public static void moveFolderContentToFolder(File from, File to) throws MojoExec
122121 moveFileToDirectory (file , to , true );
123122 }
124123 } catch (IOException e ) {
125- throw new MojoExecutionException (e .getMessage (), e );
124+ throw new Exception (e .getMessage (), e );
126125 }
127126 }
128127
129- public static void moveFileToFolder (File from , File to ) throws MojoExecutionException {
128+ public static void moveFileToFolder (File from , File to ) throws Exception {
130129 Logger .info ("Moving file [" + from + "] to folder [" + to + "]" );
131- if (!from .isFile ()) throw new MojoExecutionException ("Source file " + from + " is not a file" );
130+ if (!from .isFile ()) throw new Exception ("Source file " + from + " is not a file" );
132131 if (!to .exists ()) to .mkdirs ();
133132 try {
134133 moveFileToDirectory (from , to , true );
135134 } catch (IOException e ) {
136- throw new MojoExecutionException (e .getMessage (), e );
135+ throw new Exception (e .getMessage (), e );
137136 }
138137 }
139138
140- private static void copyStreamToFile (InputStream is , File dest ) throws MojoExecutionException {
139+ private static void copyStreamToFile (InputStream is , File dest ) throws Exception {
141140 try {
142141 copyInputStreamToFile (is , dest );
143142 } catch (IOException ex ) {
144- throw new MojoExecutionException ("Could not copy input stream to " + dest , ex );
143+ throw new Exception ("Could not copy input stream to " + dest , ex );
145144 }
146145 }
147146
148- public static void copyResourceToFile (String resource , File dest , boolean unixStyleNewLines ) throws MojoExecutionException {
147+ public static void copyResourceToFile (String resource , File dest , boolean unixStyleNewLines ) throws Exception {
149148 copyResourceToFile (resource , dest );
150149 if (unixStyleNewLines ) {
151150 try {
152151 processFileContent (dest , c -> c .replaceAll ("\\ r\\ n" , "\n " ).replaceAll ("\\ r" , "\n " ));
153152 } catch (IOException e ) {
154- throw new MojoExecutionException (e .getMessage (), e );
153+ throw new Exception (e .getMessage (), e );
155154 }
156155 }
157156 }
@@ -162,27 +161,27 @@ public static void processFileContent(File dest, Function<String, String> functi
162161 org .apache .commons .io .FileUtils .writeStringToFile (dest , content , Charset .forName ("UTF-8" ));
163162 }
164163
165- public static void copyResourceToFile (String resource , File dest ) throws MojoExecutionException {
164+ public static void copyResourceToFile (String resource , File dest ) throws Exception {
166165 Logger .info ("Copying resource [" + resource + "] to file [" + dest + "]" );
167166 copyStreamToFile (FileUtils .class .getResourceAsStream (resource ), dest );
168167 }
169168
170169
171- public static void createSymlink (File link , File target ) throws MojoExecutionException {
170+ public static void createSymlink (File link , File target ) throws Exception {
172171 Logger .info ("Creating symbolic link [" + link + "] to [" + target + "]" );
173172 try {
174173 Files .createSymbolicLink (link .toPath (), target .toPath ());
175174 } catch (IOException e ) {
176- throw new MojoExecutionException ("Could not create symlink " + link + " to " + target , e );
175+ throw new Exception ("Could not create symlink " + link + " to " + target , e );
177176 }
178177 }
179178
180- public static void removeFolder (File folder ) throws MojoExecutionException {
179+ public static void removeFolder (File folder ) throws Exception {
181180 Logger .info ("Removing folder [" + folder + "]" );
182181 try {
183182 deleteDirectory (folder );
184183 } catch (IOException e ) {
185- throw new MojoExecutionException ("Could not remove folder " + folder , e );
184+ throw new Exception ("Could not remove folder " + folder , e );
186185 }
187186 }
188187
0 commit comments