Skip to content

Upgrade to Velocity Engine 2.0 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ limitations under the License.
<artifactId>plexus-components</artifactId>
<groupId>org.codehaus.plexus</groupId>
<version>6.5</version>
<relativePath/>
</parent>

<artifactId>plexus-velocity</artifactId>
Expand All @@ -46,6 +47,7 @@ limitations under the License.
</distributionManagement>

<properties>
<slf4j.version>1.7.25</slf4j.version>
<project.build.outputTimestamp>2020-01-20T18:52:37Z</project.build.outputTimestamp>
</properties>

Expand All @@ -55,14 +57,20 @@ limitations under the License.
<artifactId>plexus-container-default</artifactId>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
* limitations under the License.
*/

import java.util.Enumeration;
import java.util.Properties;

import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.log.LogChute;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
Expand All @@ -49,7 +46,7 @@
*/
public class DefaultVelocityComponent
extends AbstractLogEnabled
implements VelocityComponent, Initializable, LogChute
implements VelocityComponent, Initializable
{
private VelocityEngine engine;

Expand All @@ -63,24 +60,11 @@ public void initialize()
throws InitializationException
{
engine = new VelocityEngine();

// avoid "unable to find resource 'VM_global_library.vm' in any resource loader."
engine.setProperty( RuntimeConstants.VM_LIBRARY, "" );

engine.setProperty( RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, this );

if ( properties != null )
{
for ( Enumeration<?> e = properties.propertyNames(); e.hasMoreElements(); )
{
String key = e.nextElement().toString();

String value = properties.getProperty( key );

engine.setProperty( key, value );

getLogger().debug( "Setting property: " + key + " => '" + value + "'." );
}
engine.setProperties( properties );
}

try
Expand All @@ -93,86 +77,9 @@ public void initialize()
}
}

// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------

public VelocityEngine getEngine()
{
return engine;
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------

private RuntimeServices runtimeServices;

public void init( RuntimeServices runtimeServices )
{
this.runtimeServices = runtimeServices;
}

public void log(int level, String message)
{
switch ( level )
{
case LogChute.WARN_ID:
getLogger().warn( message );
break;
case LogChute.INFO_ID:
getLogger().info( message );
break;
case LogChute.DEBUG_ID:
case LogChute.TRACE_ID:
getLogger().debug( message );
break;
case LogChute.ERROR_ID:
getLogger().error( message );
break;
default:
getLogger().debug( message );
break;
}
}

public void log(int level, String message, Throwable t)
{
switch ( level )
{
case LogChute.WARN_ID:
getLogger().warn( message, t );
break;
case LogChute.INFO_ID:
getLogger().info( message, t );
break;
case LogChute.DEBUG_ID:
case LogChute.TRACE_ID:
getLogger().debug( message, t );
break;
case LogChute.ERROR_ID:
getLogger().error( message, t );
break;
default:
getLogger().debug( message, t );
break;
}
}

public boolean isLevelEnabled( int level )
{
switch ( level )
{
case LogChute.WARN_ID:
return getLogger().isWarnEnabled();
case LogChute.INFO_ID:
return getLogger().isInfoEnabled();
case LogChute.DEBUG_ID:
case LogChute.TRACE_ID:
return getLogger().isDebugEnabled();
case LogChute.ERROR_ID:
return getLogger().isErrorEnabled();
default:
return getLogger().isDebugEnabled();
}
}
}
91 changes: 0 additions & 91 deletions src/main/java/org/codehaus/plexus/velocity/SiteResourceLoader.java

This file was deleted.

4 changes: 2 additions & 2 deletions src/site/xdoc/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<p>A typical use:
<source>
VelocityContext context = new VelocityContext();
VelocityComponent velocityComponent = (DefaultVelocityComponent) lookup( VelocityComponent.ROLE );
VelocityComponent velocityComponent = (VelocityComponent) lookup( VelocityComponent.ROLE );
Template template = velocityComponent.getEngine().getTemplate( "path to your template" );
StringWriter writer = new StringWriter();
template.merge( context, writer );</source>
Expand Down Expand Up @@ -45,7 +45,7 @@ template.merge( context, writer );</source>
</configuration>
</component>]]></source>
</p>
<p>See <a href="http://velocity.apache.org/engine/releases/velocity-1.7/developer-guide.html#Velocity_Configuration_Keys_and_Values">Velocity Configuration Keys and Values</a>
<p>See <a href="https://velocity.apache.org/engine/2.0/configuration.html">Velocity Configuration</a>
reference documentation for details on available configurations.</p>
</subsection>
</section>
Expand Down
10 changes: 0 additions & 10 deletions src/test/log4j.properties

This file was deleted.