gradle - How to change artifactory runtime scope to compile scope? -


i working on project uses gradle , jfrog plugin publish artifactory. important code fragments these:

plugins {    id "java"    id "idea"    id "groovy"    id "pmd"    id "findbugs"    id "maven-publish"    id "com.jfrog.artifactory" version "3.1.1" }  dependencies {    compile 'com.google.guava:guava:18.0'    compile 'com.mashape.unirest:unirest-java:1.4.5'    compile 'log4j:log4j:1.2.14' }  artifactory {    contexturl = "https://some_server/artifactory"    publish {       repository {            repokey = 'libs-snapshot-local'            username = artifactory_username            password = artifactory_password            maven = true       }       defaults {            publications ('mavenjava')       }    } }  publishing {     publications {         mavenjava(mavenpublication) {             components.java         }     } } 

when gradle artifactorypublish seems work fine. artefacts published , pom file generated well.

regretfully dependencies in pom file have runtime 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>com.whatsoever</groupid>   <artifactid>some-app</artifactid>   <version>0.0.1-snapshot</version>   <dependencies>     <dependency>       <groupid>com.google.guava</groupid>       <artifactid>guava</artifactid>       <version>18.0</version>       <scope>runtime</scope>     </dependency>     <dependency>       <groupid>com.mashape.unirest</groupid>       <artifactid>unirest-java</artifactid>       <version>1.4.5</version>       <scope>runtime</scope>     </dependency>     <dependency>       <groupid>log4j</groupid>       <artifactid>log4j</artifactid>       <version>1.2.14</version>       <scope>runtime</scope>     </dependency>   </dependencies> </project> 

instead of runtime scope should have compile scope. doing wrong?

never tried on practive, can try use publication.pom.withxml configuration block introduce changes in generated pom:

publishing {     publications {         mavenjava(mavenpublication) {             components.java              pom.withxml {                 asnode().dependencies.'*'.findall() {                     it.scope.text() == 'runtime' && project.configurations.compile.alldependencies.find { dep ->                         dep.name == it.artifactid.text()                     }                 }.each() {                     it.scope*.value = 'compile'                 }             }         }     } } 

also, known limitation of new publishing plugin , found solution in this thread.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -