0
votes

I wrote a gradle script where I am creating the zip and war file and then I need to upload/publish it to the artifactory but the issue is I specified the war file in my artifact task even after that it is publishing everything to the artifactory zip,tar and war instead of only war file.

apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'distribution'

//-- set the group for publishing
group = 'com.xxx.discovery'

/**
 * Initializing GAVC settings
 */
def buildProperties = new Properties()
file("version.properties").withInputStream { 
    stream -> buildProperties.load(stream) 
} 
//add the jenkins build version to the version
def env = System.getenv()
if (env["BUILD_NUMBER"]) buildProperties.coveryadBuildVersion += "_${env["BUILD_NUMBER"]}"
version = buildProperties.coveryadBuildVersion
println "${version}"

//name is set in the settings.gradle file
group = "com.aaa.covery"
version = buildProperties.discoveryadBuildVersion
println "Building ${project.group}:${project.name}:${project.version}"

  repositories {
    maven {
      url "http://cxxxxt.tshaaaaa.tho.com:9000/artifactory/libselease"
    }
    maven {
      url "http://cxxxxt.tshaaa.tho.com:9000/artifactory/cache"
    }
  }

dependencies {
    compile ([
    "com.uters.omni:HermesSessionAPI:1.2",
    "com.uters.proxy:ProxyResources:1.1",
    "com.uters.omni:SeshataDirectory:1.0.1" ,
    "com.euters.omni:CybeleInfrastructure:1.1.2",
    "com.euters:JSONBus:1.4.1",
    "javaee:javaee-api:5"
    ])
}

distributions {
  main { 
    contents { 
      from {
        war.outputs
        }
      }
  }
}

// for publishing to artifactory
artifacts {
  archives war
}
1
Is it your full script? It seems like some parts of it are missing (e.g. the publishArchives configuration, the ZIP/TAR creation, etc.). - Amnon Shochot
yeah this is my complete script basically distrubiton plugin created the zip and tar file.I am using the war file which basically creates the war file - unknown

1 Answers

0
votes

According to gradle distribution plugin documentation:

All of the files in the “src/$distribution.name/dist” directory will automatically be included in the distribution.

And also,

The distribution plugin adds the distribution archives as candidate for default publishing artifacts.

In other words, by default all the files will be published so this explains the behavior you're experiencing.

What you can probably do in order to workaround this behavior is to define the contents copySpec more accurately by explicitly exclude the unwanted files, i.e.:

distributions {
  main { 
    contents { 
      exclude('**/.zip')
      exclude('**/.tar')
      from {
        war.outputs
      }
    }
  }
}

Note that I didn't try the above by myself though so some fine tuning might be needed. However I believe that you can find the data you need in the CopySpec Interface documentation