Publishing in Gradle 5 migrating from 4.9

am currently trying to upgrade my gradle wrapper from 4.9 to 5.3.1 and my publishToMavenLocal is no longer working. I knew this was going to happen from the release note but I cannot figure out how to get back to a functioning level. How can I get publish working in Gradle 5 with the code below?

I have added the Gradle recommend afterEvaluate {} block inside my code. I have tried in three different locations, which are the (#) in the code below.

//Code Block

publishing {
    publications {
        // Publish the Android Archive and Javadoc (zip) all at once
        //   To publish javadocs with archive, add the line: 'artifact androidJavadocsZip' below the library variants loop

            androidArchive(MavenPublication) {
                artifacts {
                    description 'Configuration Cleaner android archive'
                    groupId 'fda dp22'
                    artifactId 'Cleaner'
                    version version
                    afterEvaluate {
                    android.libraryVariants.all { variant ->
                        variant.outputs.each { output ->
                            if (variant.name == "release" && output.name == "release") {
                                artifact output.outputFile
                            } else {
                                logger.debug("Skipping Output " + output.name + " of type " + variant.name + ".")
                            }
                        }
                    }

                    artifact androidJavadocsZip
                    artifact androidJavadocsJar
                }
            }
        }
    }
}