From 42d0f3ea83192b210431ceed7ed586dd4fed5d56 Mon Sep 17 00:00:00 2001 From: Cedric Champeau Date: Fri, 17 Feb 2017 09:58:04 +0100 Subject: [PATCH] Add section about configuring the Groovy plugin to wire dependencies correctly --- .../src/docs/userguide/javaLibraryPlugin.xml | 13 ++++++++ .../java-library/with-groovy/a/build.gradle | 33 +++++++++++++++++++ .../with-groovy/a/src/main/groovy/B.groovy | 18 ++++++++++ .../with-groovy/a/src/main/java/A.java | 17 ++++++++++ .../java-library/with-groovy/b/build.gradle | 21 ++++++++++++ .../with-groovy/b/src/main/java/C.java | 17 ++++++++++ .../java-library/with-groovy/settings.gradle | 17 ++++++++++ 7 files changed, 136 insertions(+) create mode 100644 subprojects/docs/src/samples/java-library/with-groovy/a/build.gradle create mode 100644 subprojects/docs/src/samples/java-library/with-groovy/a/src/main/groovy/B.groovy create mode 100644 subprojects/docs/src/samples/java-library/with-groovy/a/src/main/java/A.java create mode 100644 subprojects/docs/src/samples/java-library/with-groovy/b/build.gradle create mode 100644 subprojects/docs/src/samples/java-library/with-groovy/b/src/main/java/C.java create mode 100644 subprojects/docs/src/samples/java-library/with-groovy/settings.gradle diff --git a/subprojects/docs/src/docs/userguide/javaLibraryPlugin.xml b/subprojects/docs/src/docs/userguide/javaLibraryPlugin.xml index 9df8629323e2..44be85c66a8d 100644 --- a/subprojects/docs/src/docs/userguide/javaLibraryPlugin.xml +++ b/subprojects/docs/src/docs/userguide/javaLibraryPlugin.xml @@ -272,4 +272,17 @@ +
+ Known issues +
+ Compatibility with other plugins + At the moment the Java Library plugin is only wired to behave correctly with the java plugin. Other plugins, such as + the Groovy plugin, may not behave correctly. In particular, if the Groovy plugin is used in addition to the java-library plugin, + then consumers may not get the Groovy classes when they consume the library. To workaround this, you need to explicitly wire the Groovy compile + dependency, like this: + + + +
+
diff --git a/subprojects/docs/src/samples/java-library/with-groovy/a/build.gradle b/subprojects/docs/src/samples/java-library/with-groovy/a/build.gradle new file mode 100644 index 000000000000..a0e933d01096 --- /dev/null +++ b/subprojects/docs/src/samples/java-library/with-groovy/a/build.gradle @@ -0,0 +1,33 @@ +/* + * Copyright 2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +apply plugin: 'java-library' +apply plugin: 'groovy' + +dependencies { + compile localGroovy() +} + +// START SNIPPET configure-groovy +configurations { + apiElements { + outgoing.variants.getByName('classes').artifact( + file: compileGroovy.destinationDir, + type: JavaPlugin.CLASS_DIRECTORY, + builtBy: compileGroovy) + } +} +// END SNIPPET configure-groovy diff --git a/subprojects/docs/src/samples/java-library/with-groovy/a/src/main/groovy/B.groovy b/subprojects/docs/src/samples/java-library/with-groovy/a/src/main/groovy/B.groovy new file mode 100644 index 000000000000..b722f9dd0147 --- /dev/null +++ b/subprojects/docs/src/samples/java-library/with-groovy/a/src/main/groovy/B.groovy @@ -0,0 +1,18 @@ +/* + * Copyright 2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class B {} + diff --git a/subprojects/docs/src/samples/java-library/with-groovy/a/src/main/java/A.java b/subprojects/docs/src/samples/java-library/with-groovy/a/src/main/java/A.java new file mode 100644 index 000000000000..3abbcb393597 --- /dev/null +++ b/subprojects/docs/src/samples/java-library/with-groovy/a/src/main/java/A.java @@ -0,0 +1,17 @@ +/* + * Copyright 2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +public class A {} + diff --git a/subprojects/docs/src/samples/java-library/with-groovy/b/build.gradle b/subprojects/docs/src/samples/java-library/with-groovy/b/build.gradle new file mode 100644 index 000000000000..d1d9b997fdc4 --- /dev/null +++ b/subprojects/docs/src/samples/java-library/with-groovy/b/build.gradle @@ -0,0 +1,21 @@ +/* + * Copyright 2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +apply plugin: 'java' + +dependencies { + implementation project(':a') +} diff --git a/subprojects/docs/src/samples/java-library/with-groovy/b/src/main/java/C.java b/subprojects/docs/src/samples/java-library/with-groovy/b/src/main/java/C.java new file mode 100644 index 000000000000..988e88245ca0 --- /dev/null +++ b/subprojects/docs/src/samples/java-library/with-groovy/b/src/main/java/C.java @@ -0,0 +1,17 @@ +/* + * Copyright 2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public class C {} diff --git a/subprojects/docs/src/samples/java-library/with-groovy/settings.gradle b/subprojects/docs/src/samples/java-library/with-groovy/settings.gradle new file mode 100644 index 000000000000..8aeadcd60a37 --- /dev/null +++ b/subprojects/docs/src/samples/java-library/with-groovy/settings.gradle @@ -0,0 +1,17 @@ +/* + * Copyright 2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +include 'a', 'b'