Skip to content

Commit 1db4f9d

Browse files
committed
Rafactor: make version available as task variable
The refactoring allows to define the version variable in a platform specific task. There is now the choice to set the artifact version specific to a platform, for the whole SetupBuilder and therefore each platform or globally in the project. The change allows a more fine grained setup where version numbers are in a special format (msi).
1 parent 0f532b4 commit 1db4f9d

13 files changed

+137
-117
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public abstract class AbstractTask extends DefaultTask implements SetupSources {
6767

6868
private AbstractSetupBuilder setupBuilder;
6969

70-
private String extension, classifier;
70+
private String extension, classifier, version;
7171

7272
/**
7373
* Constructor with indication to artifact result
@@ -305,4 +305,24 @@ public String getDescription() {
305305
}
306306
return setupBuilder.getDescription();
307307
}
308+
309+
/**
310+
* Get the version of the task. If not set the version of the setup is returned
311+
* @return the version
312+
*/
313+
public String getVersion() {
314+
if ( version != null ) {
315+
return version;
316+
}
317+
318+
return setupBuilder.getVersion();
319+
}
320+
321+
/**
322+
* Set the version of the task
323+
* @param version the version to set
324+
*/
325+
public void setVersion( String version ) {
326+
this.version = version;
327+
}
308328
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected void prepareApplication( Application application, boolean isJNLPBuild
8080
appBundler.setName( appName );
8181
appBundler.setDisplayName( appName );
8282

83-
String version = setup.getVersion();
83+
String version = task.getVersion();
8484
appBundler.setVersion( version );
8585
int idx = version.indexOf( '.' );
8686
if( idx >= 0 ) {
@@ -121,6 +121,7 @@ protected void prepareApplication( Application application, boolean isJNLPBuild
121121
appBundler.setJarLauncherName( mainJar );
122122
}
123123

124+
appBundler.setIgnorePSN( true ); // Ignore this argument.
124125
appBundler.setCopyright( setup.getCopyright() );
125126
appBundler.setIcon( getApplicationIcon() );
126127
Architecture x86_64 = new Architecture();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ private void extractApplicationInformation() throws IOException {
276276
command.add( "--identifier" );
277277
command.add( setup.getMainClass() != null ? setup.getMainClass() : setup.getAppIdentifier() );
278278
command.add( "--version" );
279-
command.add( setup.getVersion() );
279+
command.add( task.getVersion() );
280280
command.add( "--scripts" );
281281
command.add( TempPath.get( "scripts" ).toString() );
282282
command.add( "--install-location" );

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected OSXPrefPaneCreator( Dmg task, SetupBuilder setup, FileResolver fileRes
3434

3535
/**
3636
* Create a single Lauch4j launcher.
37-
*
37+
*
3838
* @param launch the launch description
3939
* @param task the task
4040
* @param setup the SetupBuilder
@@ -98,7 +98,7 @@ void create( Service service ) throws Exception {
9898

9999
// Program will be set during installation.
100100
setPlistProperty( servicePLIST, ":Description", service.getDescription() );
101-
setPlistProperty( servicePLIST, ":Version", getSetupBuilder().getVersion() );
101+
setPlistProperty( servicePLIST, ":Version", task.getVersion() );
102102
setPlistProperty( servicePLIST, ":KeepAlive", String.valueOf( service.isKeepAlive() ) );
103103
setPlistProperty( servicePLIST, ":RunAtBoot", String.valueOf( service.isStartOnBoot() ) );
104104
setPlistProperty( servicePLIST, ":RunAtLoad", "true" );
@@ -132,7 +132,7 @@ void create( Service service ) throws Exception {
132132

133133
/**
134134
* Download and unpack the preferences pane setup files
135-
*
135+
*
136136
* @param internalName to unpack it now
137137
* @return file to prefpane sources
138138
* @throws IOException if an error occurs

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ File build() throws Exception {
9696
getOrCreateChild( jre, "runtimeBits" ).setTextContent( task.is64Bit() ? "64" : "32" );
9797

9898
Element versionInfo = getOrCreateChild( launch4jConfig, "versionInfo" );
99-
getOrCreateChild( versionInfo, "fileVersion" ).setTextContent( normalizeVersionNumber( setup.getVersion() ) );
100-
getOrCreateChild( versionInfo, "txtFileVersion" ).setTextContent( setup.getVersion() );
101-
getOrCreateChild( versionInfo, "productVersion" ).setTextContent( normalizeVersionNumber( setup.getVersion() ) );
102-
getOrCreateChild( versionInfo, "txtProductVersion" ).setTextContent( setup.getVersion() );
99+
getOrCreateChild( versionInfo, "fileVersion" ).setTextContent( normalizeVersionNumber( task.getVersion() ) );
100+
getOrCreateChild( versionInfo, "txtFileVersion" ).setTextContent( task.getVersion() );
101+
getOrCreateChild( versionInfo, "productVersion" ).setTextContent( normalizeVersionNumber( task.getVersion() ) );
102+
getOrCreateChild( versionInfo, "txtProductVersion" ).setTextContent( task.getVersion() );
103103
getOrCreateChild( versionInfo, "fileDescription" ).setTextContent( launch.getDescription() );
104104
getOrCreateChild( versionInfo, "productName" ).setTextContent( setup.getApplication() );
105105
getOrCreateChild( versionInfo, "companyName" ).setTextContent( setup.getVendor() );

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@
2121
import org.w3c.dom.Element;
2222

2323
import com.inet.gradle.setup.SetupBuilder;
24-
import com.inet.gradle.setup.abstracts.DesktopStarter;
2524
import com.inet.gradle.setup.util.XmlFileBuilder;
2625

2726
/**
2827
* Create a XML configuration file for lauch4j.
29-
*
28+
*
3029
* @author Volker
3130
*/
3231
class Launch4jManifest extends XmlFileBuilder<Msi> {
@@ -35,7 +34,7 @@ class Launch4jManifest extends XmlFileBuilder<Msi> {
3534

3635
/**
3736
* Create a instance.
38-
*
37+
*
3938
* @param launch the launch description
4039
* @param task current task
4140
* @param setup the SetupBuilder
@@ -48,7 +47,7 @@ class Launch4jManifest extends XmlFileBuilder<Msi> {
4847

4948
/**
5049
* Create the XML file.
51-
*
50+
*
5251
* @throws IOException if an error occurs on reading the image files
5352
*/
5453
void build() throws IOException {
@@ -57,7 +56,7 @@ void build() throws IOException {
5756
addAttributeIfNotExists( assembly, "manifestVersion", "1.0" );
5857

5958
Element identity = getOrCreateChild( assembly, "assemblyIdentity" );
60-
addAttributeIfNotExists( identity, "version", Launch4jConfig.normalizeVersionNumber( setup.getVersion() ) );
59+
addAttributeIfNotExists( identity, "version", Launch4jConfig.normalizeVersionNumber( task.getVersion() ) );
6160
addAttributeIfNotExists( identity, "processorArchitecture", "X86" );
6261
addAttributeIfNotExists( identity, "name", launch.getDisplayName() );
6362
addAttributeIfNotExists( identity, "type", "win32" );

0 commit comments

Comments
 (0)