Home > Software design >  Why gradle not use my specified maven settings.xml?
Why gradle not use my specified maven settings.xml?

Time:02-21

My maven settings.xml is as follows. As you can see, there is no http repository url. All repository url is started with https.

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <mirrors>
        <mirror>
            <id>mirror</id>
            <mirrorOf>central,jcenter,!rdc-releases,!rdc-snapshots</mirrorOf>
            <name>mirror</name>
            <url>https://maven.aliyun.com/nexus/content/groups/public</url>
        </mirror>

    </mirrors>
    <servers>
        <server>
            <id>rdc-releases</id>
            <username>myUserName</username>
            <password>myPwd</password>
        </server>
        <server>
            <id>rdc-snapshots</id>
            <username>myUserName</username>
            <password>myPwd</password>
        </server>
    </servers>
    <profiles>
        <profile>
            <id>rdc</id>
            <properties>
                <altReleaseDeploymentRepository>
                    rdc-releases::default::https://packages.aliyun.com/maven/repository/2012878-release-sX3W6A/
                </altReleaseDeploymentRepository>
                <altSnapshotDeploymentRepository>
                    rdc-snapshots::default::https://packages.aliyun.com/maven/repository/2012878-snapshot-wXHWRP/
                </altSnapshotDeploymentRepository>
            </properties>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>https://maven.aliyun.com/nexus/content/groups/public</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
                <pluginRepository>
                    <id>snapshots</id>
                    <url>https://maven.aliyun.com/nexus/content/groups/public</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
                <pluginRepository>
                    <id>rdc-releases</id>
                    <url>https://packages.aliyun.com/maven/repository/2012878-release-sX3W6A/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
                <pluginRepository>
                    <id>rdc-snapshots</id>
                    <url>https://packages.aliyun.com/maven/repository/2012878-snapshot-wXHWRP/</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>rdc</activeProfile>
    </activeProfiles>
</settings>

When I execute gradle build, it says I use insecure protocol. In fact, I never use http protocol in my maven settings.xml. We can see that all repository url is started with 'https://'. Can any one give me some advice ?

## Exception is 
> Task :buildSrc:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':buildSrc:compileJava'.
> Could not resolve all dependencies for configuration ':buildSrc:compileClasspath'.
   > Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.aliyun.com/nexus/content/groups/public)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.4/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details. 


My gradle version is 7.4 and part of the build.gradle is as follows. It is a multi module project. I give one module gradle setting as an example.

settings.gradle

/*
 * This file was generated by the Gradle 'init' task.
 */

rootProject.name = 'clougence-schema-parent'

include(':clougence-utils')

build.gradle of module clougence-utils

/*
 * This file was generated by the Gradle 'init' task.
 */

plugins {
    id 'com.clougence.java-conventions'
}

description = 'clougence-utils'

groovy scrips

/*
 * This file was generated by the Gradle 'init' task.
 */

plugins {
    id 'java-library'
    id 'maven-publish'
}

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    compileOnly 'org.slf4j:slf4j-api:1.7.30'
    compileOnly 'org.projectlombok:lombok:1.18.20'

    annotationProcessor 'org.projectlombok:lombok:1.18.20'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.20'

    testCompileOnly 'org.projectlombok:lombok:1.18.20'

    testImplementation 'com.alibaba:druid:1.2.6'
    testImplementation 'junit:junit:4.12'
    testImplementation 'net.hasor:hasor-db:4.3.0'
    testImplementation 'com.alibaba:druid:1.2.6'
}

group = 'com.clougence'
version = '1.0.12-SNAPSHOT'
java.sourceCompatibility = JavaVersion.VERSION_1_8

publishing {
    publications {
        maven(MavenPublication) {
            from(components.java)
        }
    }
}

CodePudding user response:

I find answer myself. I used to config ~/.gradle/init.gradle and set a http url which force gradle to use that insecure repository

  • Related