| <project name="Change plugins version" default="change-version"> |
| <property name="relay.origin.version" value="1.0.0-beta-2423"/> |
| <property name="relay.substitute.version" value="1.0.0-beta-2423-IJ-141-3"/> |
| <property name="relay.plugins.dir" value="artifacts"/> |
| <property name="relay.unpack.directory" value="relay-dir"/> |
| |
| <macrodef name="substituteRegexpInFile"> |
| <attribute name="src.file"/> |
| <attribute name="output.dir"/> |
| <attribute name="origin.version"/> |
| <attribute name="substituted.version"/> |
| <sequential> |
| <copy todir="@{output.dir}"> |
| <fileset file="@{src.file}"/> |
| <filterchain> |
| <replaceregex pattern="@{origin.version}" replace="@{substituted.version}" /> |
| </filterchain> |
| </copy> |
| </sequential> |
| </macrodef> |
| |
| <macrodef name="substitudeVersionInPlugin"> |
| <attribute name="plugin.path"/> |
| <attribute name="plugin.jar.name"/> |
| <attribute name="origin.version"/> |
| <attribute name="substituted.version"/> |
| <attribute name="plugin.subdir"/> |
| |
| <attribute name="output-dir" default="@{substituted.version}"/> |
| <attribute name="output.plugin.file.name" default="@{plugin.jar.name}-@{substituted.version}.zip"/> |
| |
| <attribute name="temp.origin.dir" default="${relay.unpack.directory}/@{plugin.jar.name}/plugin-origin"/> |
| <attribute name="temp.substitute.dir" default="${relay.unpack.directory}/@{plugin.jar.name}/substitute"/> |
| |
| <sequential> |
| <delete dir="${relay.unpack.directory}/@{plugin.jar.name}"/> |
| <mkdir dir="${relay.unpack.directory}/@{plugin.jar.name}"/> |
| |
| <unzip src="@{plugin.path}" dest="@{temp.origin.dir}"> |
| <patternset> |
| <include name="**/lib/@{plugin.jar.name}.jar" /> |
| </patternset> |
| <flattenmapper/> |
| </unzip> |
| |
| <unzip src="@{temp.origin.dir}/@{plugin.jar.name}.jar" dest="@{temp.origin.dir}"> |
| <patternset> |
| <include name="**/META-INF/plugin.xml" /> |
| </patternset> |
| <flattenmapper/> |
| </unzip> |
| |
| <substituteRegexpInFile |
| src.file="@{temp.origin.dir}/plugin.xml" output.dir="@{temp.substitute.dir}" |
| origin.version="@{origin.version}" substituted.version="@{substituted.version}"/> |
| |
| <!-- Copy updated file back into jar --> |
| <copy file="@{temp.origin.dir}/@{plugin.jar.name}.jar" todir="@{temp.substitute.dir}"/> |
| <jar destfile="@{temp.substitute.dir}/@{plugin.jar.name}.jar" update="true"> |
| <zipfileset file="@{temp.substitute.dir}/plugin.xml" prefix="META-INF"/> |
| </jar> |
| |
| <!-- Pack updated plugin.jar back to zip file --> |
| <copy file="@{plugin.path}" tofile="@{substituted.version}/@{output.plugin.file.name}"/> |
| <zip destfile="@{substituted.version}/@{output.plugin.file.name}" update="true"> |
| <zipfileset file="@{temp.substitute.dir}/@{plugin.jar.name}.jar" prefix="@{plugin.subdir}/lib"/> |
| </zip> |
| </sequential> |
| </macrodef> |
| |
| <target name="change-version" description="Repack plugin with other version"> |
| <delete dir="${relay.unpack.directory}"/> |
| <delete dir="${relay.substitute.version}"/> |
| |
| <mkdir dir="${relay.unpack.directory}"/> |
| <mkdir dir="${relay.substitute.version}"/> |
| |
| <substitudeVersionInPlugin |
| plugin.jar.name="kotlin-plugin" |
| plugin.path="${relay.plugins.dir}/kotlin-plugin-${relay.origin.version}.zip" |
| origin.version="${relay.origin.version}" |
| plugin.subdir="Kotlin" |
| substituted.version="${relay.substitute.version}"/> |
| |
| <substitudeVersionInPlugin |
| plugin.jar.name="kotlin-android-extensions" |
| plugin.path="${relay.plugins.dir}/kotlin-android-extensions-plugin-${relay.origin.version}.zip" |
| origin.version="${relay.origin.version}" |
| plugin.subdir="KotlinAndroidExtensions" |
| substituted.version="${relay.substitute.version}"/> |
| </target> |
| </project> |