36e5f8ac321fa934064f1fa076dae60f5e319c84
[sdc.git] /
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 java.io.File;
20 import java.io.IOException;
21 import java.io.UncheckedIOException;
22 import java.nio.file.Files;
23 import java.nio.file.Paths;
24 import java.util.List;
25 import java.util.stream.Collectors;
26 import org.apache.maven.plugin.MojoExecutionException;
27 import org.apache.maven.plugin.MojoFailureException;
28 import org.apache.maven.plugins.annotations.LifecyclePhase;
29 import org.apache.maven.plugins.annotations.Mojo;
30 import org.apache.maven.plugins.annotations.ResolutionScope;
31
32
33 @Mojo(name = "post-source-generator-helper", threadSafe = true, defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
34         requiresDependencyResolution = ResolutionScope.TEST)
35 public class PostSourceGeneratorMojo extends PreCompileHelperMojo {
36
37     public void execute() throws MojoExecutionException, MojoFailureException {
38         if (isCodeGenerator()) {
39             super.execute();
40         }
41     }
42
43     //    @Override
44     void deleteAllClasses(File file) {
45         if (!file.exists()) {
46             return;
47         }
48         try {
49             List<File> list =
50                     Files.walk(Paths.get(file.getAbsolutePath())).filter(Files::isRegularFile).map(p -> p.toFile())
51                          .collect(Collectors.toList());
52             for (File f : list) {
53                 f.delete();
54             }
55         } catch (IOException e) {
56             throw new UncheckedIOException(e);
57         }
58
59     }
60 }