Publish plugin error

I’m trying to publish my plugin with gradle’s publishing plugin (com.gradle.plugin-publish), but I’m getting a rather inscrutable error when invoking the publishPlugins target:

Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
    at org.apache.tools.ant.util.LayoutPreservingProperties.removeCommentsEndingAt(LayoutPreservingProperties.java:599)
    at org.apache.tools.ant.util.LayoutPreservingProperties.remove(LayoutPreservingProperties.java:198)
    at org.apache.tools.ant.util.LayoutPreservingProperties.readLines(LayoutPreservingProperties.java:359)
    at org.apache.tools.ant.util.LayoutPreservingProperties.load(LayoutPreservingProperties.java:142)
    at com.gradle.publish.LoginTask.loadProperties(LoginTask.java:57)
    at com.gradle.publish.PublishTask.buildOAuthClient(PublishTask.java:345)
    at com.gradle.publish.PublishTask.doSignedPost(PublishTask.java:291)
    at com.gradle.publish.PublishTask.publishToPortal(PublishTask.java:174)
    at com.gradle.publish.PublishTask.publish(PublishTask.java:54)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:226)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 60 more

The build.gradle is here.

Hi Aaron

This looks like a bug in a component that we’re using in the publishing plugin. We’ll investigate a solution and get back to you.

Cheers

Tom

@paleozogt Which version of gradle are you using and what operating system are you running on? I suspect that this may be something specific to the properties files on your environment. Do you have a properties file at ~/.gradle/gradle.properties and if you do, could you share it (if it’s not sensitive) or try removing properties from that file to see if it makes any difference.

One scenario which causes this is a properties file with duplicates and one of those duplicates appears at the top of a properties file i.e. the properties file does not begin with a comment or a new line.

e.g.

a=1```

I added a newline to the top of my ~/.gradle/gradle.properties file and that fixed it right up. I would have never guessed that was the issue.

This has been fixed in version 0.9.3