0

Maven file excerpt:

dependencies { compile project(':something:com.example.util') runtime project(':something:com.example.util') } apply plugin: 'maven' task writeNewPom() { doLast { pom { project { } }.writeTo("$buildDir/resources/main/META-INF/maven/${project.group}/${project.name}/pom.xml") } } tasks.jar.dependsOn writeNewPom 

I would expect that the generated pom.xml has dependencies with scopes compile and runtime, but I'm only getting the compile scope:

<?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>something</groupId> <artifactId>com.example.foo</artifactId> <version>0.0.1</version> <dependencies> <dependency> <groupId>something</groupId> <artifactId>com.example.util</artifactId> <version>0.0.1</version> <scope>compile</scope> </dependency> </dependencies> </project> 

How do I get both scopes? Or, if I can't, how can I get the runtime scope which is more important for my use case?

11
  • I cannot really read Gradle, but in Maven, having more than one scope for a giving dependency is not possible (i.e. two <dependency> entries with different scopes for the same artifact make no sense). Commented Nov 11, 2019 at 19:12
  • How do you express that you need B.jar to compile the stuff that goes into A.jar, and that you have no hope to run A.jar without also having B.jar? (Or should the definition of "compile" also imply "runtime"?) Commented Nov 11, 2019 at 19:14
  • 1
    compile includes runtime. compile scope artifacts are available for compilation, test and at runtime. Commented Nov 11, 2019 at 19:21
  • Since both dependencies are the same, it might already be working? Commented Nov 11, 2019 at 20:09
  • Actually, it's the other way around: runtime includes compile. Nice graphic on this and explanations in the docs (scroll down a little for the illustration). Commented Nov 12, 2019 at 8:10

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.