Why aren't my dependencies written into the exported pom.xml?

(h.renken) #1

Hi, i have a simple build script that should write a pom.xml with dependencies. However, the dependencies are not contained in the pom. This is probably due to the fact, that the default configuration is written to disk. However, i tried the suggestion from the ‘Example 52.4. Upload of file via SSH’ from the user guide, but this does seem to not work either. Here is the build script plus the written pom that is missing the dependencies:

apply plugin: 'maven'
  group = 'my.company'
version = 1.0
  repositories {
 archives (group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.4+')
 archives (group: 'ch.qos.logback', name: 'logback-classic', version: '1.1+')
 archives (group: 'net.sf.trove4j', name: 'trove4j', version: '3.+')
  task writePom << {
 pom {
  configurations = project.configurations

And the written pom:

<?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"

How can i configure the pom to include the three dependencies defined in the ‘archives’ configuration? I already tried a custom configuration name, but that also didn’t work. I also tried to convert the configuration dependencies to maven dependencies, but i didn’t get anywhere near functioning code.

Thx in advance.

(Justin Ryan) #2

You’re adding your dependencies to the archives configuration, while what you probably want is the compile configuration. Change your dependencies to read more list this:

    compile (group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.4+')
    compile (group: 'ch.qos.logback', name: 'logback-classic', version: '1.1+')
    compile (group: 'net.sf.trove4j', name: 'trove4j', version: '3.+')

(h.renken) #3

That didn’t solve anything. Please note, that i do only apply the maven plugin to be able to use the pom object (and not the java plugin or anything else). That also means, that i have to create the compile configuration by myself - i also tried it with a configuration with the name ‘runtime’. That didn’t work either.

Kind regards.