Trying to generate for multiple projects but getting jacocoTestReport SKIPPED - jacoco

Expected Behavior
jacocoTestReport work
Current Behavior
jacocoTestReport SKIPPED
Context
I created a task whose type is Test, and jacocoTestReport depends on the task. When I ran the task, jacocoTestReport did not work and I got the following information
jacocoTestReport SKIPPED
I find if I use the task test directly, jacocoTestReport worked fine. It makes me confused
the following code caused the above issue
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath files ('Build\\Jars\\gradle-jboss-modules-1.0.jar')
//classpath "com.moowork.gradle:gradle-node-plugin:1.2.0"
classpath 'com.github.node-gradle:gradle-node-plugin:2.2.3'
classpath "gradle.plugin.com.srcclr:gradle:3.1.7"
}
}
plugins {
id 'com.jfrog.artifactory' version '4.11.0'
id 'org.sonarqube' version '2.7'
id "jacoco"
id "java"
}
if (project.hasProperty('srcclrtoken')) {
apply plugin: "com.srcclr.gradle"
srcclr {
apiToken = project.getProperty('srcclrtoken')
}
}
org.apache.tools.ant.DirectoryScanner.removeDefaultExclude("**/CVS")
org.apache.tools.ant.DirectoryScanner.removeDefaultExclude("**/CVS/**")
import static com.github.zhurlik.Ver.V_1_1
import org.apache.tools.ant.filters.ReplaceTokens
import org.apache.tools.ant.filters.*
import org.gradle.plugins.ide.eclipse.model.Facet.FacetType
import org.gradle.plugins.ide.eclipse.model.WbResource
import org.gradle.plugins.ide.eclipse.model.WbDependentModule
apply from: 'dependencies.gradle'
apply plugin: 'com.github.zhurlik.jbossmodules'
apply plugin: 'maven-publish'
buildDir = 'gradlebuild'
//identify the version of gradle to use for the wrapper
wrapper {
gradleVersion = '6.3'
}
//artifactoryPublish.skip = true
//initialize the dynamic global build props. "Static" props come from gradle.properties
ext {
doDeploy = project.hasProperty('do.deploy') ? project.getProperty('do.deploy').toBoolean() : false
appEnv = project.hasProperty('app.env') ? project.getProperty('app.env').toLowerCase() : dev
versionDate = getDate()
versionLabel = project.hasProperty('versionLabel') ? project.getProperty('versionLabel') : ''
buildNumber = project.hasProperty('buildNumber') ? project.getProperty('buildNumber') : 1
webProjects = webProjectNames.split(',')
: ''
def slashPosition = versionLabel.lastIndexOf('/')
if (slashPosition > -1)
currentVersion = versionLabel[slashPosition+1..versionLabel.size()-1]
else
currentVersion = 'test'
set('buildInfo.build.name', 'Trax ' + versionLabel.replace('/', '_') )
set('buildInfo.build.number', buildNumber)
}
def getDate() {
def date = new Date()
def formattedDate = date.format('MM/dd/yyyy - hh:mma (z)')
return formattedDate
}
//initialize the repositories used by each projects build to retrieve required dependencies
allprojects {
group = 'com.reged.trax'
version = currentVersion + '-' + buildNumber
status = 'Integration'
repositories {
maven {
url 'http://artifacts.reged.com/artifactory/trax-dev-gradle-local'
content {
includeGroup "tapestry"
}
}
mavenCentral() {
content {
excludeGroupByRegex "javax\\.jms.*"
excludeGroupByRegex "javax\\.sql.*"
}
}
maven {
url "https://repository.apache.org/content/repositories/snapshots/"
}
maven {
url "https://maven.repository.redhat.com/ga/"
}
flatDir{
dirs "Common/jars"
}
maven {
url "https://redisson.pro/repo/"
}
mavenCentral()
}
if (it.name.startsWith("TraxLegacy")){
configurations.all {
resolutionStrategy {
//force "commons-io:commons-io:2.4", "javax.activation:activation:1.1.1", "org.hibernate:hibernate-validator:4.0.0.GA"/*,"javax.validation:validation-api:1.0.0.GA"*/
//force "commons-io:commons-io:2.4", "javax.activation:activation:1.1.1", "org.hibernate:hibernate-validator:5.4.3.Final"/*,"javax.validation:validation-api:1.0.0.GA-redhat-3"*/
//failOnVersionConflict()
force "antlr:antlr:2.7.7",
"com.fasterxml.jackson.core:jackson-annotations:2.10.5",
"com.fasterxml.jackson.core:jackson-databind:2.10.5",
}
//force versions for all 3rd party library sub-dependencies
resolutionStrategy.eachDependency {
//TRAX-52850: fix 3rd party library security vulnerabilities
if (it.requested.group ==~ /com\.fasterxml\.jackson.*/) {
it.useVersion '2.10.5'
}
//TRAX-52853: fix 3rd party library security vulnerabilities
if (it.requested.group ==~ /org\.apache\.xmlgraphics.*/ && it.requested.name ==~ /batik.*/) {
it.useVersion '1.9.1'
}
}
exclude group: 'bcel'
exclude group: 'jboss', module: 'javassist'
exclude group: 'javassist', module: 'javassist'
exclude group: 'xpp3', module: 'xpp3'
exclude group: 'commons-beanutils', module: 'commons-beanutils-core'
exclude group: 'org.apache.geronimo.specs', module: 'geronimo-jms_1.1_spec'
exclude group: 'org.slf4j', module: 'slf4j-jdk14'
exclude group: 'jdom'
exclude module: 'xmlParserAPIs'
exclude group: 'org.jboss.spec.javax.transaction', module: 'jboss-transaction-api_1.1_spec'
exclude group: 'com.sun.xml.bind'
exclude group: 'c3p0'
}
} else {
configurations.all {
resolutionStrategy {
//force "commons-io:commons-io:2.4", "javax.activation:activation:1.1.1", "org.hibernate:hibernate-validator:4.0.0.GA"/*,"javax.validation:validation-api:1.0.0.GA"*/
//force "commons-io:commons-io:2.4", "javax.activation:activation:1.1.1", "org.hibernate:hibernate-validator:5.4.3.Final"/*,"javax.validation:validation-api:1.0.0.GA-redhat-3"*/
"org.javassist:javassist:3.18.2-GA",
"org.jboss.logging:jboss-logging:3.2.1.Final",
"org.slf4j:slf4j-api:1.7.26",
"org.springframework:spring-orm:$springframeworkVersion",
"org.springframework:spring-web:$springframeworkVersion",
"org.javassist:javassist:$javassistVersion"
}
//force versions for all 3rd party library sub-dependencies
resolutionStrategy.eachDependency {
//TRAX-52850: fix 3rd party library security vulnerabilities
if (it.requested.group ==~ /com\.fasterxml\.jackson.*/) {
it.useVersion '2.10.5'
}
//TRAX-52853: fix 3rd party library security vulnerabilities
if (it.requested.group ==~ /org\.apache\.xmlgraphics.*/ && it.requested.name ==~ /batik.*/) {
it.useVersion '1.9.1'
}
}
}
}
}
configure(subprojects.findAll {!(it.getPath().startsWith(":wpServices"))}) {currProj ->
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
if (!currProj.name.startsWith("TraxLegacy")){
sourceCompatibility = 1.11
targetCompatibility = 1.11
}
eclipse {
classpath {
downloadSources = true
downloadJavadoc = true
defaultOutputDir = file('target/classes')
file.whenMerged {
entries.each {
if (it in org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry && it.kind == 'src' && it.toString().contains('output')) {
if (it.entryAttributes['gradle_used_by_scope'] == 'test') {
it.entryAttributes['test'] = true
it.output = 'target/test-classes'
} else {
it.output = 'target/classes'
}
}
}
}
}
jdt {
if (!currProj.name.startsWith("TraxLegacy")){
sourceCompatibility = 1.11
targetCompatibility = 1.11
javaRuntimeName = "JavaSE-11"
}
}
wtp {
component {
sourceDirs -= file('src/test/java')
sourceDirs -= file('src/test/resources')
}
/*facet {
facet name: 'jst.java', version: '1.8'
file {
//removing default jst.java facet version which eclipse's gradle tooling (buildship plugin) insists on adding
whenMerged { w ->
facets.removeAll { it.name == 'jst.java' && it.version != "1.8" && it.type == FacetType.installed}
}
}
}*/
}
}
if (currProj.name != 'Common') {
task sourcesJar(type: Jar) {
exclude '*.zip'
}
java {
withSourcesJar()
}
}
sourceSets {
main {
java {
srcDirs=['src/main/java']
excludes=['**/rebel.xml', '.gitkeep']
}
resources {
srcDirs=['src/main/java','src/main/resources']
excludes=['**/rebel.xml']
}
}
}
test {
ignoreFailures = rootProject.ignoreFailureProp.toBoolean()
reports.html.enabled = true
reports.junitXml.enabled = false
systemProperties = System.getProperties()
}
dependencies {
if (project.hasProperty("${currProj.name}Dependencies")) {
rootProject."${currProj.name}Dependencies".each {
add(it.configuration, it.dependency, it.options)
}
}
}
rootProject.tasks["sonarqube"].dependsOn tasks.build
}
//set up war & deploy tasks for the web projects
configure(subprojects.findAll {it.name in webProjects}) { currentProject ->
//println "configuring ${currentProject.name}"
apply plugin: 'war'
apply plugin: 'distribution'
if (currentProject.name != 'TraxLegacyWeb') {
eclipse {
wtp {
component {
minusConfigurations << configurations.compile
}
}
}
}
configurations {antconf}
if (doDeploy) {
dependencies {
antconf('ant-contrib:ant-contrib:1.0b3'){transitive=false}
}
ClassLoader antClassLoader = org.apache.tools.ant.Project.class.classLoader
configurations.antconf.each { File f ->
antClassLoader.addURL(f.toURI().toURL())
}
}
tasks.withType(War) {
if (appEnv != dev) {
rootSpec.filesMatching(['version.properties','WEB-INF/app.properties']) {
filter ReplaceTokens, tokens: [
"version.num": buildNumber.toString(),
"version.date": versionDate,
"version.label": versionLabel
]
}
}
rootSpec.exclude("**/.gitkeep")
rootSpec.exclude("**/rebel.xml")
}
def appName = rootProject.property("${currentProject.getName()}.app.name").toString()
def jbossServerName = rootProject.property("${currentProject.getName()}.jboss.server.name")
war {
if (currentProject.name != 'TraxLegacyWeb') {
rootSpec.filesMatching('*.jar') { details ->
if (!(details.file.path =~ "AuditTraxClient.jar")) {
if (!(details.file.path =~ "jazzy-core.jar")){
details.exclude()
}
}
}
}
//archiveName rootProject.property("${currentProject.getName()}.app.name")+'.war'
archiveBaseName = rootProject.property("${currentProject.getName()}.app.name")
exclude('**/node_modules')
}
jar {
baseName rootProject.property("${currentProject.getName()}.app.name")
}
distZip {
archiveName "$appName[$version+$jbossServerName].zip"
}
distributions {
main {
baseName = appName
contents {
into '/'
from war
from (project(':Build').file('jonCLI')) {
include 'generic-jon-bundle-descriptor.xml'
filter(ReplaceTokens, tokens: [
'APP.ISNAMED':appName,
'ARCHIVE.TYPE':"war",
'APP.VERSION':project.version.toString(),
'Generic JON Bundle Descriptor':"JON Bundle Descriptor for ${appName}".toString()])
rename('generic-jon-bundle-descriptor.xml', 'deploy.xml')
}
}
}
}
clean {
delete "deploy"
delete "${project.projectDir}/src/main/webapp/qrunner/node_modules"
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.web
artifactId rootProject.property("${currentProject.getName()}.app.name")}}}}
configure(subprojects.findAll {!(it.name in ['Common','Build', 'RegedCommon', 'wpServices', 'wpConsoleLite', 'wpServicesCore', 'TraxLegacyWeb'])}) {
dependencies {
compileOnly project(path: ":RegedCommon", configuration: 'compileOnly')
testCompile project(path: ":RegedCommon", configuration: "testCompile")
testCompile project(':RegedCommon').sourceSets.test.output
}
}
jibxProjects.split(',').each { name ->
project(":$name") {
dependencies {
compileOnly (project(":Build")) { transitive = false }
["Bind", "Run", "Schema"].each {
compile libs."jibx${it}".dependency
}
compile libs.bcel.dependency
}
task doJibx(dependsOn: project(":Build").tasks.build) {
doLast {
ant.lifecycleLogLevel = "VERBOSE"
ant.taskdef(name: 'bind', classname: 'com.reged.ant.JibxCompile', classpath: configurations.compileClasspath.asPath)
//println configurations.compile.asPath + ";${sourceSets.main.output.classesDirs}"
ant.bind(verbose: 'false', classpath: configurations.compile.asPath + ";${sourceSets.main.java.outputDir}") {
fileset (dir: 'src/main/java/com/reged/model/xml/jibx/binding')
}
}
}
jar.dependsOn doJibx
}
}
//update the footer files
project(":RegedCommonUITap3") {
dependencies {
compile project(path: ":RegedCommon")
}
jar {
eachFile { copyDetails ->
if (copyDetails.path == 'com/reged/common/ui/components/Footer.html') {
filter(ReplaceTokens, tokens: [buildDate:versionDate,buildNum:buildNumber.toString(),buildLabel:versionLabel/*,"#feedbackLink#":"feedbackLink"*/])
}
}
}
}
project(":RegedCommonUITap5") {
dependencies {
compile project(path: ":RegedCommon")
compile project(":tapestry5-jquery-upload")
}
jar {
eachFile { copyDetails ->
if (copyDetails.path == 'com/reged/components/Footer.tml') {
filter(ReplaceTokens, tokens: [buildDate:versionDate,buildNum:buildNumber.toString(),buildLabel:versionLabel/*,"#feedbackLink#":"feedbackLink"*/])
}
}
}
}
tapestry3Projects.split(',').each { name ->
project(":$name") {
dependencies {
compile project(":RegedCommonUITap3")
}
}
}
tapestry5Projects.split(',').each { name ->
project(":$name") {
dependencies {
compile project(":RegedCommonUITap5")
project(":tapestry5-jquery-upload")
}
}
}
project(":HighchartsServerSideJar") {
dependencies {
compile project(path: ":RegedCommon")
}
}
angularProjects.split(',').each { name ->
project(":$name") {
//apply plugin: 'com.moowork.node'
apply plugin: "com.github.node-gradle.node"
clean {
//delete rootProject.file('.gradle/nodejs')
}
node {
version = '8.12.0'
download = true
distBaseUrl = 'http://artifacts.reged.com/artifactory/nodejs-dist-local/dist'
workDir = rootProject.file('.gradle/nodejs')
}
task angularBuild (type: NpmTask) {
args = ['run', 'build']
}
angularBuild.dependsOn(npm_install)
war.dependsOn(angularBuild)
}
}
def moduleProjects = subprojects.findAll {!(it.name in webProjects) && !(it.name in ['Common','Build','wpServices','wpConsoleLite','wpServicesCore'])}.collect{it.name}
configurations {
jdbc
buildProject
}
def projArts = []
dependencies {
jdbc project(path: ":Common", configuration: "jdbc")
['wsdl', 'ws-policy'].each{
jbossmodules ("org.apache.cxf:cxf-rt-$it:$cxfVersion") { transitive false}
}
jbossmodules 'org.apache.geronimo.bundles:commons-httpclient:3.1_2'
jbossmodules 'org.apache.neethi:neethi:3.0.3'
jbossmodules 'org.apache.ws.xmlschema:xmlschema-core:2.2.1'
jbossmodules 'javax.xml.bind:jaxb-api:2.3.1'
jbossmodules 'org.glassfish.jaxb:jaxb-runtime:2.3.1'
jbossmodules 'wsdl4j:wsdl4j:1.6.3'
//jbossmodules 'javax.servlet:jstl:1.0.6'
jbossmodules 'org.mozilla:rhino:1.7.7'
libs.each {
add('jbossmodules', it.value.dependency, it.value.options)
}
jbossmodules project(path: ":RegedCommon", configuration: "java8LoggerModule")
if (appEnv != dev) {
moduleProjects.each {
jbossmodules (project(":$it")) {transitive = false}
}
}
jbossmodules 'bsf:bsf:2.3.0'
buildProject project(':Build')
}
if (appEnv != ci) {
jbossrepos {
'regedlib.modules' {
version = V_1_1
}
}
modules {
reged {
moduleName = "regedlib"
resources = configurations.jbossmodules.findAll{!it.name.startsWith('validation-api') && !projArts.contains(it) && !it.name.startsWith('log4j-1') && !it.name.contains('java8LoggerModule')}.collect{it.name}
if (appEnv == dev) {
resourceFiles = [project(':Common').file('./target/classes').absolutePath, project(':Common').file('./target/classes/Workpoint').absolutePath]
resourceFiles += moduleProjects.collect{file("$it/target/classes").absolutePath}
} else {
resourceFiles = ['../../classes', '../../classes/Workpoint']
}
dependencies = [
[name: "javax.api", export: "true"],
[name: "javax.activation.api", export: "true"],
[name: "javax.annotation.api", export: "true"],
[name: "javax.mail.api", export: "true"],
[name: "javax.resource.api", export: "true"],
[name: "javax.servlet.api", export: "true"],
[name: "javax.servlet.jsp.api", export: "true"],
[name: "javax.servlet.jstl.api", export: "true"],
[name: "javax.ejb.api", export: "true"],
[name: "javax.jms.api", export: "true"],
[name: "javax.jws.api", export: "true"],
[name: "javax.validation.api", export: "true"],
[name: "javax.xml.ws.api", export: "true"],
[name: "sun.jdk", export: "true"],
[name: "org.jboss.vfs", export: "true"],
[name: "org.jboss.logmanager", export: "true"],
[name: "org.apache.log4j", export: "true"],
[name: "org.picketbox", export: "true"],
[name: "org.jboss.jboss-transaction-spi", export: "true"],
}
regedJDK8 {
moduleName = "regedlib.java8"
if (appEnv == dev) {
resourceFiles = [project(':Common').file('./target/classes').absolutePath]
} else {
resourceFiles = ['../../../classes']
}
}
inet {
moduleName = "com.inet"
resources = ["Merlia.jar"]
dependencies = [
[name: "javax.api", export: "true"],
[name: "javax.transaction.api", export: "true"]
]
configuration = configurations.jdbc
}
postgres {
moduleName = "org.postgres"
resources = ["postgresql-9.4.1209.jar"]
dependencies = [
[name: "javax.api", export: "true"],
[name: "javax.transaction.api", export: "true"]
]
configuration = configurations.jdbc
}
datadirect {
moduleName = "com.datadirect"
resources = ["greenplum.jar"]
dependencies = [
[name: "javax.api", export: "true"],
[name: "javax.transaction.api", export: "true"]
]
configuration = configurations.jdbc
}
microsoft {
moduleName = 'com.microsoft'
resources = ['sqljdbc4.jar']
dependencies = [
[name: "javax.api", export: "true"],
[name: "javax.transaction.api", export: "true"]
]
configuration = configurations.jdbc
}
java8LoggerMoudle {
moduleName = "java8.logger"
resources = ["RegedCommon-${currentVersion}-${buildNumber}-java8LoggerModule.jar","spring-core-${springframeworkVersion}.jar","slf4j-api-1.7.26.jar", "log4j-slf4j-impl-2.17.1.jar"
,"log4j-core-2.17.1.jar", "log4j-api-2.17.1.jar", "jackson-dataformat-xml-2.10.5.jar", "jackson-core-2.10.5.jar","jackson-databind-2.10.5.jar","jackson-annotations-2.10.5.jar"]
if (appEnv == dev) {
resourceFiles = [project(':Common').file('./target/classes').absolutePath]
} else {
resourceFiles = ['../../../classes']
}
dependencies = [
[name: "org.picketbox", export: "true"],
[name: "org.jboss.logmanager", export: "true"],
[name: "org.apache.log4j", export: "true"],
[name: "javax.resource.api", export: "true"]
]
}
}
makeModules.outputs.upToDateWhen { false }
}
if (doDeploy) {
if (appEnv == ci)
build.finalizedBy makeModules
}
gradle.useLogger(new TimestampEventLogger())
class TimestampEventLogger implements TaskExecutionListener {
def timestamp = 0L
public void beforeExecute(Task task) {
println "> $task.project.name:$task.name start"
timestamp = System.currentTimeMillis()
}
public void afterExecute(Task task, TaskState state) {
def elapsed=(System.currentTimeMillis()-timestamp)/1000F
println "> $task.project.name:$task.name [$elapsed]"
}
}
evaluationDependsOn(':Build')
if (appEnv != ci) {
afterEvaluate {
distributions {
main {
baseName = 'Trax'
contents {
into ('/') {
subprojects {
if (it.name in webProjects) {
from project(it.path).distZip
}
}
from tasks['regedlib.modulesDistZip']
from (project(':').file('CCMS')) {
include 'ccms/**/*.*'
include 'perlLib/*.pm'
filesMatching('**/version.properties') {
filter ReplaceTokens, tokens: [
"version.num": buildNumber.toString(),
"version.date": versionDate,
"version.label": versionLabel
]
}
}
}
into ("/database/999_APP_VERSION/DataScripts") {
from project(":Build").file('templates')
include 'AppVersionUpdateTemplate.sql'
rename('AppVersionUpdateTemplate.sql', "AppVersionUpdate_${version}.sql")
filter(ReplaceTokens, tokens: ['app.version':version])
}
}
}
source {
baseName = 'Trax'
contents {
into ('/') {
from subprojects.findAll {!(it.getPath().startsWith(":wpServices")) && it.name != 'Common'}.sourcesJar
from (project(':').file('CCMS')) {
include 'ccms/**/*.*'
include 'perlLib/*.pm'
filesMatching('**/version.properties') {
filter ReplaceTokens, tokens: [
"version.num": buildNumber.toString(),
"version.date": versionDate,
"version.label": versionLabel
]
}
}
}
into ('/Common') {
from ('Common/src/main/resources') {
filesMatching('**/regedcommon.properties') {
filter {String line ->
line.replaceAll("(?i)(.*password=).*", "\$1")
.replaceAll("(?i)(jboss.passphrase=).*", "\$1")
.replaceAll("(?i)(tapesty.serialization.hmac.key=).*", "\$1")
.replaceAll("(?i)(jboss.algorithm=).*", "\$1")
}
}
}
}
}
}
}
sourceDistZip {
archiveClassifier = "src"
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact "$buildDir/distributions/regedlib.modules-${version}.tgz"
artifactId 'regedlib.modules'
}
}
}
artifactory {
contextUrl = artifactoryContextUrl
publish {
repository {
repoKey = artifactoryRepoKey // The Artifactory repository key to publish to
username = artifactoryUsername // The publisher user name
password = artifactoryPassword // The publisher password
}
defaults {
publications('mavenJava')
publishArtifacts = true
publishPom = true
}
}
}
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports/allTests")
// Include the results from the 'test' task in all subprojects
//reportOn subprojects*.test
reportOn subprojects.findAll {!(it.getPath().startsWith(":wpServices"))}.test
}
test {
useJUnitPlatform()
finalizedBy jacocoTestReport
}
jacoco {
toolVersion = "0.8.5"
reportsDir = file("${project.buildDir}/reports/jacoco/jacoco")
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled true
csv.enabled false
xml.destination file("${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml")
html.destination file("${project.buildDir}/reports/jacoco/test/html")
}
dependsOn tasks.build
}
sonarqube {
properties {
property "sonar.java.codeCoveragePlugin", "jacoco"
property "sonar.junit.reportPaths", "${project.buildDir}/reports/jacoco/test"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.projectName", "TRAX"
// property "sonar.jacoco.reportsPaths", "${project.buildDir}/reports/jacoco/test"
property "sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml"
}
}
tasks.sonarqube.dependsOn test

Related

Not able to create a network using #aws-sdk/client-managedblockchain

i am using #aws-sdk/client-managedblockchain to create a hyperledger network, but i got "InvalidRequestException: Invalid request body", i was follwed below link for help,
"https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-managedblockchain/classes/createnetworkcommand.html"
const params = {
ClientRequestToken : null,
Framework: 'HYPERLEDGER_FABRIC', /* required /
FrameworkVersion: '2.2', / required /
MemberConfiguration: { / required /
FrameworkConfiguration: { / required /
Fabric: {
AdminPassword: 'adminUserName', / required /
AdminUsername: 'Adminpassword' / required /
}
},
Name: 'dummy Network', / required /
Description: 'testing',
KmsKeyArn : null,
LogPublishingConfiguration: null,
Tags : null
},
Name: 'myNetwork', / required /
Tags : null,
VotingPolicy: { / required */
ApprovalThresholdPolicy: {
ProposalDurationInHours: 5,
ThresholdComparator: 'GREATER_THAN' ,
ThresholdPercentage: 50
}
},
Description: 'testing',
FrameworkConfiguration: {
Fabric: {
Edition: 'STARTER'
}
}
};
const createChannel = async ()=>{
try
{
const command = new CreateNetworkCommand(params);
const res = await client.send(command)
console.log("response", res);
}
catch(ex){
console.log(ex);
}
finally {
client.destroy();
}
}
createChannel();
Thank you in advance.

Jacoco doesnt report coverage correctly

I'm trying to set up jacoco for an android project, but there are two issues with the generated report.
1- I declared the destination folder for HTML and XML report but the generated report appears in build/reports/coverage/androidTest/debug
2- the generated report is incorrect and shows that the adder class is not covered, which is wrong.
adder class
class Adder {
fun adder(a:Int,b:Int):Int{
return a+b
}
fun subtractor(a:Int,b:Int):Int{
return a-b
}
}
test class
class AdderTest {
#Test
fun `test`(){
assertEquals(3,Adder().adder(1,2))
}
#Test
fun `substract`(){
assertEquals(-1,Adder().subtractor(1,2))
}
}
jacoco script
apply plugin: 'jacoco'
project.afterEvaluate { project ->
setupAndroidReporting()
}
def setupAndroidReporting() {
tasks.withType(Test) {
// Whether or not classes without source location should be instrumented
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}
// Grab all build types and product flavors
def buildTypes = android.buildTypes.collect { type ->
type.name
}
def productFlavors = android.productFlavors.collect { flavor ->
flavor.name
}
// When no product flavors defined, use empty
if (!productFlavors) productFlavors.add('')
productFlavors.each { productFlavorName ->
buildTypes.each { buildTypeName ->
def sourceName, sourcePath
if (!productFlavorName) {
sourceName = sourcePath = "${buildTypeName}"
} else {
sourceName = "${productFlavorName}${buildTypeName.capitalize()}"
sourcePath = "${productFlavorName}/${buildTypeName}"
}
def testTaskName = "test${sourceName.capitalize()}UnitTest"
System.out.println("Task -> $testTaskName")
// Create coverage task of form 'testFlavorTypeCoverage' depending on 'testFlavorTypeUnitTest'
task "${testTaskName}Coverage1"(type: JacocoReport, dependsOn: "$testTaskName") {
group = "Reporting"
description = "Generate Jacoco coverage reports on the ${sourceName.capitalize()} build."
if (buildTypeName == 'debug') {
reports {
csv.enabled true // change if needed
xml.enabled false // change if needed
xml.setDestination(new File("${project.rootDir.path}/coverage-report"))
html {
enabled true
destination new File("${project.rootDir.path}/coverage-report")
}
}
def fileFilter = [
]
def javaTree = fileTree(dir: "${project.buildDir}/intermediates/javac/$sourceName/classes", excludes: fileFilter)
def kotlinTree = fileTree(dir: "${project.buildDir}/tmp/kotlin-classes/$sourceName", excludes: fileFilter)
classDirectories.from = files([javaTree], [kotlinTree])
executionData.from = files("${project.buildDir}/jacoco/${testTaskName}.exec")
def coverageSourceDirs = ["src/main/java",
"src/$productFlavorName/java",
"src/$buildTypeName/java"]
sourceDirectories.setFrom(files(coverageSourceDirs))
additionalSourceDirs.setFrom(files(coverageSourceDirs))
println "xml report: file://${reports.xml.destination}"
println "html report: file://${reports.html.destination}/index.html"
}
}
}
}
}
android {
buildTypes {
debug {
testCoverageEnabled true
}
}
}
report

Pulumi GCP MemoryStore Redis Cache Internal Server Error 13

I have a weird scenario here.
The following line in my Pulumi typescript code always fails the first time:
const redisCache = new gcp.redis.Instance("my-redis-cache", {
name: "my-metadata-cache",
tier: "BASIC",
memorySizeGb: 1,
authorizedNetwork: pulumi.interpolate`projects/someprojectid/global/networks/default`,
connectMode: "PRIVATE_SERVICE_ACCESS",
redisVersion: "REDIS_6_X",
displayName: "My Metadata Cache",
project: someprojectid,
}, defaultResourceOptions);
**
error: 1 error occurred:
* Error waiting to create Instance: Error waiting for Creating Instance: Error code 13, message: an internal error has occurred
**
Strangely, when I again run pulumi up, it succeeds. Has anyone else faced this before? Any clues?
Ok this turned out to be a case of working with a beast of a code. Once I started isolating the issue, things became clearer. For those who stumble across this one, here is a full working code.
import * as pulumi from "#pulumi/pulumi";
import * as gcp from "#pulumi/gcp";
export interface CacheComponentResourceArgs {
projectId : pulumi.Input<string>;
projectNumber: pulumi.Input<string>;
}
export class CacheComponentResource extends pulumi.ComponentResource {
constructor(name: string, resourceArgs: CacheComponentResourceArgs, opts?: pulumi.ResourceOptions) {
const inputs: pulumi.Inputs = {
options: opts,
};
super("ekahaa:abstracta:Cache", name, inputs, opts);
const serviceNetworkingAccessService = new gcp.projects.Service("service-nw-" + name , {
disableDependentServices: true,
project: resourceArgs.projectId,
service: "servicenetworking.googleapis.com",
}, {
parent : this
});
const redisService = new gcp.projects.Service("redis-service-" + name, {
disableDependentServices: true,
project: resourceArgs.projectId,
service: "redis.googleapis.com",
}, {
parent : this
});
const defaultGlobalAddress = new gcp.compute.GlobalAddress("default-ip-range-" + name, {
name: "default-ip-range",
purpose: "VPC_PEERING",
prefixLength: 16,
project: resourceArgs.projectId,
addressType: "INTERNAL",
network: pulumi.interpolate`projects/${resourceArgs.projectId}/global/networks/default`
}, {
parent : this,
dependsOn: [ redisService]
});
const privateServiceConnection = new gcp.servicenetworking.Connection("servicenetworking-" + name, {
service: "servicenetworking.googleapis.com",
network: pulumi.interpolate`projects/${resourceArgs.projectId}/global/networks/default`,
reservedPeeringRanges: [defaultGlobalAddress.name],
}, {
parent : this,
dependsOn: [ defaultGlobalAddress]
});
const iamBindingRedis2 = new gcp.projects.IAMBinding("iamredis2-" + name, {
members: [
pulumi.interpolate`serviceAccount:service-${resourceArgs.projectNumber}#service-networking.iam.gserviceaccount.com`
],
role: "roles/servicenetworking.serviceAgent",
project: resourceArgs.projectId
}, {
parent : this,
dependsOn: [privateServiceConnection]
});
const redisCache = new gcp.redis.Instance(name, {
name: name,
tier: "BASIC",
memorySizeGb: 1,
authorizedNetwork: pulumi.interpolate`projects/${resourceArgs.projectId}/global/networks/default`,
connectMode: "PRIVATE_SERVICE_ACCESS",
redisVersion: "REDIS_6_X",
displayName: "Abstracta Metadata Cache",
project: resourceArgs.projectId,
}, {
parent : this,
dependsOn : [redisService,serviceNetworkingAccessService,iamBindingRedis2]
});
this.registerOutputs({
redisCache : redisCache
});
}
}
let suffix = "20211018-002";
let org_name = `org-redis-demo-${suffix}`;
let projectId = `redis-demo-${suffix}` ;
const myGcpProject = new gcp.organizations.Project('ab-' + org_name, {
orgId: gcpOrgId,
projectId: projectId,
billingAccount: billingAccountId,
name: 'ab-' + org_name,
});
const myGcpProjectIAM = new gcp.projects.IAMBinding("iam-001", {
members: [
"user:vikram.vasudevan#ekahaa.com",
],
role: "roles/owner",
project: myGcpProject.projectId
});
const cacheComponentResource = new CacheComponentResource("my-cache", {
projectId : myGcpProject.projectId,
projectNumber : myGcpProject.number
}, {
dependsOn : [myGcpProjectIAM]
});

Using Jenkins and Terraform EC2 auto deploy issues

I am new to DevOps. I am trying to deploy EC2 instances using the following script. It is failing on Terraform initializing stage. I do have the terraform init in my code. where is the issue?
pipeline {
parameters {
string(name: 'environment', defaultValue: 'terraform', description: 'Workspace/environment file to use for deployment')
booleanParam(name: 'autoApprove', defaultValue: false, description: 'Automatically run apply after generating plan?')
}
environment {
AWS_ACCESS_KEY_ID = credentials('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = credentials('AWS_SECRET_ACCESS_KEY')
}
agent any
options {
timestamps ()
}
stages {
stage('checkout') {
steps {
script{
dir("terraform")
{
git "https://github.com/Ravinderhub/Jenkins-Terraform-AWS.git"
}
}
}
}
stage('Plan') {
steps {
sh 'pwd;cd terraform/aws-instance-first-script ; terraform init -input=false'
sh 'pwd;cd terraform/aws-instance-first-script ; terraform workspace new ${environment}'
sh 'pwd;cd terraform/aws-instance-first-script ; terraform workspace select ${environment}'
sh "pwd;cd terraform/aws-instance-first-script ;terraform plan -input=false -out tfplan "
sh 'pwd;cd terraform/aws-instance-first-script ;terraform show -no-color tfplan > tfplan.txt'
}
}
stage('Approval') {
when {
not {
equals expected: true, actual: params.autoApprove
}
}
steps {
script {
def plan = readFile 'terraform/aws-instance-first-script/tfplan.txt'
input message: "Do you want to apply the plan?",
parameters: [text(name: 'Plan', description: 'Please review the plan', defaultValue: plan)]
}
}
}
stage('Apply') {
steps {
sh "pwd;cd terraform/aws-instance-first-script ; terraform apply -input=false tfplan"
}
}
}
}
There is an invalid variable in the configuration which prevents initialization.
ami_id variable defines an invalid type.
Correct that to:
variable "ami_id" {
type = "map"
default = {
us-east-1 = "ami-035b3c7efe6d061d5"
eu-west-2 = "ami-132b3c7efe6sdfdsfd"
eu-central-1 = "ami-9787h5h6nsn"
}
}

Grunt j with regular expressions

grunt.config('sass', {
options: {
sourceMap: true
},
dist: {
options: {
outputStyle: 'compact'
},
files: {
'/css/site.css': 'main/scss/site.scss',
'/css/template.home.css': 'main/scss/templates/home.scss'
'/css/template.contact.css': 'main/scss/templates/contact.scss'
'/css/template.something.css': 'main/scss/templates/something.scss'
}
}
});
is there is any way to handle this part nicely ( Thinking about a pattern but I' not sure about the possibility )
'/css/template.home.css': 'main/scss/templates/home.scss'
'/css/template.contact.css': 'main/scss/templates/contact.scss'
'/css/template.something.css': 'main/scss/templates/something.scss'
If you declare the config as a JS object you could do it like this:
var cfg = {
options: {
sourceMap: true
},
dist: {
options: {
outputStyle: 'compact'
},
files: {
'/css/site.css': 'main/scss/site.scss',
'/css/template.home.css': 'main/scss/templates/home.scss',
'/css/template.contact.css': 'main/scss/templates/contact.scss',
'/css/template.something.css': 'main/scss/templates/something.scss'
}
}
},
grunt = {
config: function() {
document.write('<br/><strong>grunt config set</string><br/>');
}
};
document.write('<br/>"files" before new config:<br/><br/>');
for (var property in cfg.dist.files) {
if (cfg.dist.files.hasOwnProperty(property)) {
document.write(property + ' = ' + cfg.dist.files[property] + '<br/>');
}
}
document.write('<br/>"files" after added config:<br/><br/>');
cfg.dist.files['/css/what ever...'] = 'the/latest/path';
for (var property in cfg.dist.files) {
if (cfg.dist.files.hasOwnProperty(property)) {
document.write(property + ' = ' + cfg.dist.files[property] + '<br/>');
}
}
grunt.config('sass', cfg);
Note the
cfg.dist.files['/css/what ever...'] = 'the/latest/path';
That's where the additional config is added.