crotwell / gradle-macappbundle

A Gradle Plugin to create a Mac OSX .app application and dmg based on the project.
Apache License 2.0
95 stars 33 forks source link

Customise plist #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is a nice plugin, but we need to customise the plist beyond what you have 
hooks for. Is there a way to do that? Or can we substitute our own plist file?

Original issue reported on code.google.com by aristede...@gmail.com on 7 Sep 2012 at 4:05

GoogleCodeExporter commented 9 years ago
Do you want to change values already in the plist or just add additional ones? 
I can probably accommodate either, but can you be more specific about which 
parts of the plist you want to change? 

If there are additional things that would be commonly useful, I could certainly 
add them to the configuration.

If you want to modify the plist file you can do that with the existing version 
by adding a "doLast" to the generatePlist task.  Something like:

generatePlist.doLast {
   def plistFile = project.macAppBundle.getPlistFileForProject(project)
   // do something to pListFile like
   plistFile.append("   Howdy   ")
}

Original comment by crotwell@seis.sc.edu on 7 Sep 2012 at 1:22

GoogleCodeExporter commented 9 years ago
Thanks for that. What we wanted to do was add a CFBundle section to identify 
documents for our application. For example:

<array>
      <dict>
        <key>CFBundleTypeName</key>
        <string>onCourse server data file</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleTypeIconFile</key>
        <string>onCourseDocument.icns</string>
        <key>CFBundleTypeExtensions</key>
        <array>
          <string>iocdata</string>
        </array>
        <key>CFBundleTypeOSTypes</key>
        <array>
          <string>ishS</string>
        </array>
        <key>LSTypeIsPackage</key>
        <string>true</string>
      </dict>
    </array>

Original comment by aristede...@gmail.com on 10 Sep 2012 at 12:11

GoogleCodeExporter commented 9 years ago
I have pushed changes to allow an "extras" in the plugin extension that I think 
will allow you to do this. An example is below. Note it is up to you to make 
sure the xml is correct, no checking is done by the plugin.

I will release a new version shortly.

macAppBundle {
    mainClassName = "edu.example.myproj.Start"
    dmgName = "MyProj-${project.version}"
    extras = """
<key>OtherStuff</key>
<array>
      <dict>
        <key>CFBundleTypeName</key>
        <string>onCourse server data file</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleTypeIconFile</key>
        <string>onCourseDocument.icns</string>
        <key>CFBundleTypeExtensions</key>
        <array>
          <string>iocdata</string>
        </array>
        <key>CFBundleTypeOSTypes</key>
        <array>
          <string>ishS</string>
        </array>
        <key>LSTypeIsPackage</key>
        <string>true</string>
      </dict>
    </array>
 """
}

Original comment by crotwell@seis.sc.edu on 10 Sep 2012 at 3:37