Skip to content

Commit

Permalink
Merge pull request #67 from codehaus-plexus/update-component
Browse files Browse the repository at this point in the history
Changes:
* update parent (spotless applied as well)
* drop p-c-d
* make it JSR330
* drop plexus XML mumbo jumbo
  • Loading branch information
cstamas committed Dec 16, 2023
2 parents f7d9d35 + 2a90dbc commit e0c3648
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 214 deletions.
54 changes: 39 additions & 15 deletions pom.xml
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2001-2006 Codehaus Foundation.
Expand All @@ -13,15 +14,13 @@ 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>plexus-components</artifactId>
<groupId>org.codehaus.plexus</groupId>
<version>10.0</version>
<relativePath />
<artifactId>plexus-components</artifactId>
<version>14.2</version>
</parent>

<artifactId>plexus-velocity</artifactId>
Expand All @@ -32,8 +31,8 @@ limitations under the License.
<scm>
<connection>scm:git:git@github.com:codehaus-plexus/plexus-velocity.git</connection>
<developerConnection>scm:git:git@github.com:codehaus-plexus/plexus-velocity.git</developerConnection>
<url>http://github.com/codehaus-plexus/plexus-velocity</url>
<tag>HEAD</tag>
<url>http://github.com/codehaus-plexus/plexus-velocity</url>
</scm>
<issueManagement>
<system>github</system>
Expand All @@ -52,15 +51,34 @@ limitations under the License.
</properties>

<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.3</version>
</dependency>

<!-- Used by Velocity at runtime -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4jVersion}</version>
<scope>runtime</scope>
</dependency>

<!-- This is a Sisu Component, DI container should be provided by consumer -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.inject</artifactId>
<version>0.9.0.M2</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
Expand All @@ -69,33 +87,39 @@ limitations under the License.
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4jVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4jVersion}</version>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>6.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.sisu</groupId>
<artifactId>sisu-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-publish-plugin</artifactId>
<configuration>
<content>${project.reporting.outputDirectory}</content><!-- mono-module doesn't require site:stage -->
<content>${project.reporting.outputDirectory}</content>
<!-- mono-module doesn't require site:stage -->
</configuration>
<executions>
<execution>
<id>scm-publish</id>
<phase>site-deploy</phase><!-- deploy site with maven-scm-publish-plugin -->
<!-- deploy site with maven-scm-publish-plugin -->
<goals>
<goal>publish-scm</goal>
</goals>
<phase>site-deploy</phase>
</execution>
</executions>
</plugin>
Expand Down

This file was deleted.

Expand Up @@ -22,8 +22,8 @@
* The VelocityComponent API to access <a href="http://velocity.apache.org/engine/">Apache Velocity Engine</a>
* configured through Plexus.
*/
public interface VelocityComponent
{
public interface VelocityComponent {
@Deprecated
String ROLE = VelocityComponent.class.getName();

VelocityEngine getEngine();
Expand Down
@@ -0,0 +1,29 @@
package org.codehaus.plexus.velocity;

/*
* Copyright 2001-2016 Codehaus Foundation.
*
* Licensed 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.util.Properties;

/**
* The VelocityComponent configuration that may configure {@link java.util.Properties} prior having them used to init
* Velocity Engine. This component is optional, is not needed if default are sufficient.
*
* @since TBD
*/
public interface VelocityComponentConfigurator {
void configure(Properties properties);
}
@@ -0,0 +1,73 @@
package org.codehaus.plexus.velocity.internal;

/*
* Copyright 2001-2016 Codehaus Foundation.
*
* Licensed 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 javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import java.util.Properties;

import org.apache.velocity.app.VelocityEngine;
import org.codehaus.plexus.velocity.VelocityComponent;
import org.codehaus.plexus.velocity.VelocityComponentConfigurator;
import org.eclipse.sisu.Nullable;

/**
* Default component implementation. The presence of {@link VelocityComponentConfigurator} is optional.
*/
@Singleton
@Named
public class DefaultVelocityComponent implements VelocityComponent {
private final VelocityEngine engine;

@Inject
public DefaultVelocityComponent(@Nullable VelocityComponentConfigurator componentConfigurator) {
Properties properties = new Properties();

// fill in defaults
properties.setProperty("resource.loaders", "classpath,file");
properties.setProperty(
"resource.loader.classpath.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
properties.setProperty(
"resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
properties.setProperty("resource.loader.file.path", "");
properties.setProperty("runtime.log.log_invalid_references", "false");
properties.setProperty("resource.manager.log_when_found", "false");
properties.setProperty(
"event_handler.include.class", "org.apache.velocity.app.event.implement.IncludeRelativePath");
properties.setProperty("velocimacro.inline.replace_global", "true");
properties.setProperty("parser.space_gobbling", "bc");

// customize if needed
if (componentConfigurator != null) {
componentConfigurator.configure(properties);
}

VelocityEngine engine = new VelocityEngine();
engine.setProperties(properties);
engine.init();

this.engine = engine;
}

@Override
public VelocityEngine getEngine() {
return engine;
}
}
52 changes: 0 additions & 52 deletions src/main/resources/META-INF/plexus/components.xml

This file was deleted.

1 comment on commit e0c3648

@michael-o
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid merge commits. They add zero benefit, just clutter.

Please sign in to comment.