injecteer
injecteer

Reputation: 20717

Propper java-groovy interoperability: how?

I managed to integrate grooid into my plain android project, so it could compile, with all those lint, multidex magic (yes, I fixed 65k limit problem), and successfully run on a device

Then I created a src/main/groovy folder, moved one of my java activities into it and turned it to a groovy class:

package com.mypackage

@CompileStatic
class SplashActivity extends Activity {

  void onCreate( Bundle savedInstanceState ) {
    super.onCreate savedInstanceState
    contentView = R.layout.splash
  }
}

upon compiling, I get a compile errors like:

:app:compileDebugJavaWithJavac

AuthHelper.java:25: error: cannot find symbol

import com.mypackage.SplashActivity;

              ^

symbol: class SplashActivity

So, the groovy files must be somehow compiled before compile*JavaWithJavac.

How can this be done?

Upvotes: 1

Views: 237

Answers (1)

Pieces
Pieces

Reputation: 2295

If you place the java files into the groovy folder the groovy compiler will facilitate joint compilation.

You can also use the skipJavaC flag to get joint compilation as well see https://github.com/groovy/groovy-android-gradle-plugin#only-use-groovyc for more information.

Upvotes: 1

Related Questions