HHH-10303 - Reinstate legacy bytecode-enhancement Ant task

This commit is contained in:
Steve Ebersole 2016-01-25 10:50:32 -06:00
parent 6648176164
commit 5ca47a6b62
2 changed files with 28 additions and 39 deletions

View File

@ -208,5 +208,14 @@ public interface DeprecationLogger extends BasicLogger {
) )
void logDeprecatedBytecodeEnhancement(); void logDeprecatedBytecodeEnhancement();
@LogMessage(level = WARN)
@Message(
id = 90000020,
value = "You are using the deprecated legacy bytecode enhancement Ant-task. This task is left in place for a short-time to " +
"aid migrations to 5.1 and the new (vastly improved) bytecode enhancement support. This task (%s) now delegates to the" +
"new Ant-task (%s) leveraging that new bytecode enhancement. You should update your build to use the new task explicitly."
)
void logDeprecatedInstrumentTask(Class taskClass, Class newTaskClass);
} }

View File

@ -6,49 +6,29 @@
*/ */
package org.hibernate.tool.instrument.javassist; package org.hibernate.tool.instrument.javassist;
import org.hibernate.bytecode.buildtime.internal.JavassistInstrumenter; import org.hibernate.internal.log.DeprecationLogger;
import org.hibernate.bytecode.buildtime.spi.Instrumenter; import org.hibernate.tool.enhance.EnhancementTask;
import org.hibernate.bytecode.buildtime.spi.Logger;
import org.hibernate.tool.instrument.BasicInstrumentationTask;
/** /**
* An Ant task for instrumenting persistent classes in order to enable * This is the legacy Ant-task Hibernate provided historically to
* field-level interception using Javassist. * perform its old-school bytecode instrumentation. That has been replaced wholesale
* <p/> * with a new approach to bytecode manipulation offering 3 build-time variations for Ant,
* In order to use this task, typically you would define a a taskdef * Maven and Gradle.
* similiar to:<pre>
* <taskdef name="instrument" classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
* <classpath refid="lib.class.path"/>
* </taskdef>
* </pre>
* where <tt>lib.class.path</tt> is an ANT path reference containing all the
* required Hibernate and Javassist libraries.
* <p/>
* And then use it like:<pre>
* <instrument verbose="true">
* <fileset dir="${testclasses.dir}/org/hibernate/test">
* <include name="yadda/yadda/**"/>
* ...
* </fileset>
* </instrument>
* </pre>
* where the nested ANT fileset includes the class you would like to have
* instrumented.
* <p/>
* Optionally you can chose to enable "Extended Instrumentation" if desired
* by specifying the extended attriubute on the task:<pre>
* <instrument verbose="true" extended="true">
* ...
* </instrument>
* </pre>
* See the Hibernate manual regarding this option.
* *
* @author Muga Nishizawa * @author Muga Nishizawa
* @author Steve Ebersole * @author Steve Ebersole
*
* @deprecated This is the legacy Ant-task Hibernate provided historically to
* perform its old-school bytecode instrumentation. That has been replaced wholesale
* with a new approach to bytecode manipulation offering 3 build-time variations for Ant,
* Maven and Gradle.
*
* @see EnhancementTask
*/ */
public class InstrumentTask extends BasicInstrumentationTask { @Deprecated
@Override @SuppressWarnings("unused")
protected Instrumenter buildInstrumenter(Logger logger, Instrumenter.Options options) { public class InstrumentTask extends EnhancementTask {
return new JavassistInstrumenter( logger, options ); public InstrumentTask() {
DeprecationLogger.DEPRECATION_LOGGER.logDeprecatedInstrumentTask( InstrumentTask.class, EnhancementTask.class );
} }
} }