-
Notifications
You must be signed in to change notification settings - Fork 60
/
build.gradle
182 lines (158 loc) · 5.28 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
// Copyright 2016-2020 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// internal plugins
apply plugin: 'java-library'
apply plugin: 'eclipse' // Eclipse integration
description = """"""
def version_str = "4.0.2"
import org.apache.tools.ant.taskdefs.condition.Os;
import org.gradle.api.tasks.options.Option;
/**
* Task class to install fastddsgen in a specific path
* @author eProsima
* @author Nuno Marques <[email protected]>
* @author Miguel Company <[email protected]>
* @version 2.0.0
* @since 2020-03-31
*/
public class InstallPath extends DefaultTask {
private String path = "";
/**
* Setter for the install path
* @param path install path given by the task option "install_path"
*/
@Option(option = "install_path", description = "Absolute path to the install dir")
public void setInstallPath(String path) {
this.path = path;
}
/**
* Getter of the install path
*/
@Input
public String getInstallPath() {
return path;
}
/**
* Uses Gradle project Copy() to copy files
* @param input file to copy
* @param ouput destination directory
*/
private void copy(String input, String output) {
project.copy {
from project.file(input)
into project.file(output)
}
}
/**
* Install Task Action that copies the script and jar files
*/
@TaskAction
private void install() {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
final String install_path = (path != null && !path.isEmpty()) ? path : "C:\\Program Files\\fastddsgen\\";
// Copy script
copy("scripts\\fastddsgen.bat", new File(install_path, "bin\\").getAbsolutePath())
// Copy jar
copy("share\\fastddsgen\\java\\fastddsgen.jar", new File(install_path, "share\\fastddsgen\\java\\").getAbsolutePath())
} else if (Os.isFamily(Os.FAMILY_UNIX) || Os.isFamily(Os.FAMILY_MAC)) {
final String install_path = (path != null && !path.isEmpty()) ? path : "/usr/local/";
// Copy script
copy("scripts/fastddsgen", new File(install_path, "bin/").getAbsolutePath())
// Copy jar
copy("share/fastddsgen/java/fastddsgen.jar", new File(install_path, "share/fastddsgen/java/").getAbsolutePath())
}
}
}
repositories {
mavenCentral()
}
dependencies {
implementation files('thirdparty/idl-parser/build/libs/idlparser-4.0.2.jar')
testImplementation('org.junit.jupiter:junit-jupiter-api:5.5.2')
testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.5.2')
}
task submodulesUpdate(type: Exec) {
description 'Updates (and inits) git submodules'
commandLine 'git', 'submodule', 'update', '--init'
}
task buildIDLParser(type: GradleBuild) {
dir = 'thirdparty/idl-parser'
tasks = ['clean', 'build']
}
buildIDLParser.dependsOn submodulesUpdate
task copyResources {
// Copy platforms file
File outputDir = file(new File("${project.buildDir}", "resources/main"))
outputDir.exists() || outputDir.mkdirs()
File versionFile = new File("${project.buildDir}/resources/main/version")
outputs.file versionFile
doLast {
// Create version file
Properties pversion = new Properties()
project.hasProperty('customversion')
? pversion.setProperty('version', project.customversion.toString())
: pversion.setProperty('version', version_str)
versionFile.withWriter {
pversion.store(it, null)
}
}
}
sourceSets {
main {
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/main/java'
include '**/*.stg'
}
}
test {
java {
srcDir 'src/test/java'
}
}
}
jar {
duplicatesStrategy 'exclude'
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
archiveBaseName = 'fastddsgen'
manifest {
attributes(
"Created-By": "eProsima",
"Main-Class": "com.eprosima.fastdds.fastddsgen",
"Class-Path": configurations.runtimeClasspath.collect { it.getName() }.join(' ')
)
}
doLast
{
copy {
from jar
into "share/fastddsgen/java"
}
}
}
compileJava.dependsOn buildIDLParser,copyResources
compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.compilerArgs.add('-Xlint:deprecation')
options.compilerArgs.add('-Xlint:unchecked')
}
task install(type: InstallPath, group: "Install", description: "Install fastddsgen script and fastddsgen.jar")
test {
useJUnitPlatform()
testLogging.showStandardStreams = true
systemProperties = System.getProperties()
}