2

In Liferay Developer Studio 3.1.2 I created a "New > Liferay Workspace Project".

Inside it, I created a "New > Liferay Module Project".

Here is how it looks:

enter image description here

Problem: There is no Gradle right-click menu on the module project.

When running Gradle from command line I get:

$ gradle --version

------------------------------------------------------------
Gradle 4.3.1
------------------------------------------------------------

Build time:   2017-11-08 08:59:45 UTC
Revision:     e4f4804807ef7c2829da51877861ff06e07e006d

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_151 (Oracle Corporation 25.151-b12)
OS:           Linux 4.4.0-101-generic amd64

$ gradle build
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* Where:
Build file '/home/nico/training-workspace/training/modules/doc-media-fragment/build.gradle' line: 2

* What went wrong:
A problem occurred evaluating root project 'doc-media-fragment'.
> Could not find method compileOnly() for arguments [{group=org.osgi, name=org.osgi.core, version=6.0.0}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

What did I do wrong?
How to fix the problem?

The build.gradle at the root of the Liferay workspace is empty, and below is the build.gradle at the root of the Liferay module:

dependencies {
    compileOnly group: "org.osgi", name: "org.osgi.core", version: "6.0.0"
    compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
}
Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
  • can you paste your build.gradle – Rajesh Nov 27 '17 at 08:52
  • also is there settings.gradle under training folder? – Rajesh Nov 27 '17 at 08:57
  • @Rajesh: Added. By the way, creating another Liferay Workspace solved the problem, but I am not sure whether that qualifies as a solution? – Nicolas Raoul Nov 27 '17 at 10:23
  • ideally there should be settings.gradle at root workspace. Also you can try using "blade gw deploy" instead of "gradle build" – Rajesh Nov 27 '17 at 10:41
  • @Rajesh: I don't have a `settings.gradle` at the root of the Liferay workspace. I just tried executing `blade gw deploy`, it said `gradlew: Permission denied` and generated a few files including `settings.gradle`. – Nicolas Raoul Nov 27 '17 at 15:05
  • settings.gradle typically contain the minimal liferay gradle plugin to execute build and deploy liferay modules. I've pasted this in answer. Also give permission to your gradlew in liferay workspace root. chmod 777 training/gradlew – Rajesh Nov 27 '17 at 18:36

2 Answers2

10

You can fix this by navigating to node_modules/react-native-maps/lib/android/build.gradle and changing these lines

compileOnly "com.facebook.react:react-native:+"
implementation "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
implementation "com.google.android.gms:play-services-maps:$googlePlayServicesVersion"
implementation "com.google.maps.android:android-maps-utils:$androidMapsUtilsVersion"

to

provided "com.facebook.react:react-native:+"
compile "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
compile "com.google.android.gms:play-services-maps:$googlePlayServicesVersion"
compile "com.google.maps.android:android-maps-utils:$androidMapsUtilsVersion"

and see if the project builds.

2

Create settings.gradle and add following.

buildscript {
  dependencies {
      classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "1.5.0"
      classpath group: "net.saliman", name: "gradle-properties-plugin", version: "1.4.6"
      classpath group: "com.liferay", name: "com.liferay.gradle.plugins", version: "latest.release"
  }

  repositories {
      maven {
          url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"
      }
  }
}

apply plugin: "net.saliman.properties"

apply plugin: "com.liferay.workspace"

settings.gradle typically contain the minimal liferay gradle plugin to execute build and deploy liferay modules. I've pasted this in answer. Also give permission to your gradlew in liferay workspace root. chmod 777 training/gradlew

Rajesh
  • 400
  • 3
  • 7