Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is 'gradle install' replacing my version with 'unspecified'?

I am having a real problem with my Gradle build and was hoping someone could lend a 2nd set of eyes. Here's my build.grade:

apply plugin: 'groovy'
apply plugin: 'maven'

group = 'myorg'

task createPom << {
    pom {
        project {
            groupId 'myorg'
            artifactId 'mylib'
            version '6.0'

            inceptionYear '2015'
            licenses {
                license {
                    name 'The Apache Software License, Version 2.0'
                    url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                }
            }
        }
    }.writeTo("pom.xml")
}

Here's my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>myorg</groupId>
    <artifactId>mylib</artifactId>
    <version>6.0</version>

    <inceptionYear>2015</inceptionYear>
    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>
</project>

When I run gradle install, Gradle 'installs' this JAR/POM under:

~/.m2/repository/com/myorg/mylib/unspecified/
    mylib-unspecified.jar
    mylib-unspecified.pom

Whereas, I would have expected:

~/.m2/repository/com/myorg/mylib/6.0/
    mylib-6.0.jar
    mylib-6.0.pom

What is this 'unspecified' business, and where am I going awry?

like image 334
smeeb Avatar asked Dec 20 '15 02:12

smeeb


1 Answers

Apparently the version in the pom is not used in the install task. Try to specify the version on project level next to the group like this:

group = 'myorg'
version = '6.0'
like image 191
Henry Avatar answered Sep 28 '22 04:09

Henry