<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2010, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
--><projectname="module-repository-lib"><propertyname="src.dir"value="src"/><propertyname="module.repo.src.dir"value="${src.dir}/main/resources/modules"/><propertyname="module.xml"value="module.xml"/><taskdefresource="net/sf/antcontrib/antlib.xml"/><taskdefname="jandex"classname="org.jboss.jandex.JandexAntTask" /><macrodefname="module-def"><attributename="name"/><attributename="slot"default="main"/><elementname="resources"implicit="yes"optional="yes"/><sequential><echomessage="Initializing module -> @{name}"/><propertyname="module.repo.output.dir"value="${output.dir}/modules"/><!-- Figure out the correct module path --><define-module-dirname="@{name}"slot="@{slot}"/><!-- Make the module output director --><mkdirdir="${module.repo.output.dir}/${current.module.path}"/><!-- Copy the module.xml and other stuff to the output director --><copytodir="${module.repo.output.dir}/${current.module.path}"overwrite="true"><filesetdir="${module.repo.src.dir}/${current.module.path}"><includename="**"/></fileset></copy><!-- Process the resource --><resources/><!-- Add keycloak version property to module xml --><replacefile="${module.repo.output.dir}/${current.module.path}/${module.xml}"token="$${project.version}"value="${project.version}"/><!-- Some final cleanup --><replacefile="${module.repo.output.dir}/${current.module.path}/${module.xml}"><replacetoken>
<![CDATA[
<!-- Insert resources here -->]]></replacetoken><replacevalue></replacevalue></replace></sequential></macrodef><macrodefname="bundle-def"><attributename="name"/><attributename="slot"default="main"/><elementname="resources"implicit="yes"optional="yes"/><sequential><echomessage="Initializing bundle -> @{name}"/><propertyname="bundle.repo.output.dir"value="${output.dir}/bundles/system/layers/base"/><!-- Figure out the correct bundle path --><define-bundle-dirname="@{name}"slot="@{slot}" /><!-- Make the bundle output director --><mkdirdir="${bundle.repo.output.dir}/${current.bundle.path}"/><!-- Process the resource --><resources/></sequential></macrodef><macrodefname="maven-bundle" ><attributename="group"/><attributename="artifact"/><sequential><!-- Copy the jar to the bundle dir --><propertyname="bundle.repo.output.dir"value="${output.dir}/bundles/system/layers/base"/><copytodir="${bundle.repo.output.dir}/${current.bundle.path}"failonerror="true"><filesetfile="${@{group}:@{artifact}:jar}"/><mappertype="flatten" /></copy></sequential></macrodef><scriptdefname="define-module-dir"language="javascript"manager="bsf"><attributename="name"/><attributename="slot"/>
<![CDATA[
name = attributes.get("name");
name = name.replace(".", "/");
project.setProperty("current.module.path", name + "/" + attributes.get("slot"));
]]>
</scriptdef><scriptdefname="define-bundle-dir"language="javascript"manager="bsf"><attributename="name"/><attributename="slot"/>
<![CDATA[
name = attributes.get("name");
name = name.replace(".", "/");
project.setProperty("current.bundle.path", name + "/" + attributes.get("slot"));
]]>
</scriptdef><!--
Get the version from the parent directory of the jar. If the parent directory is 'target' this
means that the jar is contained in AS build so extract the version from the file name
--><scriptdefname="define-maven-artifact"language="javascript"manager="bsf"><attributename="group"/><attributename="artifact"/><attributename="classifier"/><attributename="element"/><attributename="path"/>
<![CDATA[
importClass(Packages.java.io.File);
group = attributes.get("group");
artifact = attributes.get("artifact");
classifier = attributes.get("classifier");
element = attributes.get("element");
path = attributes.get("path");
if(path.indexOf('${') != -1) {
throw "Module resource root not found, make sure it is listed in build/pom.xml" + path;
}
fp = new File(path);
version = fp.getParentFile().getName();
if (version.equals("target")) {
version = fp.getName();
version = version.substring(artifact.length() + 1);
suffix = ".jar";
if (classifier) {
suffix = "-" + classifier + suffix;
}
version = version.replace(suffix, "");
}
root = "<" + element + " name=\"" + group + ":" + artifact + ":" + version;
if (classifier) {
root = root + ":" + classifier;
}
root = root + "\"/>";
project.setProperty("current.maven.root", root);
]]>
</scriptdef><macrodefname="maven-resource" ><attributename="group"/><attributename="artifact"/><attributename="jandex"default="false" /><sequential><if><equalsarg1="${mavenized.modules}"arg2="true"/><then><define-maven-artifactgroup="@{group}"artifact="@{artifact}"element="artifact"path="${@{group}:@{artifact}:jar}"/><replacefile="${module.repo.output.dir}/${current.module.path}/${module.xml}"><replacefiltertoken="<!-- Insert resources here -->"value="${current.maven.root} <!-- Insert resources here -->"/></replace></then><else><!-- Copy the jar to the module dir --><copytodir="${module.repo.output.dir}/${current.module.path}"failonerror="true"><filesetfile="${@{group}:@{artifact}:jar}"/><mappertype="flatten" /></copy><basenamefile="${@{group}:@{artifact}:jar}"property="resourcename.@{group}.@{artifact}"/><!-- Generate the Jandex Index --><jandexrun="@{jandex}"newJar="true" ><filesetdir="${module.repo.output.dir}/${current.module.path}" /></jandex><!-- Update the resource entry in module.xml --><define-resource-rootpath="${resourcename.@{group}.@{artifact}}"jandex="@{jandex}"/><replacefile="${module.repo.output.dir}/${current.module.path}/${module.xml}"><replacefiltertoken="<!-- Insert resources here -->"value="${current.resource.root} <!-- Insert resources here -->"/></replace></else></if></sequential></macrodef><macrodefname="maven-resource-with-classifier" ><attributename="group"/><attributename="artifact"/><attributename="classifier"/><attributename="jandex"default="false" /><sequential><if><equalsarg1="${mavenized.modules}"arg2="true"/><then><define-maven-artifactgroup="@{group}"artifact="@{artifact}"element="artifact"classifier="@{classifier}"path="${@{group}:@{artifact}:jar:@{classifier}}"/><replacefile="${module.repo.output.dir}/${current.module.path}/${module.xml}"><replacefiltertoken="<!-- Insert resources here -->"value="${current.maven.root} <!-- Insert resources here -->"/></replace></then><else><!-- Copy the jar to the module dir --><copytodir="${module.repo.output.dir}/${current.module.path}"failonerror="true"><filesetfile="${@{group}:@{artifact}:jar:@{classifier}}"/><!-- http://jira.codehaus.org/browse/MANTRUN-159 --><mappertype="flatten" /></copy><basenamefile="${@{group}:@{artifact}:jar:@{classifier}}"property="resourcename.@{group}.@{artifact}.@{classifier}"/><!-- Update the resource entry in module.xml --><define-resource-rootpath="${resourcename.@{group}.@{artifact}.@{classifier}}"/><replacefile="${module.repo.output.dir}/${current.module.path}/${module.xml}"><replacefiltertoken="<!-- Insert resources here -->"value="${current.resource.root} <!-- Insert resources here -->"/></replace></else></if></sequential></macrodef><macrodefname="extract-native-jar" ><attributename="group"/><attributename="artifact"/><sequential><if><equalsarg1="${mavenized.modules}"arg2="true"/><then><define-maven-artifactgroup="@{group}"artifact="@{artifact}"element="native-artifact"path="${@{group}:@{artifact}:jar}"/><replacefile="${module.repo.output.dir}/${current.module.path}/${module.xml}"><replacefiltertoken="<!-- Insert resources here -->"value="${current.maven.root} <!-- Insert resources here -->"/></replace></then><else><unzipsrc="${@{group}:@{artifact}:jar}"dest="${module.repo.output.dir}/${current.module.path}"><patternset><includename="lib/**"/></patternset></unzip></else></if></sequential></macrodef><scriptdefname="define-resource-root"language="javascript"manager="bsf"><attributename="path"/><attributename="jandex"/>
<![CDATA[
path = attributes.get("path");
root = "<resource-root path=\"" + path + "\"/>";
if(path.indexOf('${') != -1) {
throw "Module resource root not found, make sure it is listed in build/pom.xml" + path;
}
if(attributes.get("jandex") == "true" ) {
root = root + "\n\t<resource-root path=\"" + path.replace(".jar","-jandex.jar") + "\"/>";
}
project.setProperty("current.resource.root", root);
]]>
</scriptdef></project>