From dc707ea3f146cad2db73c71dec440daaf4bce179 Mon Sep 17 00:00:00 2001 From: Evgeny Goldin Date: Sat, 29 Jun 2013 01:03:58 +0200 Subject: [PATCH 1/8] ExtractorMojo - prints all values. --- .../maven/plugin/ExtractorMojo.groovy | 54 ++++++++++--------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojo.groovy b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojo.groovy index ae3f76985..135df9b07 100644 --- a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojo.groovy +++ b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojo.groovy @@ -106,9 +106,16 @@ class ExtractorMojo extends ExtractorMojoProperties /** - * Mapping of mojo parameters of type {@link Config.DelegatesToPrefixPropertyHandler}: - * Key - parameter (field) name - * Value - parameter (field) value + * Mapping of types printed by {@link #printConfigurations()}: class => description. + */ + private final static Map, String> TYPES_DESCRIPTION = [ ( Boolean ) : 'true/false', + ( boolean ) : 'true/false', + ( Number ) : 'N', + ( File ) : 'path/to/file', + ( String ) : ' .. ' ].asImmutable() + + /** + * Mapping of mojo parameters of type {@link Config.DelegatesToPrefixPropertyHandler}: name => value. */ final Map prefixPropertyHandlers = this.class.declaredFields. @@ -117,7 +124,7 @@ class ExtractorMojo extends ExtractorMojoProperties @SuppressWarnings([ 'GroovyAccessibility' ]) - @Requires({ descriptorReader && repoSystem && session }) + @Requires({ descriptorReader && repoSystem && session && prefixPropertyHandlers }) @Override void execute () throws MojoExecutionException , MojoFailureException { @@ -126,7 +133,7 @@ class ExtractorMojo extends ExtractorMojoProperties ( session.request.executionListener instanceof BuildInfoRecorder )) if ( invokedAlready ){ return } - if ( log.debugEnabled ){ printHandlerSettings() } + if ( log.debugEnabled ){ printConfigurations() } skipDefaultDeploy() updateConfiguration() @@ -138,35 +145,34 @@ class ExtractorMojo extends ExtractorMojoProperties /** * Prints out all possible settings for each handler container. */ - @Requires({ log.debugEnabled && prefixPropertyHandlers.values() }) - private void printHandlerSettings () + @Requires({ log.debugEnabled && artifactory && prefixPropertyHandlers }) + private void printConfigurations () { - log.debug( " handlers:\n" + ( [ artifactory : artifactory ] + prefixPropertyHandlers ).collect { - String handlerName, Object handler -> - """ - |<$handlerName> - | ${ handlerSettings( handler ).join( '\n ' )} - |""".stripMargin().trim() - }.join( '\n' )) + final Map objectsMap = [ '' : this, artifactory : artifactory ] + prefixPropertyHandlers + final List lines = [ 'Possible values:' ] + objectsMap.collect { + String objectName, Object object -> + objectName ? [ "<$objectName>", objectConfigurations( object ).collect { " $it" }, "" ] : + objectConfigurations( object ) + }.flatten() + + log.debug( lines.join( '\n' )) } /** * Retrieves a list of all handler's settings. */ - @Requires({ handler }) + @Requires({ handler != null }) @Ensures ({ result }) - private List handlerSettings ( Object handler ) + private List objectConfigurations ( Object handler ) { - handler.class.methods.findAll { Method m -> ( m.parameterTypes.length == 1 ) && - [ String, Boolean, boolean, Number ].any { it.isAssignableFrom( m.parameterTypes.first()) }}. - findAll { Method m -> m.name.startsWith( 'set' ) && ( m.name.length() > 3 ) }. + handler.class.methods.findAll { Method m -> ( m.name.length() > 3 ) && + ( m.name.startsWith( 'set' )) && + ( m.parameterTypes.length == 1 ) && + TYPES_DESCRIPTION.keySet().any { it.isAssignableFrom( m.parameterTypes.first()) }}. collect { Method m -> - final tagName = "${ m.name.charAt( 3 ).toLowerCase()}${ m.name.substring( 4 )}" - final tagContent = [ Boolean, boolean ].any{ it.isAssignableFrom( m.parameterTypes.first()) } ? 'true/false' : - Number.isAssignableFrom ( m.parameterTypes.first()) ? 'N' : - ' .. ' - "<$tagName>${ tagContent }" + final tag = "${ m.name.charAt( 3 ).toLowerCase()}${ m.name.substring( 4 )}" + "<$tag>${ TYPES_DESCRIPTION[ m.parameterTypes.first()] }" }. sort() } From aa37e7ff5e7b0c74652f76e614a6b93a7459ddde Mon Sep 17 00:00:00 2001 From: Evgeny Goldin Date: Sat, 29 Jun 2013 02:41:23 +0200 Subject: [PATCH 2/8] ExtractorMojo - old properties are eliminated + code cleanup. --- .../ArtifactoryClientConfiguration.java | 8 + .../client/ClientConfigurationFields.java | 1 + .../maven/plugin/ExtractorMojo.groovy | 101 +++------ .../maven/plugin/ExtractorMojoHelper.groovy | 194 ++++++++++++++++++ .../plugin/ExtractorMojoProperties.groovy | 6 - .../maven/plugin/PropertiesHelper.groovy | 161 --------------- .../build/extractor/maven/plugin/Utils.groovy | 38 ---- 7 files changed, 227 insertions(+), 282 deletions(-) create mode 100644 build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy delete mode 100644 build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/PropertiesHelper.groovy delete mode 100644 build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/Utils.groovy diff --git a/build-info-client/src/main/java/org/jfrog/build/client/ArtifactoryClientConfiguration.java b/build-info-client/src/main/java/org/jfrog/build/client/ArtifactoryClientConfiguration.java index cd4cec677..d1633aef4 100644 --- a/build-info-client/src/main/java/org/jfrog/build/client/ArtifactoryClientConfiguration.java +++ b/build-info-client/src/main/java/org/jfrog/build/client/ArtifactoryClientConfiguration.java @@ -444,6 +444,14 @@ public String getRepoKey() { return getStringValue(REPO_KEY); } + public void setResolutionRepoKey(String repoKey) { + setStringValue(RESOLUTION_REPO_KEY, repoKey); + } + + public String getResolutionRepoKey() { + return getStringValue(RESOLUTION_REPO_KEY); + } + /** * In the context of a publisher it is used to publish a pom. In the context of a resolver it is used to add a * maven resolver (e.g. in Gradle). diff --git a/build-info-client/src/main/java/org/jfrog/build/client/ClientConfigurationFields.java b/build-info-client/src/main/java/org/jfrog/build/client/ClientConfigurationFields.java index a1465b6de..fa4ce0595 100644 --- a/build-info-client/src/main/java/org/jfrog/build/client/ClientConfigurationFields.java +++ b/build-info-client/src/main/java/org/jfrog/build/client/ClientConfigurationFields.java @@ -32,6 +32,7 @@ public interface ClientConfigurationFields { String IVY_IVY_PATTERN = "ivy.ivyPattern"; String URL = "url"; String REPO_KEY = "repoKey"; + String RESOLUTION_REPO_KEY = "resolution.repoKey"; // Publish fields String PUBLISH_ARTIFACTS = "artifacts"; String PUBLISH_BUILD_INFO = "buildInfo"; diff --git a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojo.groovy b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojo.groovy index 135df9b07..c7145ca5e 100644 --- a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojo.groovy +++ b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojo.groovy @@ -1,6 +1,5 @@ package org.jfrog.build.extractor.maven.plugin -import static org.jfrog.build.extractor.maven.plugin.Utils.* import org.apache.maven.AbstractMavenLifecycleParticipant import org.apache.maven.execution.ExecutionEvent import org.apache.maven.execution.MavenSession @@ -14,15 +13,13 @@ import org.apache.maven.plugins.annotations.Mojo import org.apache.maven.plugins.annotations.Parameter import org.apache.maven.project.MavenProject import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader -import org.gcontracts.annotations.Ensures +import org.codehaus.gmaven.mojo.GroovyMojo import org.gcontracts.annotations.Requires import org.jfrog.build.extractor.maven.BuildInfoRecorder import org.jfrog.build.extractor.maven.BuildInfoRecorderLifecycleParticipant import org.sonatype.aether.RepositorySystem import org.sonatype.aether.impl.ArtifactDescriptorReader import org.sonatype.aether.impl.internal.DefaultRepositorySystem -import java.lang.reflect.Field -import java.lang.reflect.Method import java.text.SimpleDateFormat @@ -30,7 +27,7 @@ import java.text.SimpleDateFormat * Artifactory plugin creating and deploying JSON build data together with build artifacts. */ @Mojo ( name = 'extract-build-info', defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true ) -class ExtractorMojo extends ExtractorMojoProperties +class ExtractorMojo extends GroovyMojo { /** * --------------------------- @@ -77,6 +74,9 @@ class ExtractorMojo extends ExtractorMojoProperties @Parameter boolean pomPropertiesPriority = false + @Parameter + String deployProperties + /** * ---------------- * Mojo parameters - property handlers @@ -105,79 +105,29 @@ class ExtractorMojo extends ExtractorMojoProperties Config.BlackDuck blackDuck = new Config.BlackDuck() - /** - * Mapping of types printed by {@link #printConfigurations()}: class => description. - */ - private final static Map, String> TYPES_DESCRIPTION = [ ( Boolean ) : 'true/false', - ( boolean ) : 'true/false', - ( Number ) : 'N', - ( File ) : 'path/to/file', - ( String ) : ' .. ' ].asImmutable() - - /** - * Mapping of mojo parameters of type {@link Config.DelegatesToPrefixPropertyHandler}: name => value. - */ - final Map prefixPropertyHandlers = - this.class.declaredFields. - findAll{ Field f -> Config.DelegatesToPrefixPropertyHandler.isAssignableFrom( f.type ) }. - inject( [:] ) { Map m, Field f -> m[ f.name ] = this."${ f.name }"; m } - - @SuppressWarnings([ 'GroovyAccessibility' ]) - @Requires({ descriptorReader && repoSystem && session && prefixPropertyHandlers }) + @Requires({ descriptorReader && repoSystem && session && log }) @Override - void execute () throws MojoExecutionException , MojoFailureException + void execute () + throws MojoExecutionException , MojoFailureException { boolean invokedAlready = (( descriptorReader.artifactResolver instanceof RepositoryResolver ) || ( repoSystem.artifactResolver instanceof RepositoryResolver ) || ( session.request.executionListener instanceof BuildInfoRecorder )) + final helper = new ExtractorMojoHelper( this ) + if ( invokedAlready ){ return } - if ( log.debugEnabled ){ printConfigurations() } + if ( log.debugEnabled ){ helper.printConfigurations() } skipDefaultDeploy() - updateConfiguration() - overrideResolutionRepository( new PropertiesHelper( this ).mergeProperties()) + updateBuildInfo() + helper.createPropertiesFile() + overrideResolutionRepository() recordBuildInfo() } - /** - * Prints out all possible settings for each handler container. - */ - @Requires({ log.debugEnabled && artifactory && prefixPropertyHandlers }) - private void printConfigurations () - { - final Map objectsMap = [ '' : this, artifactory : artifactory ] + prefixPropertyHandlers - final List lines = [ 'Possible values:' ] + objectsMap.collect { - String objectName, Object object -> - objectName ? [ "<$objectName>", objectConfigurations( object ).collect { " $it" }, "" ] : - objectConfigurations( object ) - }.flatten() - - log.debug( lines.join( '\n' )) - } - - - /** - * Retrieves a list of all handler's settings. - */ - @Requires({ handler != null }) - @Ensures ({ result }) - private List objectConfigurations ( Object handler ) - { - handler.class.methods.findAll { Method m -> ( m.name.length() > 3 ) && - ( m.name.startsWith( 'set' )) && - ( m.parameterTypes.length == 1 ) && - TYPES_DESCRIPTION.keySet().any { it.isAssignableFrom( m.parameterTypes.first()) }}. - collect { Method m -> - final tag = "${ m.name.charAt( 3 ).toLowerCase()}${ m.name.substring( 4 )}" - "<$tag>${ TYPES_DESCRIPTION[ m.parameterTypes.first()] }" - }. - sort() - } - - /** * Cancels default "deploy" activity. */ @@ -188,29 +138,26 @@ class ExtractorMojo extends ExtractorMojoProperties /** - * Updates various values. + * Updates {@link #buildInfo} fields. */ - @Requires({ project }) - private void updateConfiguration () + @Requires({ buildInfo && session && project }) + private void updateBuildInfo () { - buildInfoBuildTimestamp = session.startTime.time.toString() - buildInfoBuildStarted = new SimpleDateFormat( 'yyyy-MM-dd\'T\'HH:mm:ss.SSSZ' ).format( session.startTime ) // 2013-06-23T18\:38\:37.597+0200 - artifactoryDeployBuildTimestamp = buildInfoBuildTimestamp - buildInfoBuildName = buildInfoBuildName ?: project.artifactId - artifactoryDeployBuildName = artifactoryDeployBuildName ?: buildInfoBuildName + buildInfo.buildTimestamp = session.startTime.time.toString() + buildInfo.buildStarted = new SimpleDateFormat( 'yyyy-MM-dd\'T\'HH:mm:ss.SSSZ' ).format( session.startTime ) // 2013-06-23T18\:38\:37.597+0200 + buildInfo.buildName = buildInfo.buildName ?: project.artifactId } - /** * Overrides resolution repository if a corresponding property is set. */ @SuppressWarnings([ 'GroovyAccessibility' ]) - @Requires({ ( properties != null ) && descriptorReader.artifactResolver && repoSystem.artifactResolver }) - private void overrideResolutionRepository ( Properties properties ) + @Requires({ publisher && descriptorReader.artifactResolver && repoSystem.artifactResolver }) + private void overrideResolutionRepository () { - final String artifactoryUrl = properties[ propertyName( 'artifactoryPublishContextUrl' ) ] - final String resolutionRepo = properties[ propertyName( 'artifactoryResolutionRepoKey' ) ] + final String artifactoryUrl = publisher.contextUrl + final String resolutionRepo = publisher.resolutionRepoKey if ( artifactoryUrl && resolutionRepo ) { diff --git a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy new file mode 100644 index 000000000..9d2026b33 --- /dev/null +++ b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy @@ -0,0 +1,194 @@ +package org.jfrog.build.extractor.maven.plugin + +import org.jfrog.build.api.BuildInfoFields +import org.gcontracts.annotations.Ensures +import org.gcontracts.annotations.Requires +import org.jfrog.build.api.BuildInfoConfigProperties +import org.jfrog.build.client.ClientProperties +import java.lang.reflect.Field +import java.lang.reflect.Method + + +/** + * Helper merging all mojo properties. + */ +class ExtractorMojoHelper +{ + @Delegate + private final ExtractorMojo mojo + + private final Properties systemProperties + + /** + * Mapping of mojo parameters of type {@link Config.DelegatesToPrefixPropertyHandler}: name => value. + */ + private final Map prefixPropertyHandlers + + /** + * Mapping of types printed by {@link #printConfigurations()}: class => description. + */ + private final static Map, String> TYPES_DESCRIPTION = [ ( Boolean ) : 'true/false', + ( boolean ) : 'true/false', + ( Number ) : 'N', + ( File ) : 'path/to/file', + ( String ) : ' .. ' ].asImmutable() + + + @SuppressWarnings([ 'GrFinalVariableAccess' ]) + @Requires({ mojo }) + @Ensures ({ this.mojo && ( this.systemProperties != null ) && prefixPropertyHandlers }) + ExtractorMojoHelper ( ExtractorMojo mojo ) + { + this.mojo = mojo + final systemProperty = System.getProperty( BuildInfoConfigProperties.PROP_PROPS_FILE ) + this.systemProperties = readProperties( systemProperty ? new File( systemProperty ) : '' ) + prefixPropertyHandlers = (( Map ) mojo.class.declaredFields. + findAll{ Field f -> Config.DelegatesToPrefixPropertyHandler.isAssignableFrom( f.type ) }. + inject( [:] ) { Map m, Field f -> m[ f.name ] = mojo."${ f.name }"; m }). + asImmutable() + } + + + /** + * Prints out all possible Mojo settings. + */ + @Requires({ log.debugEnabled && artifactory && prefixPropertyHandlers }) + void printConfigurations () + { + final Map objectsMap = [ '' : this, artifactory : artifactory ] + prefixPropertyHandlers + final List lines = [ 'Possible values:' ] + objectsMap.collect { + String objectName, Object object -> + objectName ? [ "<$objectName>", objectConfigurations( object ).collect { " $it" }, "" ] : + objectConfigurations( object ) + }.flatten() + + log.debug( lines.join( '\n' )) + } + + + /** + * Retrieves a list of all object settings. + */ + @Requires({ object != null }) + @Ensures ({ result }) + private List objectConfigurations ( Object object ) + { + object.class.methods.findAll { Method m -> ( m.name.length() > 3 ) && + ( m.name.startsWith( 'set' )) && + ( m.parameterTypes.length == 1 ) && + TYPES_DESCRIPTION.keySet().any { it.isAssignableFrom( m.parameterTypes.first()) }}. + collect { Method m -> + final tag = "${ m.name.charAt( 3 ).toLowerCase()}${ m.name.substring( 4 )}" + "<$tag>${ TYPES_DESCRIPTION[ m.parameterTypes.first()] }" + }. + sort() + } + + + /** + * Merges *.properties files with values and writes a new *.properties file to be picked up later + * by the original Maven listener. + */ + @Ensures ({ result }) + Properties createPropertiesFile () + { + final mergedProperties = mergeProperties() + assert mergedProperties + + final propertiesFile = writeProperties ? new File( mojo.project.basedir, 'buildInfo.properties' ) : + File.createTempFile( 'buildInfo', '.properties' ) + + mergedProperties[ BuildInfoConfigProperties.PROP_PROPS_FILE ] = propertiesFile.canonicalPath + propertiesFile.withWriter { Writer w -> mergedProperties.store( w, 'Build Info Properties' )} + if ( ! writeProperties ){ propertiesFile.deleteOnExit() } + + log.info( "Merged properties file:${ propertiesFile.canonicalPath } created" ) + System.setProperty( BuildInfoConfigProperties.PROP_PROPS_FILE, propertiesFile.canonicalPath ) + + mergedProperties + } + + + /** + * Merges system-provided properties with POM properties and class fields. + */ + @SuppressWarnings([ 'GroovyAccessibility' ]) + @Requires({ prefixPropertyHandlers && artifactory.delegate.root.props && buildInfo.buildTimestamp && buildInfo.buildName }) + @Ensures ({ result != null }) + private Properties mergeProperties () + { + assert prefixPropertyHandlers.values().each { assert it.delegate.props.is( artifactory.delegate.root.props ) } + + final mergedProperties = new Properties() + final deployPropertiesPrefix = ClientProperties.PROP_DEPLOY_PARAM_PROP_PREFIX + final deployProperties = (( Properties ) readProperties( deployProperties ).collectEntries { + String key, String value -> [ "${ deployPropertiesPrefix }${ key }", value ] + }) + [ ( "${ deployPropertiesPrefix }${ BuildInfoFields.BUILD_TIMESTAMP }".toString()) : buildInfo.buildTimestamp, + ( "${ deployPropertiesPrefix }${ BuildInfoFields.BUILD_NAME }".toString()) : buildInfo.buildName ] + + addProperties(( Map ) readProperties( mojo.propertiesFile ) + readProperties( mojo.properties ), + mergedProperties ) + + addProperties( artifactory.delegate.root.props, + mergedProperties ) + + addProperties(( Map ) deployProperties, + mergedProperties ) + + ( Properties ) mergedProperties.collectEntries { String key, String value -> [ key, updateValue( value ) ]} + } + + + /** + * Adds all {@code propertiesFrom} to {@code propertiesTo} considering {@link #systemProperties}. + */ + @SuppressWarnings([ 'GroovyAssignmentToMethodParameter' ]) + @Requires({ ( propertiesFrom != null ) && ( propertiesTo != null ) && ( systemProperties != null ) }) + private void addProperties ( Map propertiesFrom, Properties propertiesTo ) + { + propertiesFrom.each { + String propertyName, String propertyValue -> + propertyName = propertyName.toString() // Possible GString => String + propertiesTo[ propertyName ] = ( systemProperties[ propertyName ] && ( ! pomPropertiesPriority )) ? + systemProperties[ propertyName ] : + propertyValue + } + } + + + /** + * Reads {@link Properties} from the {@link File} specified. + */ + @Ensures ({ result != null }) + private Properties readProperties ( File propertiesFile ) + { + assert (( ! propertiesFile ) || propertiesFile.file ), "Properties file [$propertiesFile.canonicalPath] is not available" + readProperties( propertiesFile?.file ? propertiesFile.getText( 'UTF-8' ) : '' ) + } + + + /** + * Reads {@link Properties} from the {@link String} specified. + */ + @Ensures ({ result != null }) + private Properties readProperties ( String propertiesContent ) + { + final p = new Properties() + if ( propertiesContent ){ p.load( new StringReader( propertiesContent )) } + p + } + + + /** + * Updates all "${var}" entries in the value specified to their corresponding environment variables or system properties. + */ + @Requires({ value }) + @Ensures ({ result }) + private String updateValue( String value ) + { + value?.replaceAll( /\$\{([^}]+)\}/ ){ + final String var = it[ 1 ] + System.getenv( var ) ?: System.getProperty( var ) ?: '${' + var + '}' + } + } +} diff --git a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoProperties.groovy b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoProperties.groovy index b9bdd4c58..793657429 100644 --- a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoProperties.groovy +++ b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoProperties.groovy @@ -194,10 +194,4 @@ abstract class ExtractorMojoProperties extends GroovyMojo @Property( name = 'artifactory.deploy.vcs.revision' ) String artifactoryDeployVcsRevision - /** - * Inline properties to attach to all published artifacts - */ - @Parameter - @Property( name = 'artifactory.deploy' ) - String deployProperties } diff --git a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/PropertiesHelper.groovy b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/PropertiesHelper.groovy deleted file mode 100644 index 776d990a4..000000000 --- a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/PropertiesHelper.groovy +++ /dev/null @@ -1,161 +0,0 @@ -package org.jfrog.build.extractor.maven.plugin - -import static org.jfrog.build.extractor.maven.plugin.Utils.* -import org.gcontracts.annotations.Ensures -import org.gcontracts.annotations.Requires -import org.jfrog.build.api.BuildInfoConfigProperties - - -/** - * Helper merging all mojo properties. - */ -class PropertiesHelper -{ - @Delegate - private final ExtractorMojo mojo - - @SuppressWarnings([ 'GrFinalVariableAccess' ]) - @Requires({ mojo }) - @Ensures ({ this.mojo }) - PropertiesHelper ( ExtractorMojo mojo ) - { - this.mojo = mojo - } - - - /** - * Merges *.properties files with values and writes a new *.properties file to be picked up later - * by the original Maven listener. - */ - @Ensures ({ result }) - Properties mergeProperties () - { - final systemProperty = System.getProperty( BuildInfoConfigProperties.PROP_PROPS_FILE ) - final systemProperties = readProperties( systemProperty ? new File( systemProperty ) : '' ) - - Properties pomProperties = readProperties( mojo.propertiesFile ) - pomProperties += readProperties( mojo.properties ) - - final propertiesFile = writeProperties ? new File( mojo.project.basedir, 'buildInfo.properties' ) : - File.createTempFile( 'buildInfo', '.properties' ) - - buildInfoConfigPropertiesFile = propertiesFile.canonicalPath - final mergedProperties = mergePropertiesWithFields( systemProperties, pomProperties ) - assert mergedProperties - - assert propertiesFile.parentFile.with { File f -> f.directory || f.mkdirs() } - propertiesFile.withWriter { Writer w -> mergedProperties.store( w, 'Build Info Properties' )} - if ( ! writeProperties ){ propertiesFile.deleteOnExit() } - - log.info( "Merged properties file:$propertiesFile.canonicalPath created" ) - System.setProperty( BuildInfoConfigProperties.PROP_PROPS_FILE, propertiesFile.canonicalPath ) - - mergedProperties - } - - - /** - * Merges system-provided properties with POM properties and class fields. - */ - @Requires({ ( systemProperties != null ) && ( pomProperties != null ) }) - @Ensures ({ result != null }) - private Properties mergePropertiesWithFields ( Properties systemProperties, Properties pomProperties ) - { - final mergedProperties = ( Properties ) ( pomPropertiesPriority ? systemProperties + pomProperties : pomProperties + systemProperties ) - final propertyFields = ExtractorMojoProperties.declaredFields.findAll{ ( it.name != 'deployProperties' ) && it.getAnnotation( Property ) } - assert propertyFields - - for ( field in propertyFields ) - { - assert field.name && ( field.type == String ) - - final property = field.getAnnotation( Property ) - final propertyName = property.name() - assert propertyName - - if (( ! systemProperties[ propertyName ] ) || pomPropertiesPriority ) - { - final propertyValue = mojo."${ field.name }" ?: mergedProperties[ propertyName ] ?: property.defaultValue() - assert ( propertyValue == null ) || ( propertyValue instanceof String ) - if ( propertyValue ) - { - mergedProperties[ propertyName ] = propertyValue - } - } - else - { - assert systemProperties[ propertyName ] && ( ! pomPropertiesPriority ) && - ( systemProperties[ propertyName ] == mergedProperties[ propertyName ]) - } - } - - if ( deployProperties ){ addDeployProperties( mergedProperties, systemProperties )} - addHandlersProperties( mergedProperties, systemProperties ) - - ( Properties ) mergedProperties.collectEntries { String key, String value -> [ key, updateValue( value ) ]} - } - - - /** - * Adds deployment properties to properties merged. - */ - @Requires({ ( properties != null ) && ( systemProperties != null ) && deployProperties }) - private void addDeployProperties( Properties properties, Properties systemProperties ) - { - final deployPropertiesBase = propertyName( 'deployProperties' ) - readProperties( deployProperties ).each { - String key, String value -> addProperty( "$deployPropertiesBase.$key", value, properties, systemProperties ) - } - } - - - /** - * Adds handler properties to properties merged. - */ - @SuppressWarnings([ 'GroovyAccessibility' ]) - @Requires({ ( properties != null ) && ( systemProperties != null ) && prefixPropertyHandlers.values() }) - private void addHandlersProperties ( Properties properties, Properties systemProperties ) - { - prefixPropertyHandlers.values().each { assert it.delegate.props.is( artifactory.delegate.root.props ) } - artifactory.delegate.root.props.each { - String key, String value -> addProperty( key, value, properties, systemProperties ) - } - } - - - /** - * Adds property provided to {@link Properties} instance based on {@link ExtractorMojo#pomPropertiesPriority} - * and system properties specified. - */ - @Requires({ propertyName && ( propertyValue != null ) && ( properties != null ) && ( systemProperties != null ) }) - @Ensures ({ properties[ propertyName ] != null }) - private void addProperty( String propertyName, String propertyValue, Properties properties, Properties systemProperties ) - { - properties[ propertyName ] = ( systemProperties[ propertyName ] && ( ! pomPropertiesPriority )) ? - systemProperties[ propertyName ] : - propertyValue - } - - - /** - * Reads {@link Properties} from the {@link File} specified. - */ - @Ensures ({ result != null }) - private Properties readProperties ( File propertiesFile ) - { - assert (( ! propertiesFile ) || propertiesFile.file ), "Properties file [$propertiesFile.canonicalPath] is not available" - readProperties( propertiesFile?.file ? propertiesFile.getText( 'UTF-8' ) : '' ) - } - - - /** - * Reads {@link Properties} from the {@link String} specified. - */ - @Ensures ({ result != null }) - private Properties readProperties ( String propertiesContent ) - { - final p = new Properties() - if ( propertiesContent ){ p.load( new StringReader( propertiesContent )) } - p - } -} diff --git a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/Utils.groovy b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/Utils.groovy deleted file mode 100644 index 943a29a64..000000000 --- a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/Utils.groovy +++ /dev/null @@ -1,38 +0,0 @@ -package org.jfrog.build.extractor.maven.plugin - -import org.gcontracts.annotations.Ensures -import org.gcontracts.annotations.Requires - - -/** - * Various helper methods. - */ -final class Utils -{ - private Utils (){} - - - /** - * Updates all "${var}" entries in the value specified to their corresponding environment variables or system properties. - */ - @Requires({ value }) - @Ensures ({ result }) - static String updateValue( String value ) - { - value?.replaceAll( /\$\{([^}]+)\}/ ){ - final String var = it[ 1 ] - System.getenv( var ) ?: System.getProperty( var ) ?: '${' + var + '}' - } - } - - - /** - * Retrieves mojo field's property name reading its {@link Property} annotation. - */ - @Requires({ fieldName }) - @Ensures ({ result }) - static String propertyName ( String fieldName ) - { - ExtractorMojoProperties.getDeclaredField( fieldName ).getAnnotation( Property ).name() - } -} From ac5342224b0a892ab652d8ffc735f01139a0920c Mon Sep 17 00:00:00 2001 From: Evgeny Goldin Date: Sat, 29 Jun 2013 03:42:06 +0200 Subject: [PATCH 3/8] ExtractorMojoHelper - supports "{EXPR}" and "{A|B|C}" expressions when values are replaced with env. variables or system properties. --- .../build/extractor/maven/plugin/ExtractorMojoHelper.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy index 9d2026b33..e9cbd947c 100644 --- a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy +++ b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy @@ -186,9 +186,9 @@ class ExtractorMojoHelper @Ensures ({ result }) private String updateValue( String value ) { - value?.replaceAll( /\$\{([^}]+)\}/ ){ - final String var = it[ 1 ] - System.getenv( var ) ?: System.getProperty( var ) ?: '${' + var + '}' + value?.replaceAll( /(\$?\{)([^}]+)(\})/ ){ + final expressionValue = (( String ) it[ 2 ] ).tokenize( '|' ).collect { System.getenv( it ) ?: System.getProperty( it )}.grep()[ 0 ] + expressionValue ?: "${ it[ 1 ] }${ it[ 2 ] }${ it[ 3 ] }" } } } From 05bc2d17b1640f80ffff408111f54aff19965499 Mon Sep 17 00:00:00 2001 From: Evgeny Goldin Date: Sat, 29 Jun 2013 03:52:29 +0200 Subject: [PATCH 4/8] ArtifactoryClientConfiguration.java + ClientConfigurationFields.java - changes reverted --- .../build/client/ArtifactoryClientConfiguration.java | 8 -------- .../org/jfrog/build/client/ClientConfigurationFields.java | 1 - .../build/extractor/maven/plugin/ExtractorMojo.groovy | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/build-info-client/src/main/java/org/jfrog/build/client/ArtifactoryClientConfiguration.java b/build-info-client/src/main/java/org/jfrog/build/client/ArtifactoryClientConfiguration.java index d1633aef4..cd4cec677 100644 --- a/build-info-client/src/main/java/org/jfrog/build/client/ArtifactoryClientConfiguration.java +++ b/build-info-client/src/main/java/org/jfrog/build/client/ArtifactoryClientConfiguration.java @@ -444,14 +444,6 @@ public String getRepoKey() { return getStringValue(REPO_KEY); } - public void setResolutionRepoKey(String repoKey) { - setStringValue(RESOLUTION_REPO_KEY, repoKey); - } - - public String getResolutionRepoKey() { - return getStringValue(RESOLUTION_REPO_KEY); - } - /** * In the context of a publisher it is used to publish a pom. In the context of a resolver it is used to add a * maven resolver (e.g. in Gradle). diff --git a/build-info-client/src/main/java/org/jfrog/build/client/ClientConfigurationFields.java b/build-info-client/src/main/java/org/jfrog/build/client/ClientConfigurationFields.java index fa4ce0595..a1465b6de 100644 --- a/build-info-client/src/main/java/org/jfrog/build/client/ClientConfigurationFields.java +++ b/build-info-client/src/main/java/org/jfrog/build/client/ClientConfigurationFields.java @@ -32,7 +32,6 @@ public interface ClientConfigurationFields { String IVY_IVY_PATTERN = "ivy.ivyPattern"; String URL = "url"; String REPO_KEY = "repoKey"; - String RESOLUTION_REPO_KEY = "resolution.repoKey"; // Publish fields String PUBLISH_ARTIFACTS = "artifacts"; String PUBLISH_BUILD_INFO = "buildInfo"; diff --git a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojo.groovy b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojo.groovy index c7145ca5e..ceba6489d 100644 --- a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojo.groovy +++ b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojo.groovy @@ -157,7 +157,7 @@ class ExtractorMojo extends GroovyMojo private void overrideResolutionRepository () { final String artifactoryUrl = publisher.contextUrl - final String resolutionRepo = publisher.resolutionRepoKey + final String resolutionRepo = resolver.repoKey if ( artifactoryUrl && resolutionRepo ) { From 12fc05d98b5465dbf63a2d872e37b63ca2570a71 Mon Sep 17 00:00:00 2001 From: Evgeny Goldin Date: Sat, 29 Jun 2013 10:36:58 +0200 Subject: [PATCH 5/8] ExtractorMojoProperties + @Property removed --- .../plugin/ExtractorMojoProperties.groovy | 197 ------------------ .../extractor/maven/plugin/Property.java | 16 -- 2 files changed, 213 deletions(-) delete mode 100644 build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoProperties.groovy delete mode 100644 build-info-extractor-maven3-plugin/src/main/java/org/jfrog/build/extractor/maven/plugin/Property.java diff --git a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoProperties.groovy b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoProperties.groovy deleted file mode 100644 index 793657429..000000000 --- a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoProperties.groovy +++ /dev/null @@ -1,197 +0,0 @@ -package org.jfrog.build.extractor.maven.plugin - -import org.apache.maven.plugins.annotations.Parameter -import org.codehaus.gmaven.mojo.GroovyMojo - - -/** - * Base Mojo class holding all parameters and their mapping to properties. - */ -@SuppressWarnings([ 'GroovyInstanceVariableNamingConvention' ]) -abstract class ExtractorMojoProperties extends GroovyMojo -{ - @Parameter - @Property( name = 'org.jfrog.build.extractor.maven.recorder.activate', defaultValue = 'true' ) - String orgJfrogBuildExtractorMavenRecorderActivate - - @Parameter - @Property( name = 'artifactory.publish.contextUrl' ) - String artifactoryPublishContextUrl - - @Parameter - @Property( name = 'artifactory.publish.username' ) - String artifactoryPublishUsername - - @Parameter - @Property( name = 'artifactory.publish.password' ) - String artifactoryPublishPassword - - @Parameter - @Property( name = 'artifactory.publish.resolution.repoKey' ) - String artifactoryResolutionRepoKey - - @Parameter - @Property( name = 'artifactory.publish.repoKey' ) - String artifactoryPublishRepoKey - - @Parameter - @Property( name = 'artifactory.publish.snapshot.repoKey' ) - String artifactoryPublishSnapshotRepoKey - - @Parameter - @Property( name = 'artifactory.publish.artifacts', defaultValue = 'true' ) - String artifactoryPublishArtifacts - - @Parameter - @Property( name = 'artifactory.publish.buildInfo', defaultValue = 'true' ) - String artifactoryPublishBuildInfo - - @Parameter - @Property( name = 'artifactory.publish.maven', defaultValue = 'false' ) - String artifactoryPublishMaven - - @Parameter - @Property( name = 'artifactory.publish.ivy', defaultValue = 'false' ) - String artifactoryPublishIvy - - @Parameter - @Property( name = 'artifactory.publish.ivy.m2compatible', defaultValue = 'false' ) - String artifactoryPublishIvyM2compatible - - @Parameter - @Property( name = 'buildInfoConfig.includeEnvVars', defaultValue = 'false' ) - String buildInfoConfigIncludeEnvVars - - @Parameter - @Property( name = 'artifactory.publish.unstable', defaultValue = 'false' ) - String artifactoryPublishUnstable - - @Parameter - @Property( name = 'buildInfo.buildRetention.deleteBuildArtifacts', defaultValue = 'false' ) - String buildInfoBuildRetentionDeleteBuildArtifacts - - @Parameter - @Property( name = 'buildInfo.buildRetention.daysToKeep', defaultValue = '3' ) - String buildInfoBuildRetentionDaysToKeep - - @Parameter - @Property( name = 'buildInfo.licenseControl.includePublishedArtifacts', defaultValue = 'false' ) - String buildInfoLicenseControlIncludePublishedArtifacts - - @Parameter - @Property( name = 'buildInfo.licenseControl.violationRecipients' ) - String buildInfoLicenseControlViolationRecipients - - @Parameter - @Property( name = 'buildInfo.licenseControl.scopes' ) - String buildInfoLicenseControlScopes - - @Parameter - @Property( name = 'buildInfo.governance.blackduck.runChecks', defaultValue = 'false' ) - String buildInfoGovernanceBlackduckRunChecks - - @Parameter - @Property( name = 'buildInfo.governance.blackduck.includePublishedArtifacts', defaultValue = 'false' ) - String buildInfoGovernanceBlackduckIncludePublishedArtifacts - - @Parameter - @Property( name = 'buildInfo.governance.blackduck.autoCreateMissingComponentRequests', defaultValue = 'false' ) - String buildInfoGovernanceBlackduckAutoCreateMissingComponentRequests - - @Parameter - @Property( name = 'buildInfo.governance.blackduck.autoDiscardStaleComponentRequests', defaultValue = 'false' ) - String buildInfoGovernanceBlackduckAutoDiscardStaleComponentRequests - - @Parameter - @Property( name = 'buildInfo.licenseControl.runChecks', defaultValue = 'false' ) - String buildInfoLicenseControlRunChecks - - @Parameter - @Property( name = 'buildInfo.licenseControl.autoDiscover', defaultValue = 'false' ) - String buildInfoLicenseControlAutoDiscover - - @Parameter - @Property( name = 'artifactory.publish.includePatterns' ) - String artifactoryPublishIncludePatterns - - @Parameter - @Property( name = 'artifactory.publish.excludePatterns' ) - String artifactoryPublishExcludePatterns - - @Parameter - @Property( name = 'buildInfoConfig.envVarsIncludePatterns' ) - String buildInfoConfigEnvVarsIncludePatterns - - @Parameter - @Property( name = 'buildInfoConfig.envVarsExcludePatterns', defaultValue = '*password*,*secret*' ) - String buildInfoConfigEnvVarsExcludePatterns - - @Parameter - @Property( name = 'artifactory.timeout', defaultValue = '300' ) - String artifactoryTimeout - - @Parameter - @Property( name = 'buildInfoConfig.propertiesFile', defaultValue = '300' ) - String buildInfoConfigPropertiesFile - - @Parameter - @Property( name = 'buildInfo.build.root' ) - String buildInfoBuildRoot - - @Parameter - @Property( name = 'artifactory.resolve.matrixbuild.root' ) - String artifactoryResolveMatrixbuildRoot - - @Parameter - @Property( name = 'artifactory.deploy.build.root' ) - String artifactoryDeployBuildRoot - - @Parameter - @Property( name = 'buildInfo.build.name' ) - String buildInfoBuildName - - @Parameter - @Property( name = 'artifactory.deploy.build.name' ) - String artifactoryDeployBuildName - - @Parameter - @Property( name = 'buildInfo.build.timestamp' ) - String buildInfoBuildTimestamp - - @Parameter - @Property( name = 'buildInfo.build.started' ) - String buildInfoBuildStarted - - @Parameter - @Property( name = 'artifactory.deploy.build.timestamp' ) - String artifactoryDeployBuildTimestamp - - @Parameter - @Property( name = 'buildInfo.buildUrl' ) - String buildInfoBuildUrl - - @Parameter - @Property( name = 'artifactory.deploy.build.number' ) - String artifactoryDeployBuildNumber - - @Parameter - @Property( name = 'buildInfo.build.number' ) - String buildInfoBuildNumber - - @Parameter - @Property( name = 'buildInfo.agent.name' ) - String buildInfoAgentName - - @Parameter - @Property( name = 'buildInfo.agent.version' ) - String buildInfoAgentVersion - - @Parameter - @Property( name = 'buildInfo.vcs.revision' ) - String buildInfoVcsRevision - - @Parameter - @Property( name = 'artifactory.deploy.vcs.revision' ) - String artifactoryDeployVcsRevision - -} diff --git a/build-info-extractor-maven3-plugin/src/main/java/org/jfrog/build/extractor/maven/plugin/Property.java b/build-info-extractor-maven3-plugin/src/main/java/org/jfrog/build/extractor/maven/plugin/Property.java deleted file mode 100644 index a63a3b371..000000000 --- a/build-info-extractor-maven3-plugin/src/main/java/org/jfrog/build/extractor/maven/plugin/Property.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.jfrog.build.extractor.maven.plugin; - -import java.lang.annotation.*; - -/** - * Annotation allowing to specify for mojo fields their corresponding property names. - */ -@Documented -@Retention( RetentionPolicy.RUNTIME ) -@Target( ElementType.FIELD ) -@Inherited -public @interface Property -{ - String name() default ""; - String defaultValue() default ""; -} From f430e011cb528f0ddc00ff18360e174bb8fd3358 Mon Sep 17 00:00:00 2001 From: Evgeny Goldin Date: Sat, 29 Jun 2013 10:44:49 +0200 Subject: [PATCH 6/8] ExtractorMojoHelper cosmetics. --- .../build/extractor/maven/plugin/ExtractorMojoHelper.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy index e9cbd947c..cfff14cbd 100644 --- a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy +++ b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy @@ -73,7 +73,7 @@ class ExtractorMojoHelper @Ensures ({ result }) private List objectConfigurations ( Object object ) { - object.class.methods.findAll { Method m -> ( m.name.length() > 3 ) && + object.class.methods.findAll { Method m -> ( m.name.length() > 3 ) && ( m.name.startsWith( 'set' )) && ( m.parameterTypes.length == 1 ) && TYPES_DESCRIPTION.keySet().any { it.isAssignableFrom( m.parameterTypes.first()) }}. From 76af2a353858ceb0d00c34718db76d85659d2b47 Mon Sep 17 00:00:00 2001 From: Evgeny Goldin Date: Sat, 29 Jun 2013 10:45:39 +0200 Subject: [PATCH 7/8] ExtractorMojoHelper cosmetics. --- .../extractor/maven/plugin/ExtractorMojoHelper.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy index cfff14cbd..a374d054b 100644 --- a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy +++ b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy @@ -73,10 +73,10 @@ class ExtractorMojoHelper @Ensures ({ result }) private List objectConfigurations ( Object object ) { - object.class.methods.findAll { Method m -> ( m.name.length() > 3 ) && - ( m.name.startsWith( 'set' )) && - ( m.parameterTypes.length == 1 ) && - TYPES_DESCRIPTION.keySet().any { it.isAssignableFrom( m.parameterTypes.first()) }}. + object.class.methods.findAll { Method m -> ( m.name.length() > 3 ) && + ( m.name.startsWith( 'set' )) && + ( m.parameterTypes.length == 1 ) && + TYPES_DESCRIPTION.keySet().any { it.isAssignableFrom( m.parameterTypes.first()) }}. collect { Method m -> final tag = "${ m.name.charAt( 3 ).toLowerCase()}${ m.name.substring( 4 )}" "<$tag>${ TYPES_DESCRIPTION[ m.parameterTypes.first()] }" From d96674e110b95ccecaad504ef44178b450e42d92 Mon Sep 17 00:00:00 2001 From: Evgeny Goldin Date: Sat, 29 Jun 2013 10:46:56 +0200 Subject: [PATCH 8/8] ExtractorMojoHelper cosmetics. --- .../maven/plugin/ExtractorMojoHelper.groovy | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy index a374d054b..550523071 100644 --- a/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy +++ b/build-info-extractor-maven3-plugin/src/main/groovy/org/jfrog/build/extractor/maven/plugin/ExtractorMojoHelper.groovy @@ -27,11 +27,11 @@ class ExtractorMojoHelper /** * Mapping of types printed by {@link #printConfigurations()}: class => description. */ - private final static Map, String> TYPES_DESCRIPTION = [ ( Boolean ) : 'true/false', - ( boolean ) : 'true/false', - ( Number ) : 'N', - ( File ) : 'path/to/file', - ( String ) : ' .. ' ].asImmutable() + private final static Map, String> TYPE_DESCRIPTORS = [ ( Boolean ) : 'true/false', + ( boolean ) : 'true/false', + ( Number ) : 'N', + ( File ) : 'path/to/file', + ( String ) : ' .. ' ].asImmutable() @SuppressWarnings([ 'GrFinalVariableAccess' ]) @@ -76,10 +76,10 @@ class ExtractorMojoHelper object.class.methods.findAll { Method m -> ( m.name.length() > 3 ) && ( m.name.startsWith( 'set' )) && ( m.parameterTypes.length == 1 ) && - TYPES_DESCRIPTION.keySet().any { it.isAssignableFrom( m.parameterTypes.first()) }}. + TYPE_DESCRIPTORS.keySet().any { it.isAssignableFrom( m.parameterTypes.first()) }}. collect { Method m -> final tag = "${ m.name.charAt( 3 ).toLowerCase()}${ m.name.substring( 4 )}" - "<$tag>${ TYPES_DESCRIPTION[ m.parameterTypes.first()] }" + "<$tag>${ TYPE_DESCRIPTORS[ m.parameterTypes.first()] }" }. sort() }