1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "gradlebuild.h" |
6 | |
7 | #include "services/builder/builderservice.h" |
8 | #include "services/option/optionmanager.h" |
9 | |
10 | class GradleBuildPrivate |
11 | { |
12 | friend class GradleBuild; |
13 | }; |
14 | |
15 | GradleBuild::GradleBuild(QObject *parent) |
16 | : QObject(parent) |
17 | , d(new GradleBuildPrivate()) |
18 | { |
19 | |
20 | } |
21 | |
22 | GradleBuild::~GradleBuild() |
23 | { |
24 | if (d) |
25 | delete d; |
26 | } |
27 | |
28 | QString GradleBuild::build(const QString& kitName, const QString& projectPath) |
29 | { |
30 | QString buildUuid; |
31 | auto &ctx = dpfInstance.serviceContext(); |
32 | dpfservice::BuilderService *builderService = ctx.service<dpfservice::BuilderService>(dpfservice::BuilderService::name()); |
33 | |
34 | if (builderService) { |
35 | BuildCommandInfo commandInfo; |
36 | commandInfo.kitName = kitName; |
37 | commandInfo.program = OptionManager::getInstance()->getGradleToolPath(); |
38 | commandInfo.arguments = QStringList("build"); |
39 | commandInfo.workingDir = projectPath; |
40 | |
41 | buildUuid = commandInfo.uuid; |
42 | builderService->interface.builderCommand({commandInfo}, false); |
43 | } |
44 | |
45 | return buildUuid; |
46 | } |
47 | |
48 | |
49 |