Defining custom ‘build’ task is deprecated when using standard lifecycle plugin has been deprecated and is scheduled to be removed in Gradle 3.0

时间:2015-05-04 19:21:47

标签: gradle build.gradle gradlew

I am facing an issue in my build.gradle script My script is bascially generatiing the POM file and then copy the artifact to other location as well under build/lib with different name.The issue which I am facing How to call the below build task beacuse it is generating the error.I am using gradle 2.3

Error:"Defining custom ‘build’ task is deprecated when using standard lifecycle plugin has been deprecated and is scheduled to be removed in Gradle 3.0"

My task build will build the artifact and then generate the POM and move the artifact to different location but I am getting below error.

My full script is

apply plugin: 'cpp'
apply plugin: 'java'
//-- set the group for publishing
group = 'com.tr.anal'

/**
 * 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.analBuildVersion += "_${env["BUILD_NUMBER"]}"
version = buildProperties.analBuildVersion
println "${version}"

//name is set in the settings.gradle file
group = "com.t.anal"
version = buildProperties.analBuildVersion
println "Building ${project.group}:${project.name}:${project.version}"

repositories {
    maven {
      url "http://cm.thon.com:900000/artifactory/libs-snapshot-local"
    }
     maven {
      url "http://cm.thon.com:9000000/artifactory/libs-release"
    }
}
    dependencies {
   compile ([
    "com.tr.anal:analytics-engine-common:4.+"
      ])
}



model {
  repositories {
    libs(PrebuiltLibraries) {
      jdk {
        headers.srcDirs "${System.properties['java.home']}/../include",
        "${System.properties['java.home']}/../include/win32",
        "${System.properties['java.home']}/../include/darwin",
        "${System.properties['java.home']}/../include/linux"
      }
    }
  }
}

model {
  platforms {
    x64 { architecture "x86_64" }
    x86 { architecture "x86" }
  }
}

model {
  components {
    main(NativeLibrarySpec) {
      sources {
        cpp {
          source {
            lib library: 'main', linkage: 'static'
            lib library: 'jdk', linkage: 'api'
            srcDir "src/main/c++/native"
            include "**/JniSupport.cpp"
            include "**/DiseaseStagingJni.cpp"
          }
        }
      }
    }
  }
}

def nativeHeadersDir = file("$buildDir/nativeHeaders")
//def compilePath = configurations.compile.resolve().collect {it.absolutePath}.join(";")
binaries.all {
    // Define toolchain-specific compiler and linker options
    if (toolChain in Gcc) {
        cppCompiler.args "-I${nativeHeadersDir}"
        cppCompiler.args "-g"
        linker.args '-Xlinker', '-shared -LNativeJNI/src/main/resources/DSresources/DSLib -lds64 -Wl'
}
}

//def nativeHeadersDir = file("$buildDir/nativeHeaders")
task nativeHeaders {
    // def nativeHeadersDir = file("$buildDir/nativeHeaders")
     def outputFile = file("$nativeHeadersDir/DiseaseStagingJniWrapper.h")
     def classes = [
             'com.truvenhealth.analyticsengine.common.diseasestaging.DiseaseStagingJniWrapper'
                  ]
     inputs.files sourceSets.main.output
     inputs.property('classes', classes)
     outputs.file outputFile
     doLast {
         outputFile.parentFile.mkdirs()
         def compilePath = configurations.compile.resolve().collect {it.absolutePath}.join(":")
         println "Using Compile Path: ${compilePath}"
         exec {
             executable org.gradle.internal.jvm.Jvm.current().getExecutable('javah')
             args '-o', outputFile
             args '-classpath', compilePath
             args classes
         }
     }
 }

             tasks.withType(CppCompile) { task ->
                 task.dependsOn nativeHeaders
             }
/*****************************
 * Packaging
 *****************************/

apply plugin: "maven"


// Workaround for Jenkins-Artifactory plugin not picking up the POM file

def pomFile = file("${buildDir}/libs/${archivesBaseName.toLowerCase()}-${version}.pom")
task newPom << {
  pom {
      project {
          groupId project.group
          artifactId project.name
          version project.version
          description = "Configuration Management Gradle Plugin"
      }
  }.writeTo(pomFile)
}
//disabling the install task since we're not using maven for real
install.enabled = false

//for publishing to artifactory via jenkins
if(project.hasProperty('artifactoryPublish')) {
  artifactoryPublish {
    mavenDescriptor pomFile
  }
}
def filechange = file("build/libs/NativeJNI-${project.version}.so")
task copyfile(type: Copy) {
     from 'build/binaries/mainSharedLibrary'
     into 'build/libs'
include('libmain.so')
rename ('libmain.so', "$filechange")
 }
//build.dependsOn copyfile
task build (dependsOn: ["newPom","copyfile"]) << {
    println "build in progress"
}

def someFile = file("build/libs/NativeJNI-${project.version}.so")
artifacts {
    archives someFile
}

1 个答案:

答案 0 :(得分:0)

看起来这是3.0中的错误, https://github.com/GradleFx/GradleFx/issues/235