Answer the question
In order to leave comments, you need to log in
How can I change a class in a jar using maven?
There is a jar without sources. You need to replace the class in it with your class. Can this be done with maven? So far I have found a way to change the class manually (through the archiver).
Answer the question
In order to leave comments, you need to log in
Bad option to change the class in jar
Are you sure that this class has no heirs, static fields and other things?
If not, then forget it.
Made through antrun plugin.
For the production profile, all the action takes place in the ear module.
<!--Патчим сериализаторы в jar'ках ear'ки для продакш сборки-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>repack</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<!--разархивируем в спец папку-->
<unzip src="${project.build.directory}/ear${releasePostfix}/lib/gwt-user-${gwt.version}.jar"
dest="${project.build.directory}/ant/user"/>
<unzip src="${project.build.directory}/ear${releasePostfix}/lib/gwt-servlet-${gwt.version}.jar"
dest="${project.build.directory}/ant/servlet"/>
<unzip src="${project.build.directory}/ear${releasePostfix}/lib/iask-api-web-${version}.jar"
dest="${project.build.directory}/ant/apiweb"/>
<!--заменяем нужные классы-->
<copy file="${project.build.directory}/ant/apiweb/com/google/gwt/user/client/rpc/core/java/sql/Date_CustomFieldSerializer.class"
todir="${project.build.directory}/ant/user/com/google/gwt/user/client/rpc/core/java/sql/"
overwrite="true"/>
<copy file="${project.build.directory}/ant/apiweb/com/google/gwt/user/client/rpc/core/java/sql/Date_CustomFieldSerializer.class"
todir="${project.build.directory}/ant/servlet/com/google/gwt/user/client/rpc/core/java/sql/"
overwrite="true"/>
<!--собираем в джарки обратно-->
<zip basedir="${project.build.directory}/ant/user"
destfile="${project.build.directory}/ant/toEar/lib/gwt-user-${gwt.version}.jar"
update="true"/>
<zip basedir="${project.build.directory}/ant/servlet"
destfile="${project.build.directory}/ant/toEar/lib/gwt-servlet-${gwt.version}.jar"
update="true"/>
<!--обновление еарки-->
<zip basedir="${project.build.directory}/ant/toEar/"
destfile="${project.build.directory}/ear${releasePostfix}.ear"
update="true"/>
<delete dir="${project.build.directory}/ant"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question