Skip to content

Commit

Permalink
Merge pull request #382 from Dexterp37/pom_dependencies
Browse files Browse the repository at this point in the history
Add 'jnaTest' dependencies to the 'forUnitTest' JAR
  • Loading branch information
Dexterp37 authored Oct 17, 2019
2 parents 4c002ba + 4ebdb7a commit 57340ef
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ def libProjectName = properties.libProjectName
def libUrl = properties.libUrl
def libVcsUrl = properties.libVcsUrl

// The note to be added at the end of the description for 'forUnitTests'
// artifacts.
def forUnitTestDescriptionSuffix =
"This artifact is to be used for running unit tests on developer's systems."

// `jnaForTestConfiguration` is a hacky way to say yes, I'm using JNA and want
// to pack the JNA dispatch libraries and my Rust libraries into a single JAR
// for use in unit tests that run on a development host (and not an Android
Expand Down Expand Up @@ -118,7 +123,7 @@ ext.configurePublish = { jnaForTestConfiguration = null ->
pom {
groupId = theGroupId
artifactId = "${theArtifactId}-forUnitTests"
description = theDescription
description = theDescription + " " + forUnitTestDescriptionSuffix
version = rootProject.ext.library.version
packaging = "jar"

Expand All @@ -143,6 +148,20 @@ ext.configurePublish = { jnaForTestConfiguration = null ->
}
}

pom.withXml {
// The 'forUnitTest' JAR, used to run unit tests on the host system,
// needs to declare any dependency it requires (e.g. JNA).
def dependenciesNode = asNode().appendNode("dependencies")
configurations["jnaForTest"].allDependencies.forEach {
if (it.group != null) {
def dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", it.group)
dependencyNode.appendNode("artifactId", it.name)
dependencyNode.appendNode("version", it.version)
}
}
}

// This is never the publication we want to use when publishing a
// parent project with us as a child `project()` dependency.
alias = true
Expand Down

0 comments on commit 57340ef

Please sign in to comment.