You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/06/04 12:56:29 UTC
[maven-doxia-sitetools] 01/01: [DOXIASITETOOLS-230] Upgrade to
Velocity Engine 2.0
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch DOXIASITETOOLS-230
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git
commit 8fff1b53a739d7effb4f510e55a0036a1ed66964
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Fri Jun 4 14:56:10 2021 +0200
[DOXIASITETOOLS-230] Upgrade to Velocity Engine 2.0
---
doxia-doc-renderer/pom.xml | 14 +--
.../docrenderer/AbstractDocumentRenderer.java | 7 +-
doxia-site-renderer/pom.xml | 44 ++------
.../doxia/siterenderer/SkinResourceLoader.java | 125 ---------------------
.../doxia/siterenderer/SkinResourceLoaderTest.java | 63 -----------
.../src/test/resources/log4j.properties | 24 ----
pom.xml | 22 +++-
7 files changed, 36 insertions(+), 263 deletions(-)
diff --git a/doxia-doc-renderer/pom.xml b/doxia-doc-renderer/pom.xml
index da2a5bd..a94fa0a 100644
--- a/doxia-doc-renderer/pom.xml
+++ b/doxia-doc-renderer/pom.xml
@@ -114,19 +114,17 @@ under the License.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-velocity</artifactId>
- <version>1.2</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-api</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<!-- misc -->
<dependency>
<groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
+ <artifactId>velocity-engine-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
</dependency>
<!-- misc -->
diff --git a/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java b/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java
index bc9f7e5..4674def 100644
--- a/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java
+++ b/doxia-doc-renderer/src/main/java/org/apache/maven/doxia/docrenderer/AbstractDocumentRenderer.java
@@ -59,7 +59,6 @@ import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.XmlStreamReader;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import org.codehaus.plexus.velocity.SiteResourceLoader;
import org.codehaus.plexus.velocity.VelocityComponent;
/**
@@ -512,7 +511,7 @@ public abstract class AbstractDocumentRenderer
{
reader = getVelocityReader( f, ( (XmlStreamReader) reader ).getEncoding(), context );
}
- if ( context != null && Boolean.TRUE.equals( (Boolean) context.get( "validate" ) ) )
+ if ( context != null && Boolean.TRUE.equals( context.get( "validate" ) ) )
{
reader = validate( reader, fullDocPath );
}
@@ -668,8 +667,8 @@ public abstract class AbstractDocumentRenderer
{
getLogger().debug( "Velocity render for " + f.getAbsolutePath() );
}
-
- SiteResourceLoader.setResource( f.getAbsolutePath() );
+// TODO
+// SiteResourceLoader.setResource( f.getAbsolutePath() );
Context velocityContext = new VelocityContext();
diff --git a/doxia-site-renderer/pom.xml b/doxia-site-renderer/pom.xml
index ba4c0f6..8246b1b 100644
--- a/doxia-site-renderer/pom.xml
+++ b/doxia-site-renderer/pom.xml
@@ -124,44 +124,11 @@ under the License.
<!-- misc -->
<dependency>
<groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
+ <artifactId>velocity-engine-core</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-tools</artifactId>
- <version>2.0</version>
- <exclusions>
- <!-- exclude VelocityView and VelocityStruts specific dependencies -->
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.struts</groupId>
- <artifactId>struts-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.struts</groupId>
- <artifactId>struts-taglib</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.struts</groupId>
- <artifactId>struts-tiles</artifactId>
- </exclusion>
- <exclusion>
- <groupId>sslext</groupId>
- <artifactId>sslext</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-validator</groupId>
- <artifactId>commons-validator</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2.2</version>
+ <groupId>org.apache.velocity.tools</groupId>
+ <artifactId>velocity-tools-generic</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
@@ -181,6 +148,11 @@ under the License.
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-core</artifactId>
<version>${doxiaVersion}</version>
diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SkinResourceLoader.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SkinResourceLoader.java
deleted file mode 100644
index e8870de..0000000
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SkinResourceLoader.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.apache.maven.doxia.siterenderer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.velocity.runtime.resource.Resource;
-import org.apache.velocity.runtime.resource.loader.ResourceLoader;
-import org.apache.velocity.exception.ResourceNotFoundException;
-import org.apache.commons.collections.ExtendedProperties;
-import org.codehaus.plexus.util.IOUtil;
-
-/**
- * Skin resource loader: gets content from context classloader, which should contain skin artifact,
- * and normalizes newlines
- * (see <a href="https://issues.apache.org/jira/browse/DOXIASITETOOLS-87">DOXIASITETOOLS-87</a>).
- *
- * @author Hervé Boutemy
- */
-@Deprecated
-public class SkinResourceLoader
- extends ResourceLoader
-{
- public void init( ExtendedProperties configuration )
- {
- }
-
- public synchronized InputStream getResourceStream( String name )
- throws ResourceNotFoundException
- {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
- if ( name.startsWith( "/" ) )
- {
- name = name.substring( 1 );
- }
-
- return normalizeNewline( classLoader.getResourceAsStream( name ) );
- }
-
- InputStream normalizeNewline( InputStream in )
- throws ResourceNotFoundException
- {
- if ( in == null )
- {
- return null;
- }
-
- try
- {
- byte[] content = IOUtil.toByteArray( in );
-
- // following code based on org.apache.maven.doxia.sink.AbstractSink.unifyEOLs(String)
-
- byte[] eol = System.getProperty( "line.separator" ).getBytes();
-
- final int size = content.length;
-
- ByteArrayOutputStream out = new ByteArrayOutputStream( size );
-
- for ( int i = 0; i < size; i++ )
- {
- byte b = content[i];
-
- if ( b == '\r' )
- {
- if ( ( i + 1 ) < size && content[i + 1] == '\n' )
- {
- i++;
- }
-
- out.write( eol );
- }
- else if ( b == '\n' )
- {
- out.write( eol );
- }
- else
- {
- out.write( b );
- }
- }
-
- return new ByteArrayInputStream( out.toByteArray() );
- }
- catch ( IOException ioe )
- {
- throw new ResourceNotFoundException( "cannot read resource", ioe );
- }
- finally
- {
- IOUtil.close( in );
- }
- }
-
- public boolean isSourceModified( Resource resource )
- {
- return false;
- }
-
- public long getLastModified( Resource resource )
- {
- return 0;
- }
-}
diff --git a/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/SkinResourceLoaderTest.java b/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/SkinResourceLoaderTest.java
deleted file mode 100644
index 6f7a5e9..0000000
--- a/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/SkinResourceLoaderTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package org.apache.maven.doxia.siterenderer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.maven.doxia.sink.impl.AbstractSink;
-import org.codehaus.plexus.util.IOUtil;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class SkinResourceLoaderTest
-{
- private SkinResourceLoader skinResourceLoader = new SkinResourceLoader();
-
- @Test
- public void testNormalizeNewline() throws Exception
- {
- String EOL = AbstractSink.EOL;
- String EOL_MACOS9 = "\r";
- String EOL_UNIX = "\n";
- String EOL_WIN = "\r\n";
-
- assertEquals( "Hello " + EOL + " world", normalizeNewline( "Hello " + EOL_MACOS9 + " world" ) );
- assertEquals( "Hello " + EOL + " world", normalizeNewline( "Hello " + EOL_UNIX + " world" ) );
- assertEquals( "Hello " + EOL + " world", normalizeNewline( "Hello " + EOL_WIN + " world" ) );
-
- assertEquals( "Hello world" + EOL, normalizeNewline( "Hello world" + EOL_MACOS9 ) );
- assertEquals( "Hello world" + EOL, normalizeNewline( "Hello world" + EOL_UNIX ) );
- assertEquals( "Hello world" + EOL, normalizeNewline( "Hello world" + EOL_WIN ) );
-
- assertEquals( EOL + "Hello world", normalizeNewline( EOL_MACOS9 + "Hello world" ) );
- assertEquals( EOL + "Hello world", normalizeNewline( EOL_UNIX + "Hello world" ) );
- assertEquals( EOL + "Hello world", normalizeNewline( EOL_WIN + "Hello world" ) );
- }
-
- private String normalizeNewline( String text ) throws IOException
- {
- InputStream in = new ByteArrayInputStream( text.getBytes() );
- InputStream out = skinResourceLoader.normalizeNewline( in );
- return IOUtil.toString( out );
- }
-}
diff --git a/doxia-site-renderer/src/test/resources/log4j.properties b/doxia-site-renderer/src/test/resources/log4j.properties
deleted file mode 100644
index 45cd5b3..0000000
--- a/doxia-site-renderer/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-log4j.rootCategory=INFO, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%5p [%c{1}:%L] %d{ISO8601} - %m%n
-
-log4j.logger.com.gargoylesoftware.htmlunit=ERROR
diff --git a/pom.xml b/pom.xml
index a63c002..725f264 100644
--- a/pom.xml
+++ b/pom.xml
@@ -168,7 +168,13 @@ under the License.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-velocity</artifactId>
- <version>1.2</version>
+ <version>1.3-SNAPSHOT</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
@@ -178,8 +184,13 @@ under the License.
<!-- misc -->
<dependency>
<groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <version>1.7</version>
+ <artifactId>velocity-engine-core</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.velocity.tools</groupId>
+ <artifactId>velocity-tools-generic</artifactId>
+ <version>3.0</version>
</dependency>
<!-- Test -->
<dependency>
@@ -187,6 +198,11 @@ under the License.
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.7.25</version>
+ </dependency>
</dependencies>
</dependencyManagement>