ОТДЫХ - Dropwizard с муравьем и плющом
Я не могу использовать Maven. Поиск в Интернете для учебника dropwizard без Maven, но ничего не найдено...
Кто-нибудь знает хороший учебник, чтобы начать с dropwizard, используя муравья и плюща вместо maven?
1 ответ
Решение
Так же, как обычная сборка муравья и вставьте эти цели
<target name="compile-server" depends="clean, resolve, echo">
<javac srcdir="${src}" source="1.8" target="1.8" encoding="UTF8" destdir="${bin}" includeantruntime="false" debug="true" debuglevel="lines,vars,source">
<classpath>
<path refid="ivy.path-server" />
</classpath>
</javac>
</target>
<target name="resolve">
<ivy:resolve file="ivy.xml" conf="*" />
<ivy:cachepath pathid="ivy.path-server" conf="server" type="jar,bundle" />
<ivy:cachefileset setid="ivy.libs-server" conf="server" type="jar,bundle" />
<ivy:retrieve conf="server" pattern="${lib.dir}/ivy/[conf]/[artifact](-[classifier]).[ext]"/>
<ivy:cachepath pathid="ivy.path-client" conf="client" type="jar,bundle" />
<ivy:cachefileset setid="ivy.libs-client" conf="client" type="jar,bundle" />
<ivy:retrieve conf="client" pattern="${lib.dir}/ivy/[conf]/[artifact](-[classifier]).[ext]"/>
<ivy:cachepath pathid="ivy.path-test" conf="test, test-meta" type="jar,bundle" />
<ivy:cachefileset setid="ivy.libs-test" conf="test, test-meta" type="jar,bundle" />
<ivy:retrieve conf="test, test-meta" pattern="${lib.dir}/ivy/[conf]/[artifact](-[classifier]).[ext]"/>
</target>
добавить / обновить это в файл плюща:
<configurations>
<conf name="server" description="server runtime dependencies" visibility="public"/>
<conf name="client" description="client runtime dependencies" visibility="public"/>
<conf name="test" description="unit test configuration" visibility="private" extends="server,client" />
<conf name="test-meta" description="sonar and jacoco" visibility="private" extends="test" />
</configurations>
<dependencies>
<dependency org="org.jacoco" name="org.jacoco.ant" rev="0.6.4.201312101107" conf="test-meta->default">
<exclude org="org.apache.ant" module="ant" />
</dependency>
<dependency org="org.codehaus.sonar-plugins" name="sonar-ant-task" rev="2.1" conf="test-meta->default">
<exclude org="org.apache.ant" module="ant" />
</dependency>
<dependency org="junit" name="junit" rev="4.11" conf="test->default"/> <!-- for builds outside of eclipse -->
<dependency org="org.mortbay.jetty" name="servlet-api" rev="3.0.20100224" conf="server->default" />
<dependency org="io.dropwizard" name="dropwizard-core" rev="0.7.1" conf="server->default"/>
<dependency org="io.dropwizard" name="dropwizard-jersey" rev="0.7.1" conf="server->default"/>
<dependency org="io.dropwizard" name="dropwizard-servlets" rev="0.7.1" conf="server->default"/>
<dependency org="io.dropwizard" name="dropwizard-jetty" rev="0.7.1" conf="server->default"/>
<dependency org="io.dropwizard" name="dropwizard-validation" rev="0.7.1" conf="server->default"/>
<dependency org="io.dropwizard" name="dropwizard-configuration" rev="0.7.1" conf="server->default"/>
<dependency org="io.dropwizard" name="dropwizard-jdbi" rev="0.7.1" conf="server->default"/>
<dependency org="io.dropwizard" name="dropwizard-db" rev="0.7.1" conf="server->default"/>
<dependency org="io.dropwizard" name="dropwizard-jackson" rev="0.7.1" conf="server->default"/>
</dependencies>
Возможно, у вас также есть проблема с io.dropwizard.jackson.Discoverable, затем используйте это:
<!-- Dropwizard Hack for problem https://github.com/dropwizard/dropwizard/issues/455 io.dropwizard.jackson.Discoverable is used by seveal libs and is overwritten each time -->
<property name="dropwizard.hack.name" value="io.dropwizard.jackson.Discoverable" />
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${lib.dir}/ivy/test/ant-contrib.jar"/>
</classpath>
</taskdef>
<!-- Dropwizard Hack for problem https://github.com/dropwizard/dropwizard/issues/455 io.dropwizard.jackson.Discoverable is used by seveal libs and is overwritten each time -->
<target name="mergehack" depends="clean, unjar_mergehack">
<!-- for every filename do another merge -->
<var name="file.destination" value="${bin}/META-INF/services/${dropwizard.hack.name}" />
<delete file="${file.destination}" />
<touch file="${file.destination}" />
<merge tofile="${file.destination}">
<sourcefiles>
<fileset dir="./${tmp}/dropwizard.hack/">
<include name="**/${dropwizard.hack.name}" />
</fileset>
</sourcefiles>
</merge>
<!-- second one ... -->
<!-- copy and change above -->
<!-- third one ... -->
<!-- copy and change above -->
</target>
<!-- = = = = = = = = = = = = = = = = =
macrodef: merge
= = = = = = = = = = = = = = = = = -->
<macrodef name="merge">
<attribute name="tofile">
</attribute>
<element name="sourcefiles">
</element>
<sequential>
<tempfile property="temp.file" prefix="ant.merge." deleteonexit="true">
</tempfile>
<concat destfile="${temp.file}" fixlastline="true">
<sourcefiles>
</sourcefiles>
</concat>
<copy file="${temp.file}" tofile="@{tofile}">
<filterchain>
<tokenfilter>
<linetokenizer>
</linetokenizer>
</tokenfilter>
<sortfilter>
</sortfilter>
<uniqfilter>
</uniqfilter>
</filterchain>
</copy>
</sequential>
</macrodef>
<target name="unjar_mergehack" depends="clean, resolve">
<!-- Needed for counting -->
<var name="op2" value="1"/>
<var name="op" value="+"/>
<var name="opminus" value="+"/>
<var name="result" value="0"/>
<!-- What file should be searched in zipped file -->
<var name="searchfile.name" value="${dropwizard.hack.name}"/>
<for param="filename">
<path>
<fileset dir="${lib.dir}/ivy/server">
<include name="**/*.jar" />
</fileset>
</path>
<sequential>
<math result="result" operand1="${result}" operation="${op}" operand2="${op2}" datatype="int"/>
<!-- <echo>Result = ${result}</echo> -->
<var name="destination" value="./${tmp}/dropwizard.hack/${result}"/>
<echo message="1. Starting to read file: @{filename}" />
<echo message="2. unzip to: ${destination}" />
<unzip src="@{filename}" dest="${destination}">
<patternset>
<include name="**/${searchfile.name}"/>
</patternset>
</unzip>
</sequential>
</for>
<echo message="Ready" />
</target>
Он распаковывает библиотеки libs для нужных файлов в каждой библиотеке, а затем объединяет все данные только в один файл. Этот файл сохраняется в папке bin в папке META-INF/services/{имя_файла}