Maven-publish plugin doesn't work with Gradle 4.0-rc-1

Build fails with the following error:

A problem occurred configuring project ':android-standalone'.
> Could not resolve all dependencies for configuration ':android-standalone:alphaReleaseRuntimeClasspath'.
    > Exception thrown while executing model rule: PublishingPlugin.Rules#publishing(ExtensionContainer)
        > Could not get unknown property 'java' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

In the build file, this happens in the following block:

publishing {
    ...

    publications {
        libraryJar(MavenPublication) {
            def name = 'library'
            from project(":$name").components.java

The error suggests that components.java can’t be resolved, in fact, when I log “components” I get “[]”. This works fine with Gradle 3.5.

Sorry, I just noticed that I’d better create an issue on Github. Can’t find how to delete the thread.