Skip to content

Commit

Permalink
Stop applying the java plugin automatically.
Browse files Browse the repository at this point in the history
Require the user to apply either the java plugin or the android plugin
first, so that he has a choice between them.

Resolves #11
  • Loading branch information
zhangkun83 committed Jun 22, 2015
1 parent de66162 commit c9f0f69
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ com.google.protobuf:protobuf-gradle-plugin:0.4.1 - Available on Maven Central.
To use the protobuf plugin, include in your build script:

```groovy
// For Java project, you must apply the java plugin first.
apply plugin: 'java'
// Or, for Android project, apply the Android plugin first.
// apply plugin: 'com.android.application'
apply plugin: 'com.google.protobuf'
buildscript {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ class ProtobufPlugin implements Plugin<Project> {
println("You are using Gradle ${project.gradle.gradleVersion}: This version of the protobuf plugin requires minimum Gradle version 2.2")
}

project.apply plugin: 'java'
if (!project.plugins.hasPlugin('java')
&& !project.plugins.hasPlugin('com.android.application')) {
throw new GradleException(
'Please apply the \'java\' plugin or the \'com.android.application\' plugin first')
}

// Provides the osdetector extension
project.apply plugin: 'osdetector'

Expand Down
2 changes: 1 addition & 1 deletion testProject/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
classpath "com.google.protobuf:protobuf-gradle-plugin:${rootProject.version}"
}
}

apply plugin: 'java'
apply plugin: 'com.google.protobuf'

repositories {
Expand Down
2 changes: 1 addition & 1 deletion testProjectCustomProtoDir/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
classpath "com.google.protobuf:protobuf-gradle-plugin:${rootProject.version}"
}
}

apply plugin: 'java'
apply plugin: 'com.google.protobuf'

repositories {
Expand Down

0 comments on commit c9f0f69

Please sign in to comment.