-
Notifications
You must be signed in to change notification settings - Fork 21
/
Rpm.java
267 lines (232 loc) · 6.86 KB
/
Rpm.java
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/*
* Copyright 2015 i-net software
*
* 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.
*/
package com.inet.gradle.setup.unix.rpm;
import java.util.ArrayList;
import org.gradle.api.internal.project.ProjectInternal;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Optional;
import com.inet.gradle.setup.unix.Unix;
/**
* The rpm Gradle task. It build a rpm package for Linux.
*
* @author Volker Berlin
*/
public class Rpm extends Unix {
private String summary;
private String release;
private String license;
private boolean backwardCompatible = true;
private ArrayList<String> specHeader = new ArrayList<String>();
private ArrayList<String> prep = new ArrayList<String>();
private ArrayList<String> build = new ArrayList<String>();
private ArrayList<String> install = new ArrayList<String>();
private ArrayList<String> clean = new ArrayList<String>();
/**
* the default constructor
*/
public Rpm() {
super( "rpm" );
}
/**
* {@inheritDoc}
*/
@Override
public void build() {
ProjectInternal project = (ProjectInternal)getProject();
new RpmBuilder( this, getSetupBuilder(), project.getFileResolver() ).build();
}
/**
* Returns the summary that should be used in the 'Summary' entry in the SPEC file.
*
* @return the summary specified in the gradle script
*/
@Input
public String getSummary() {
if( summary != null ) {
return summary;
}
return getSetupBuilder().getApplication();
}
/**
* Sets the value for the 'Summary' entry in the SPEC file.
*
* @param summary
* the value for the entry
*/
public void setSummary( String summary ) {
this.summary = summary;
}
/**
* Returns the release that should be used in the 'Release' entry in the SPEC file.
*
* @return the release specified in the gradle script
*/
@Input
@Optional
public String getRelease() {
return release;
}
/**
* Sets the value for the 'Release' entry in the SPEC file.
*
* @param release
* the value for the entry
*/
public void setRelease( String release ) {
this.release = release;
}
/**
* Returns the license that should be used in the 'License' entry in the SPEC file.
*
* @return the license specified in the gradle script
*/
@Input
@Optional
public String getLicense() {
return license;
}
/**
* Sets the value for the 'License' entry in the SPEC file.
*
* @param license
* the value for the entry
*/
public void setLicense( String license ) {
this.license = license;
}
/**
* Returns the backward compatibility for old rpm versions
*
* @return the backward compatibility for old rpm versions
*/
@Input
public boolean isBackwardCompatible() {
return backwardCompatible;
}
/**
* Sets the backward compatibility for old rpm versions
*
* @param backwardCompatibility
* the backward compatibility for old rpm versions
*/
public void setBackwardCompatible( boolean backwardCompatibility ) {
this.backwardCompatible = backwardCompatibility;
}
/**
* Returns the specHeader which are header lines that should be put additionally
*
* @return the prep specified in the gradle script
*/
@Input
@Optional
public ArrayList<String> getSpecHeader() {
return specHeader;
}
/**
* Adds an entry to the additional SPEC file header
*
* @param specHeader
* the value for the entry
*/
public void setSpecHeader( String specHeader ) {
this.specHeader.add( specHeader );
}
/**
* Returns the prep that should be used in the '%prep' entry in the SPEC file.
*
* @return the prep specified in the gradle script
*/
@Input
@Optional
public ArrayList<String> getPrep() {
return prep;
}
/**
* Sets the value for the '%prep' entry in the SPEC file.
*
* @param prep
* the value for the entry
*/
public void setPrep( String prep ) {
this.prep.add( prep );
}
/**
* Returns the clean that should be used in the '%clean' entry in the SPEC file.
*
* @return the clean specified in the gradle script
*/
@Input
@Optional
public ArrayList<String> getClean() {
return clean;
}
/**
* Sets the value for the '%clean' entry in the SPEC file.
*
* @param clean
* the value for the entry
*/
public void setClean( String clean ) {
this.clean.add( clean );
}
/**
* Returns the install that should be used in the '%install' entry in the SPEC file.
*
* @return the install specified in the gradle script
*/
@Input
@Optional
public ArrayList<String> getInstall() {
return install;
}
/**
* Sets the value for the '%install' entry in the SPEC file.
*
* @param install
* the value for the entry
*/
public void setInstall( String install ) {
this.install.add( install );
}
/**
* Returns the build that should be used in the '%build' entry in the SPEC file.
*
* @return the build specified in the gradle script
*/
@Input
@Optional
public ArrayList<String> getBuild() {
return build;
}
/**
* Sets the value for the '%build' entry in the SPEC file.
*
* @param build
* the value for the entry
*/
public void setBuild( String build ) {
this.build.add( build );
}
@Override
@Input
public String getArchitecture() {
String architecture = super.getArchitecture();
if( architecture == null || architecture.length() == 0 ) {
architecture = "noarch";
}
return architecture;
}
}