////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you 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

https://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.
////


==== Publishing Profiles

To mark a profile project for publishing, you need to apply the `grails-profile-publish` plugin:

[source,groovy]
----
apply plugin: "org.apache.grails.gradle.grails-publish-profile"
----

To publish a profile using this plugin to the Grails central repository first upload the source to https://github.com[Github] (closed source profiles will not be accepted). Then register for an account on https://central.sonatype.com/[Maven Central] and configure your keys as follows in the profile's `build.gradle` file:

[source,groovy]
----
grailsPublish {
        githubSlug = 'foo/bar'
        license {
            name = 'Apache-2.0'
        }
        title = 'My profile title'
        desc = 'My profile description'
        developers = [johndoe: 'John Doe']
    }
----

NOTE: The `githubSlug` argument should point to the path to your Github repository. For example if your repository is located at https://github.com/apache/grails-core then your `githubSlug` is `apache/grails-core`

Environment variables control where the profile is published.  By default, this plugin will publish to the specified `MAVEN_PUBLISH` instance for snapshots, and `NEXUS_PUBLISH` for releases.  To change the snapshot publish behavior, set `snapshotRepoType` to `PublishType.NEXUS_PUBLISH`. To change the release publish behavior, set `releaseRepoType` to `PublishType.MAVEN_PUBLISH`.

The credentials and connection url must be specified as a project property or an environment variable.

`MAVEN_PUBLISH` Environment Variables are:

    MAVEN_PUBLISH_USERNAME
    MAVEN_PUBLISH_PASSWORD
    MAVEN_PUBLISH_URL

`NEXUS_PUBLISH` Environment Variables are:

    NEXUS_PUBLISH_USERNAME
    NEXUS_PUBLISH_PASSWORD
    NEXUS_PUBLISH_URL
    NEXUS_PUBLISH_SNAPSHOT_URL
    NEXUS_PUBLISH_STAGING_PROFILE_ID

By default, the release or snapshot state is determined by the `project.version` or `projectVersion` gradle property.  To override this behavior, use the environment variable `GRAILS_PUBLISH_RELEASE` to decide if it's a release or snapshot.

With these environment variables in place you can run `gradle publish` to publish your profile:

[source,bash]
----
$ gradle publish
----

The profile will be uploaded to the specified location based on whether the version is a snapshot or release.

