re base code
[sdc.git] / openecomp-be / tools / compile-helper-plugin / src / main / java / org / openecomp / sdc / onboarding / PostSourceGeneratorMojo.java
1 /*
2  * Copyright © 2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on a "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.sdc.onboarding;
18
19 import org.apache.maven.plugin.MojoExecutionException;
20 import org.apache.maven.plugin.MojoFailureException;
21 import org.apache.maven.plugins.annotations.LifecyclePhase;
22 import org.apache.maven.plugins.annotations.Mojo;
23 import org.apache.maven.plugins.annotations.ResolutionScope;
24
25 import java.io.File;
26 import java.io.IOException;
27 import java.io.UncheckedIOException;
28 import java.nio.file.Files;
29 import java.nio.file.Paths;
30 import java.util.List;
31 import java.util.stream.Collectors;
32
33
34 @Mojo(name = "post-source-generator-helper", threadSafe = true, defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
35         requiresDependencyResolution = ResolutionScope.TEST)
36 public class PostSourceGeneratorMojo extends PreCompileHelperMojo {
37
38     public void execute() throws MojoExecutionException, MojoFailureException {
39         if (isCodeGenerator()) {
40             super.execute();
41         }
42     }
43
44     //    @Override
45     void deleteAllClasses(File file) {
46         if (!file.exists()) {
47             return;
48         }
49         try {
50             List<File> list =
51                     Files.walk(Paths.get(file.getAbsolutePath())).filter(Files::isRegularFile).map(p -> p.toFile())
52                          .collect(Collectors.toList());
53             for (File f : list) {
54                 f.delete();
55             }
56         } catch (IOException e) {
57             throw new UncheckedIOException(e);
58         }
59
60     }
61 }