Skip to content

Commit b43c335

Browse files
Re-added the old closure API so that old gradle scripts work properly.
There are problems with actions that the properties will not be found. see https://discuss.gradle.org/t/properties-not-found-in-closures/40966 gradle/gradle#11060
1 parent a5ebd99 commit b43c335

File tree

6 files changed

+106
-1
lines changed

6 files changed

+106
-1
lines changed

src/com/inet/gradle/appbundler/AppBundlerGradleTask.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.gradle.api.GradleException;
2323
import org.gradle.api.internal.project.ProjectInternal;
2424
import org.gradle.api.tasks.TaskAction;
25+
import org.gradle.util.ConfigureUtil;
2526

2627
import com.inet.gradle.setup.abstracts.AbstractTask;
2728

@@ -72,6 +73,16 @@ public void action() {
7273
}
7374
}
7475

76+
/**
77+
* Set the needed information for signing the setup.
78+
*
79+
* @param closure the data for signing
80+
*/
81+
public void codeSign( Closure<AppBundler> closure ) {
82+
ProjectInternal project = (ProjectInternal)getProject();
83+
codeSign = ConfigureUtil.configure( closure, new OSXCodeSign<AppBundlerGradleTask,AppBundler>(this, project.getFileResolver()) );
84+
}
85+
7586
/**
7687
* Set the needed information for signing the setup.
7788
*

src/com/inet/gradle/appbundler/OSXCodeSign.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.gradle.api.Action;
1010
import org.gradle.api.internal.file.FileResolver;
1111
import org.gradle.api.internal.project.ProjectInternal;
12+
import org.gradle.util.ConfigureUtil;
1213

1314
import com.inet.gradle.setup.abstracts.AbstractBuilder;
1415
import com.inet.gradle.setup.abstracts.AbstractSetupBuilder;
@@ -330,7 +331,16 @@ public void notarize( File notarizeFile ) {
330331
}
331332

332333
/**
333-
* Set the notarization information
334+
* Set the notarization information via a closure
335+
* @param closure the notarization information
336+
*/
337+
public void notarization( Closure<OSXNotarize<T, S>> closure ) {
338+
ProjectInternal project = (ProjectInternal)task.getProject();
339+
this.notarization = ConfigureUtil.configure( closure, new OSXNotarize<T, S>(getTask(), project.getFileResolver(), this) );
340+
}
341+
342+
/**
343+
* Set the notarization information via an action
334344
* @param action the notarization information
335345
*/
336346
public void notarization( Action<? super OSXNotarize<? super T, ? super S>> action ) {

src/com/inet/gradle/setup/SetupBuilder.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import org.gradle.api.Action;
2424
import org.gradle.api.Project;
25+
import org.gradle.util.ConfigureUtil;
2526

2627
import com.inet.gradle.setup.abstracts.AbstractSetupBuilder;
2728
import com.inet.gradle.setup.abstracts.DesktopStarter;
@@ -124,6 +125,15 @@ public void setRunAfter( String runAfter ) {
124125
this.runAfter.setExecutable( runAfter );
125126
}
126127

128+
/**
129+
* Set a command that run after the installer.
130+
*
131+
* @param closure the command
132+
*/
133+
public void runAfter( Closure<?> closure ) {
134+
runAfter = ConfigureUtil.configure( closure, new DesktopStarter( this ) );
135+
}
136+
127137
/**
128138
* Set a command that run after the installer.
129139
*
@@ -153,6 +163,15 @@ public void setRunBeforeUninstall( String runAfter ) {
153163
this.runBeforeUninstall.setExecutable( runAfter );
154164
}
155165

166+
/**
167+
* Set a command that run run before the uninstaller.
168+
*
169+
* @param closue the command
170+
*/
171+
public void runBeforeUninstall( Closure<DesktopStarter> closue ) {
172+
runBeforeUninstall = ConfigureUtil.configure( closue, new DesktopStarter( this ) );
173+
}
174+
156175
/**
157176
* Set a command that run run before the uninstaller.
158177
*
@@ -163,6 +182,16 @@ public void runBeforeUninstall( Action<? super DesktopStarter> action ) {
163182
action.execute(runBeforeUninstall);
164183
}
165184

185+
/**
186+
* Register a service.
187+
*
188+
* @param closue the closure of the service definition
189+
*/
190+
public void service( Closure<Service> closue ) {
191+
Service service = ConfigureUtil.configure( closue, new Service( this ) );
192+
services.add( service );
193+
}
194+
166195
/**
167196
* Register a service.
168197
*
@@ -183,6 +212,16 @@ public List<Service> getServices() {
183212
return services;
184213
}
185214

215+
/**
216+
* Register a desktop starter.
217+
*
218+
* @param closue the closure of the desktop starter's definition
219+
*/
220+
public void desktopStarter( Closure<?> closue ) {
221+
DesktopStarter service = ConfigureUtil.configure( closue, new DesktopStarter( this ) );
222+
desktopStarters.add( service );
223+
}
224+
186225
/**
187226
* Register a desktop starter.
188227
*

src/com/inet/gradle/setup/abstracts/DesktopStarter.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.gradle.api.Action;
2323
import org.gradle.api.GradleException;
24+
import org.gradle.util.ConfigureUtil;
2425

2526
import groovy.lang.Closure;
2627

@@ -111,6 +112,19 @@ public static enum Location {
111112
StartMenu, ApplicationMenu, InstallDir, DesktopDir;
112113
}
113114

115+
/**
116+
* Register a file extensions.
117+
*
118+
* @param closue document type
119+
*/
120+
public void documentType( Closure<?> closue ) {
121+
DocumentType doc = ConfigureUtil.configure( closue, new DocumentType( setup ) );
122+
if( doc.getFileExtension() == null || doc.getFileExtension().size() == 0 ) {
123+
throw new GradleException( "The documentType has to contain at least one file extension." );
124+
}
125+
documentTypes.add( doc );
126+
}
127+
114128
/**
115129
* Register a file extensions.
116130
*

src/com/inet/gradle/setup/dmg/Dmg.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.gradle.api.tasks.Input;
2929
import org.gradle.api.tasks.InputFile;
3030
import org.gradle.api.tasks.Optional;
31+
import org.gradle.util.ConfigureUtil;
3132

3233
import com.inet.gradle.appbundler.OSXCodeSign;
3334
import com.inet.gradle.setup.SetupBuilder;
@@ -262,6 +263,16 @@ public void setFontSize( int fontSize ) {
262263
this.fontSize = fontSize;
263264
}
264265

266+
/**
267+
* Set the needed information for signing the setup.
268+
*
269+
* @param closure the data for signing
270+
*/
271+
public void setCodeSign( Closure<OSXCodeSign<Dmg, SetupBuilder>> closure ) {
272+
ProjectInternal project = (ProjectInternal)getProject();
273+
codeSign = ConfigureUtil.configure( closure, new OSXCodeSign<Dmg, SetupBuilder>( this, project.getFileResolver() ) );
274+
}
275+
265276
/**
266277
* Set the needed information for signing the setup.
267278
*

src/com/inet/gradle/setup/msi/Msi.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.gradle.api.tasks.Input;
3333
import org.gradle.api.tasks.InputFile;
3434
import org.gradle.api.tasks.InputFiles;
35+
import org.gradle.util.ConfigureUtil;
3536

3637
import com.inet.gradle.setup.abstracts.AbstractSetupTask;
3738
import com.inet.gradle.setup.util.ResourceUtils;
@@ -221,6 +222,15 @@ public void setDialogBmp( Object dialogBmp ) {
221222
this.dialogBmp = dialogBmp;
222223
}
223224

225+
/**
226+
* Set the needed information for signing the setup.
227+
*
228+
* @param closue the data for signing
229+
*/
230+
public void signTool( Closure<SignTool> closue ) {
231+
signTool = ConfigureUtil.configure( closue, new SignTool() );
232+
}
233+
224234
/**
225235
* Set the needed information for signing the setup.
226236
*
@@ -359,6 +369,16 @@ public void setMinOS( double minVersion ) {
359369
this.minOS = minVersion;
360370
}
361371

372+
/**
373+
* Register a lauch4j configuration.
374+
*
375+
* @param closue the closure of the launch4j definition
376+
*/
377+
public void launch4j( Closure<Launch4j> closue ) {
378+
Launch4j service = ConfigureUtil.configure( closue, new Launch4j( getSetupBuilder() ) );
379+
launch4j.add( service );
380+
}
381+
362382
/**
363383
* Register a lauch4j configuration. Every configuration create an *.exe file with the given settings.
364384
*

0 commit comments

Comments
 (0)