4

I am building a Kotlin/JS project that will be used as a library for a web app. The kotlin plugin recently enabled DCE and provides a keep directive, but it is not keeping the class I am specifying.

kotlin.target.browser {
dceTask {
    keep 'BluetoothSerialJs.com.fivestars.bluetooth.BluetoothSerial'
}
}

And here is the top of my class definition:

package com.fivestars.bluetooth



object BluetoothSerial {

Full project is here:

https://github.com/darran-kelinske-fivestars/cordova-alternative-pattern/blob/master/BluetoothSerialJs/build.gradle#L14

dazza5000
  • 7,075
  • 9
  • 44
  • 89

1 Answers1

6

I needed to specify the root project name with the keep definition:

CordovoaAlternativePattern is the root project name. The root project name is typically in settings.gradle

So the syntax needs to be:

RootProjectName-ModuleName.namespace.Class

Full example:

kotlin.target.browser {
    dceTask {
        keep  'CordovaAlternativePattern-BluetoothSerialJs.com.fivestars.bluetooth.BluetoothSerial'
    }
}
dazza5000
  • 7,075
  • 9
  • 44
  • 89