Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore compatibility with artifactory/bintray plugins
The artifactory and bintray plugins resolve all publications in an afterEvaluate hook. This is not a good idea, but what we have to work with at the moment. We now only use afterEvaluate {} when the stable publishing feature is enabled and otherwise rely on the deferred configurable behavior instead.
- Loading branch information
Showing
3 changed files
with
151 additions
and
20 deletions.
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
.../gradle/plugin/devel/plugins/JavaGradlePluginLegacyPluginPublishingIntegrationTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright 2018 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. | ||
*/ | ||
|
||
package org.gradle.plugin.devel.plugins | ||
|
||
import org.gradle.integtests.fixtures.AbstractIntegrationSpec | ||
|
||
class JavaGradlePluginLegacyPluginPublishingIntegrationTest extends AbstractIntegrationSpec { | ||
|
||
def setup() { | ||
buildFile << """ | ||
apply plugin: 'java-gradle-plugin' | ||
group = 'com.example' | ||
version = '1.0' | ||
""" | ||
settingsFile << """ | ||
rootProject.name = 'plugins' | ||
""" | ||
} | ||
|
||
def "can resolve plugin publications in an afterEvaluate hook"() { | ||
given: | ||
plugin('foo', 'com.example.foo') | ||
publishToIvy() | ||
publishToMaven() | ||
buildFile << """ | ||
afterEvaluate { | ||
assert publishing.publications.size() == 4 | ||
} | ||
""" | ||
executer.expectDeprecationWarning() | ||
|
||
expect: | ||
succeeds 'help' | ||
} | ||
def publishToMaven() { | ||
buildFile << """ | ||
apply plugin: 'maven-publish' | ||
publishing { | ||
repositories { | ||
maven { | ||
url '${mavenRepo.uri}' | ||
} | ||
} | ||
} | ||
""" | ||
} | ||
|
||
def publishToIvy() { | ||
buildFile << """ | ||
apply plugin: 'ivy-publish' | ||
publishing { | ||
repositories { | ||
ivy { | ||
url '${ivyRepo.uri}' | ||
} | ||
} | ||
} | ||
""" | ||
} | ||
|
||
def plugin(String name, String pluginId) { | ||
String implementationClass = name.capitalize(); | ||
|
||
file("src/main/java/com/xxx/${implementationClass}.java") << """ | ||
package com.xxx; | ||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
public class ${implementationClass} implements Plugin<Project> { | ||
public void apply(Project project) { } | ||
} | ||
""" | ||
buildFile << """ | ||
gradlePlugin { | ||
plugins { | ||
${name} { | ||
id = '${pluginId}' | ||
implementationClass = '${implementationClass}' | ||
} | ||
} | ||
} | ||
""" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters