1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "javaplugin.h" |
6 | |
7 | #include "maven/mavengenerator.h" |
8 | #include "maven/option/optionmavengenerator.h" |
9 | #include "maven/project/mavenprojectgenerator.h" |
10 | #include "maven/builder/mainframe/mavenbuildergenerator.h" |
11 | #include "gradle/gradlegenerator.h" |
12 | #include "gradle/option/optiongradlegenerator.h" |
13 | #include "gradle/project/gradleprojectgenerator.h" |
14 | #include "gradle/builder/mainframe/gradlebuildergenerator.h" |
15 | #include "java/option/optionjavagenerator.h" |
16 | |
17 | #include "services/language/languageservice.h" |
18 | #include "services/project/projectservice.h" |
19 | #include "services/option/optionservice.h" |
20 | #include "services/builder/builderservice.h" |
21 | |
22 | using namespace dpfservice; |
23 | |
24 | void JavaPlugin::initialize() |
25 | { |
26 | qInfo() << __FUNCTION__; |
27 | } |
28 | |
29 | bool JavaPlugin::start() |
30 | { |
31 | qInfo() << __FUNCTION__; |
32 | auto &ctx = dpfInstance.serviceContext(); |
33 | LanguageService *languageService = ctx.service<LanguageService>(LanguageService::name()); |
34 | if (languageService) { |
35 | QString errorString; |
36 | bool ret = languageService->regClass<MavenGenerator>(MavenGenerator::toolKitName(), &errorString); |
37 | if (!ret) { |
38 | qCritical() << errorString; |
39 | } else { |
40 | ret = languageService->create<MavenGenerator>(MavenGenerator::toolKitName(), &errorString); |
41 | if (!ret) { |
42 | qCritical() << errorString; |
43 | } |
44 | } |
45 | |
46 | ret = languageService->regClass<GradleGenerator>(GradleGenerator::toolKitName(), &errorString); |
47 | if (!ret) { |
48 | qCritical() << errorString; |
49 | } else { |
50 | ret = languageService->create<GradleGenerator>(GradleGenerator::toolKitName(), &errorString); |
51 | if (!ret) { |
52 | qCritical() << errorString; |
53 | } |
54 | } |
55 | } |
56 | |
57 | ProjectService *projectService = ctx.service<ProjectService>(ProjectService::name()); |
58 | if (projectService) { |
59 | QString errorString; |
60 | projectService->implGenerator<MavenProjectGenerator>(MavenProjectGenerator::toolKitName(), &errorString); |
61 | projectService->implGenerator<GradleProjectGenerator>(GradleProjectGenerator::toolKitName(), &errorString); |
62 | } |
63 | |
64 | OptionService *optionService = ctx.service<OptionService>(OptionService::name()); |
65 | if (!optionService) { |
66 | qCritical() << "Failed, not found OptionGradle service!" ; |
67 | abort(); |
68 | } |
69 | optionService->implGenerator<OptionGradleGenerator>(OptionGradleGenerator::kitName()); |
70 | optionService->implGenerator<OptionMavenGenerator>(OptionMavenGenerator::kitName()); |
71 | optionService->implGenerator<OptionJavaGenerator>(OptionJavaGenerator::kitName()); |
72 | |
73 | BuilderService *builderService = ctx.service<BuilderService>(BuilderService::name()); |
74 | if (builderService) { |
75 | QString errorString; |
76 | bool retMaven = builderService->regClass<MavenBuilderGenerator>(MavenBuilderGenerator::toolKitName(), &errorString); |
77 | if (retMaven) { |
78 | builderService->create<MavenBuilderGenerator>(MavenBuilderGenerator::toolKitName(), &errorString); |
79 | } |
80 | bool retGradle = builderService->regClass<GradleBuilderGenerator>(GradleBuilderGenerator::toolKitName(), &errorString); |
81 | if (retGradle) { |
82 | builderService->create<GradleBuilderGenerator>(GradleBuilderGenerator::toolKitName(), &errorString); |
83 | } |
84 | } |
85 | |
86 | return true; |
87 | } |
88 | |
89 | dpf::Plugin::ShutdownFlag JavaPlugin::stop() |
90 | { |
91 | qInfo() << __FUNCTION__; |
92 | return Sync; |
93 | } |
94 | |
95 | |
96 | |