blob: 9eddce3a883cc49b5680cf9c2d0dfa94211c449e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
# Qt Gradle Plugin
## Plugin as dependency
All of the "blocks" mentioned below might already exist.
If that is the case, no need to create a new one.
### Modify settings.gradle (.kts)
Open settings.gradle (.kts) file.
Within the `pluginManagement` block, add `mavenCentral` and `maven` repositories.
### Groovy/Kotlin
```
pluginManagement {
repositories {
mavenCentral()
}
}
```
### Modify build.gradle (.kts)
Open `build.gradle` (.kts) file. Inside the plugins block, include the plugin ID and version.
### Groovy
```Groovy
plugins {
id 'org.qtproject.qt.gradleplugin' version '1.+'
}
```
### Kotlin
```Groovy
plugins {
id("org.qtproject.qt.gradleplugin") version("1.+")
}
```
Define `QtBuild` block to specify project and Qt configurations.
### Groovy
```Groovy
QtBuild {
// Qt installation directory
qtPath file('foobar/Qt/6.8.0')
// QML project directory
projectPath file('../qmlapp')
// Optional: Qt kit directory location
// If defined build will be done to only that ABI
// else will build using Multi-ABI
qtKitDir file('home/<your-username>/<your-Qt-builds>/<your-Qt-kit>')
// Optional: Extra cmake arguments for configuration
extraCMakeArguments = ['-DCMAKE_BUILD_TYPE=Release', '-DANDROID_NDK_ROOT=/opt/android/ndk/26.1.10909125']
// Optional: If your ninja is installed somewhere other than Qt/Tools/Ninja or
// not found in system path you can define it here
ninjaPath 'your/path/to/Ninja'
}
```
### Kotlin
```Groovy
QtBuild {
// Qt installation directory
qtPath = file("foobar/Qt/6.8.0")
// QML project directory
projectPath = file("../qmlapp")
// Optional: Qt kit directory location
// If defined build will be done to only that ABI
// else will build using Multi-ABI
qtKitDir = file('home/<your-username>/<your-Qt-builds>/<your-Qt-kit>')
// Optional: Extra cmake arguments for configuration
setExtraCMakeArguments("-DCMAKE_BUILD_TYPE=Release", "-DANDROID_NDK_ROOT=/opt/android/ndk/26.1.10909125")
// Optional: If your ninja is installed somewhere other than Qt/Tools/Ninja or
// not found in system path you can define it here
ninjaPath = 'your/path/to/Ninja'
}
```
## Build plugin
Run the following command to build and run tests for the plugin
```bash
./gradlew build
```
The .jar file can be found under folder `build/libs` and the test results can be found
under the folder `build/reports/tests`.
## Publish plugin to Local Maven
Run the following command to build and publish the plugin in local Maven:
```bash
./gradlew publishToMavenLocal
```
## Publish plugin to Maven
Run the following command to publish the plugin into a Maven repository that is defined by the
project level `./gradle.properties` or the global level `~/.gradle/gradle.properties` file.
Required properties are `publishingUrl`, `publishingUser` and `publishingPass`.
Gradle properties can also be passed by using the command-line options `-P`.
```bash
./gradlew publish
// or passing publishing parameters via command-line
./gradlew publish -PpublishingUrl=http://example.com/maven -PpublishingUser=user -PpublishingPass=pass
```
## Publish plugin to Maven Central
Run the following command to publish the plugin into a Maven repository that is defined by the
global level `~/.gradle/gradle.properties` file. Required properties are `publishingUser` and
`publishingPass`. These properties should contain the token username and password generated in
Maven Central.
```bash
./gradlew publishAllPublicationsToCentralPortal
```
Navigate to your Qt Quick as Android View project.
### Modify settings.gradle (.kts)
Add Plugin Path: Open `settings.gradle` (.kts) file.
Within the pluginManagement block, add `mavenLocal` repository.
### Groovy & Kotlin
```Groovy
pluginManagement {
repositories {
mavenLocal()
}
}
```
For the [build.gradle (.kts)](#modify-buildgradle-kts)
## Running from Android Studio IDE
`QtBuildTask` will automatically run when android application is built.
## Running from terminal
You can now run QtBuildTask with:
```bash
./gradlew QtBuildTask
```
## Debugging
Confirm that plugin is successfully added by running
```bash
./gradlew tasks --group QtProject
```
Output should look like this:
> Task :tasks
>
> ------------------------------------------------------------
> Tasks runnable from root project 'My Application'
> ------------------------------------------------------------
>
> QtProject tasks
> ---------------
> QtBuildTask - Qt Project AAR Build
>
> To see all tasks and more detail, run gradlew tasks --all
|