-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
226 lines (172 loc) · 6.09 KB
/
build.gradle
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
buildscript {
repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://artifacts.halodi.com/repository/maven-open-source-group" }
mavenLocal()
}
dependencies {
classpath "us.ihmc:ihmc-commons:0.30.4"
classpath "us.ihmc:log-tools:0.6.1"
classpath "us.ihmc:ihmc-pub-sub-generator:0.16.2"
classpath 'com.halodi:halodi-csharp-pub-sub-generator:0.1.7'
classpath 'net.saliman:gradle-properties-plugin:1.5.1'
}
}
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'net.saliman.properties'
group = "com.halodi"
//def inputVersion= project.hasProperty("artifactVersion") ?
// project.getProperty("artifactVersion"): System.getenv('ARTIFACT_VERSION')
//version = "$inputVersion$versionAppendix"
version = "2.1.2"
def repoUrl = "https://artifacts.halodi.com/repository"
def outputDirectory = project.file("$buildDir/java-generated")
def csOutputDirectory = project.file("${project.projectDir}/halodi-messages-unity-support/Packages/halodi-messages/Runtime")
repositories {
mavenCentral()
maven { url "https://artifacts.halodi.com/repository/maven-open-source-group" }
mavenLocal()
}
sourceSets {
main {
java {
srcDirs = [ outputDirectory ]
}
}
}
dependencies
{
api group: "us.ihmc", name: "euclid-geometry", version: "0.16.2"
api group: "us.ihmc", name: "ihmc-pub-sub", version: "0.16.2"
api group: "us.ihmc", name: "ros2-common-interfaces", version: "0.19.4"
}
task generateHalodiMessages(type: us.ihmc.idl.generator.IDLGeneratorTask) {
idlFiles = fileTree(dir: "halodi_msgs/msg/")
idlFiles += fileTree(dir: "ocs2_ros2_msgs/msg/")
includeDirs = files(".", "java-typesupport")
targetDirectory = outputDirectory
packagePrefix = ""
doFirst
{
mkdir outputDirectory
}
doLast
{
// Due to incompatiblity with how the java messages are generated and how the new .idl support is defined, we need to add ".dds" to the package name for all included files.
def typesupportDirectories = file("java-typesupport")
def generated = fileTree(dir: outputDirectory)
typesupportDirectories.eachFile(groovy.io.FileType.DIRECTORIES) {
def packageName = it.name
generated.each
{
def msgAdjusted = it.text.replaceAll(packageName + "\\." + "msg", packageName + "\\." + "msg.dds")
def srvAdjusted = msgAdjusted.replaceAll(packageName + "\\." + "srv", packageName + "\\." + "srv.dds")
it.text = srvAdjusted
}
}
}
}
task importRos2IDL(type: DefaultTask) {
doLast
{
def typesupportDirectories = fileTree(dir: "java-typesupport", include: "**/*.idl")
def generated = fileTree(dir: outputDirectory)
typesupportDirectories.each {
def newPath = it.absolutePath.replaceAll("_\\.idl\$", ".idl")
def includeAdjusted = it.text.replaceAll(/#include "(.*)_\.idl"/, /#include "$1\.idl"/)
def ddsAdjusted = includeAdjusted.replaceAll(/(?s)module dds(.*?)\{(.*)\};/, /$2/)
def ddsRemoved = ddsAdjusted.replaceAll(/::dds::/, '::')
it.text = ddsRemoved
println "Moving " + it.name + " to " + newPath
it.renameTo(newPath)
}
}
}
task generateCSharpMessages(type: com.halodi.idl.generator.IDLCSharpGeneratorTask) {
idlFiles = fileTree(dir: "halodi_msgs/msg/")
idlFiles += fileTree(dir: "ocs2_ros2_msgs/msg/")
idlFiles += fileTree(dir: "java-typesupport/", include: '**/*.idl')
includeDirs = files(".", "java-typesupport")
targetDirectory = csOutputDirectory
packagePrefix = ""
doFirst
{
mkdir csOutputDirectory
}
doLast
{
def typesupportDirectories = file(csOutputDirectory)
def generated = fileTree(dir: outputDirectory)
def constantDirectories = []
typesupportDirectories.eachFileRecurse(groovy.io.FileType.DIRECTORIES) {
if(it.name.endsWith("_Constants"))
{
constantDirectories.add(it)
}
}
constantDirectories.each() {
it.deleteDir()
}
}
}
build.dependsOn generateHalodiMessages
jar.dependsOn generateHalodiMessages
build.dependsOn generateCSharpMessages
jar.dependsOn generateCSharpMessages
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
// Create the pom configuration:
def pomConfig = {
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
developers {
developer {
name "Jesper Smith"
email "jesper@halodi.com"
}
}
scm {
url "https://github.com/yourgithubaccount/example"
}
}
// Create the publication with the pom configuration:
publishing {
publications {
HalodiMessages(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId group
artifactId project.name
version version
}
}
}
publishing {
repositories {
maven {
def inputUsername = project.hasProperty("artifactUsername") ?
project.getProperty("artifactUsername"): System.getenv('ARTIFACT_USERNAME')
def inputPassword = project.hasProperty("artifactPassword") ?
project.getProperty("artifactPassword"): System.getenv('ARTIFACT_PASSWORD')
credentials {
username inputUsername
password inputPassword
}
url "$repoUrl$repository"
}
}
}