|
1 | 1 | package io.bootique.tools.release.controller; |
2 | 2 |
|
3 | | -import io.bootique.tools.release.model.maven.persistent.Project; |
4 | 3 | import io.bootique.tools.release.model.persistent.Repository; |
5 | | -import io.bootique.tools.release.service.desktop.DesktopException; |
6 | | -import io.bootique.tools.release.service.desktop.DesktopService; |
7 | | -import io.bootique.tools.release.service.git.GitService; |
8 | | -import io.bootique.tools.release.service.job.JobException; |
9 | 4 | import io.bootique.tools.release.service.validation.ValidatePomService; |
10 | | -import io.bootique.tools.release.view.ValidationView; |
11 | 5 | import jakarta.inject.Inject; |
12 | 6 | import jakarta.ws.rs.GET; |
13 | 7 | import jakarta.ws.rs.Path; |
14 | | -import jakarta.ws.rs.QueryParam; |
15 | 8 | import org.apache.cayenne.ObjectContext; |
16 | 9 | import org.apache.cayenne.query.ObjectSelect; |
17 | 10 |
|
18 | | -import java.io.IOException; |
19 | 11 | import java.util.LinkedHashMap; |
20 | 12 | import java.util.List; |
21 | 13 | import java.util.Map; |
22 | | -import java.util.function.Function; |
23 | 14 |
|
24 | 15 | @Path("/validation") |
25 | 16 | public class ValidationController extends BaseJobController { |
26 | 17 |
|
27 | | - private static final String CONTROLLER_NAME = "validation"; |
28 | | - |
29 | | - @Inject |
30 | | - private DesktopService desktopService; |
31 | | - |
32 | 18 | @Inject |
33 | 19 | private ValidatePomService validatePomService; |
34 | 20 |
|
35 | | - @GET |
36 | | - public ValidationView home() { |
37 | | - return new ValidationView(getCurrentUser(), getCurrentOrganization()); |
38 | | - } |
39 | | - |
40 | | - @GET |
41 | | - @Path("/validate") |
42 | | - public String validate(@QueryParam("releaseVersion") String releaseVersion, |
43 | | - @QueryParam("nextDevVersion") String nextDevVersion, |
44 | | - @QueryParam("selectedModules") String selectedModules) throws IOException { |
45 | | - Function<Project, String> repoProcessor = project -> { |
46 | | - try { |
47 | | - Repository repo = project.getRepository(); |
48 | | - if (!mavenService.isMavenProject(repo)) { |
49 | | - throw new JobException("NO_POM", "No pom.xml for repo " + repo); |
50 | | - } |
51 | | - String[] prepareArgs = { |
52 | | - "-DpreparationGoals=clean", |
53 | | - "-B", // non-interactive batch mode |
54 | | - "release:prepare", |
55 | | - "-Darguments=\"-Dgpg.pinentry-mode=default -DskipTests\"", |
56 | | - "-Dbootique.version=" + releaseVersion, |
57 | | - "-Pgpg", // gpg signing profile |
58 | | - "-Ddummy.version=" + releaseVersion, |
59 | | - "-Dtag=" + releaseVersion, |
60 | | - "-DreleaseVersion=" + releaseVersion, |
61 | | - "-DdevelopmentVersion=" + nextDevVersion, |
62 | | - "-DdryRun=true" |
63 | | - }; |
64 | | - desktopService.runMavenCommand( |
65 | | - preferences.get(GitService.BASE_PATH_PREFERENCE).resolve(repo.getName()), prepareArgs |
66 | | - ); |
67 | | - return ""; |
68 | | - } catch (DesktopException ex) { |
69 | | - throw new JobException(ex.getMessage(), ex); |
70 | | - } |
71 | | - }; |
72 | | - startJob(repoProcessor, selectedModules, CONTROLLER_NAME); |
73 | | - return ""; |
74 | | - } |
75 | | - |
76 | 21 | @GET |
77 | 22 | @Path("/pom") |
78 | 23 | public String validatePom() { |
|
0 commit comments