println "[INFO] ------------------------------------------------------------------------";
println "[INFO] UPDATING SLOT VALUE FOR BEAN VALIDATION IN MODULE.XML FILES ";
println "[INFO] ------------------------------------------------------------------------";
def processFileInplace(file, Closure processText) {
def text = file.text
file.write( processText( text ) )
}
def hvModuleList = [
new File( project.properties['wildflyTargetDir'], 'modules/system/layers/base/org/jboss/as/connector/main/module.xml' ),
new File( project.properties['wildflyTargetDir'], 'modules/system/layers/base/org/jboss/as/jpa/main/module.xml' ),
new File( project.properties['wildflyTargetDir'], 'modules/system/layers/base/org/jboss/ironjacamar/impl/main/module.xml' ),
new File( project.properties['wildflyTargetDir'], 'modules/system/layers/base/org/jboss/ironjacamar/jdbcadapters/main/module.xml' ),
new File( project.properties['wildflyTargetDir'], 'modules/system/layers/base/org/jboss/resteasy/resteasy-jaxrs/main/module.xml' ),
new File( project.properties['wildflyTargetDir'], 'modules/system/layers/base/org/jboss/resteasy/resteasy-validator-provider-11/main/module.xml' ),
new File( project.properties['wildflyTargetDir'], 'modules/system/layers/base/org/wildfly/extension/bean-validation/main/module.xml' ),
]
def hvCdiModuleList = [
new File( project.properties['wildflyTargetDir'], 'modules/system/layers/base/org/jboss/as/weld/main/module.xml' )
]
def slotName = ' slot="' + project.version + '" '
hvModuleList.each{ f ->
processFileInplace( f ) { text ->
println "[INFO] Added HV slot in " + f.absolutePath;
text.replaceAll( /<module name="org.hibernate.validator"/, '<module name="org.hibernate.validator"' + slotName )
}
};
hvCdiModuleList.each{ f ->
processFileInplace( f ) { text ->
println "[INFO] Added HV CDI slot in " + f.absolutePath;
text.replaceAll( /<module name="org.hibernate.validator.cdi"/, '<module name="org.hibernate.validator.cdi"' + slotName )
}
};
println "[INFO] ------------------------------------------------------------------------";