<commit_before>/*
 * Copyright 2011 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.integtests.publish.maven

import org.gradle.integtests.fixtures.HttpServer
import org.gradle.integtests.fixtures.MavenRepository
import org.gradle.integtests.fixtures.AbstractIntegrationSpec
import org.gradle.internal.SystemProperties
import org.gradle.util.TestFile
import org.junit.Rule
import org.junit.Test

/**
 * @author: <NAME>, created at: 6/16/11
 */
class MavenNewPublicationIntegrationTest extends AbstractIntegrationSpec {
    @Rule public final HttpServer server = new HttpServer()

    void "publishes snapshot to a local maven repository"() {
        given:
        file('build.gradle') << """
apply plugin: 'java'
apply plugin: 'maven'
new org.gradle.api.publication.PublicationPlugin().apply(project)

group = 'org.test'
archivesBaseName = 'someCoolProject'
version = '5.0-SNAPSHOT'

publications.maven.repository.url = '${repo().uri}'
"""

        when:
        executer.withTasks('publishArchives').run()

        then:
        def module = repo().module('org.test', 'someCoolProject', '5.0-SNAPSHOT')
        module.assertArtifactsPublished("someCoolProject-5.0-SNAPSHOT.jar", "someCoolProject-5.0-SNAPSHOT.pom")
    }

    @Test
    void "installs archives to local maven repo"() {
        given:
        file('build.gradle') << """
apply plugin: 'java'
apply plugin: 'maven'
new org.gradle.api.publication.PublicationPlugin().apply(project)

group = 'org.test'
archivesBaseName = 'someCoolProject'
version = '5.0-SNAPSHOT'

"""

        when:
        executer.withTasks('installArchives').run()

        then:
        def localRepo = new MavenRepository(new TestFile("$SystemProperties.userHome/.m2/repository"))
        def module = localRepo.module('org.test', 'someCoolProject', '5.0-SNAPSHOT')

        def files = module.moduleDir.list() as List
        assert files.contains('maven-metadata-local.xml')
        assert files.any { it =~ /someCoolProject-5.0-.*\.jar/ }
        assert files.any { it =~ /someCoolProject-5.0-.*\.pom/ }
    }

    void "publishes to remote maven repo"() {
        given:
        server.start()
        file('build.gradle') << """
apply plugin: 'java'
apply plugin: 'maven'
new org.gradle.api.publication.PublicationPlugin().apply(project)

group = 'org.test'
archivesBaseName = 'someCoolProject'
version = '5.0'

publications {
    maven {
        repository {
            url = 'http://localhost:${server.port}/repo'
            credentials {
                username = 'szczepiq'
                password = '<PASSWORD>'<commit_msg>Fixed broken int test.<commit_after>/*
 * Copyright 2011 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.integtests.publish.maven

import org.gradle.integtests.fixtures.HttpServer
import org.gradle.integtests.fixtures.MavenRepository
import org.gradle.integtests.fixtures.AbstractIntegrationSpec
import org.gradle.internal.SystemProperties
import org.gradle.util.TestFile
import org.junit.Rule
import org.junit.Test

/**
 * @author: <NAME>, created at: 6/16/11
 */
class MavenNewPublicationIntegrationTest extends AbstractIntegrationSpec {
    @Rule public final HttpServer server = new HttpServer()

    void "publishes snapshot to a local maven repository"() {
        given:
        file('build.gradle') << """
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: org.gradle.api.publication.PublicationPlugin

group = 'org.test'
archivesBaseName = 'someCoolProject'
version = '5.0-SNAPSHOT'

publications.maven.repository.url = '${repo().uri}'
"""

        when:
        executer.withTasks('publishArchives').run()

        then:
        def module = repo().module('org.test', 'someCoolProject', '5.0-SNAPSHOT')
        module.assertArtifactsPublished("someCoolProject-5.0-SNAPSHOT.jar", "someCoolProject-5.0-SNAPSHOT.pom")
    }

    @Test
    void "installs archives to local maven repo"() {
        given:
        file('build.gradle') << """
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: org.gradle.api.publication.PublicationPlugin

group = 'org.test'
archivesBaseName = 'someCoolProject'
version = '5.0-SNAPSHOT'

"""

        when:
        executer.withTasks('installArchives').run()

        then:
        def localRepo = new MavenRepository(new TestFile("$SystemProperties.userHome/.m2/repository"))
        def module = localRepo.module('org.test', 'someCoolProject', '5.0-SNAPSHOT')

        def files = module.moduleDir.list() as List
        assert files.contains('maven-metadata-local.xml')
        assert files.any { it =~ /someCoolProject-5.0-.*\.jar/ }
        assert files.any { it =~ /someCoolProject-5.0-.*\.pom/ }
    }

    void "publishes to remote maven repo"() {
        given:
        server.start()
        file('build.gradle') << """
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: org.gradle.api.publication.PublicationPlugin

group = 'org.test'
archivesBaseName = 'someCoolProject'
version = '5.0'

publications {
    maven {
        repository {
            url = 'http://localhost:${server.port}/repo'
            credentials {
                username = 'szczepiq'
                password = '<PASSWORD>'
{'fraction_non_alphanumeric': 0.12165178571428571, 'fraction_numerical': 0.01020408163265306, 'mean_word_length': 3.293634496919918, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3757406', 'n_tokens_mistral': 1931, 'n_tokens_neox': 1844, 'n_words': 483}