Skip to content

Commit e0c3648

Browse files
authored
Merge pull request #67 from codehaus-plexus/update-component
Changes: * update parent (spotless applied as well) * drop p-c-d * make it JSR330 * drop plexus XML mumbo jumbo
2 parents f7d9d35 + 2a90dbc commit e0c3648

File tree

10 files changed

+195
-214
lines changed

10 files changed

+195
-214
lines changed

pom.xml

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<!--
23
Copyright 2001-2006 Codehaus Foundation.
34
@@ -13,15 +14,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1314
See the License for the specific language governing permissions and
1415
limitations under the License.
1516
-->
16-
1717
<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">
1818
<modelVersion>4.0.0</modelVersion>
1919

2020
<parent>
21-
<artifactId>plexus-components</artifactId>
2221
<groupId>org.codehaus.plexus</groupId>
23-
<version>10.0</version>
24-
<relativePath />
22+
<artifactId>plexus-components</artifactId>
23+
<version>14.2</version>
2524
</parent>
2625

2726
<artifactId>plexus-velocity</artifactId>
@@ -32,8 +31,8 @@ limitations under the License.
3231
<scm>
3332
<connection>scm:git:[email protected]:codehaus-plexus/plexus-velocity.git</connection>
3433
<developerConnection>scm:git:[email protected]:codehaus-plexus/plexus-velocity.git</developerConnection>
35-
<url>http://github.com/codehaus-plexus/plexus-velocity</url>
3634
<tag>HEAD</tag>
35+
<url>http://github.com/codehaus-plexus/plexus-velocity</url>
3736
</scm>
3837
<issueManagement>
3938
<system>github</system>
@@ -52,15 +51,34 @@ limitations under the License.
5251
</properties>
5352

5453
<dependencies>
55-
<dependency>
56-
<groupId>org.codehaus.plexus</groupId>
57-
<artifactId>plexus-container-default</artifactId>
58-
</dependency>
5954
<dependency>
6055
<groupId>org.apache.velocity</groupId>
6156
<artifactId>velocity-engine-core</artifactId>
6257
<version>2.3</version>
6358
</dependency>
59+
60+
<!-- Used by Velocity at runtime -->
61+
<dependency>
62+
<groupId>org.slf4j</groupId>
63+
<artifactId>slf4j-api</artifactId>
64+
<version>${slf4jVersion}</version>
65+
<scope>runtime</scope>
66+
</dependency>
67+
68+
<!-- This is a Sisu Component, DI container should be provided by consumer -->
69+
<dependency>
70+
<groupId>javax.inject</groupId>
71+
<artifactId>javax.inject</artifactId>
72+
<version>1</version>
73+
<scope>provided</scope>
74+
</dependency>
75+
<dependency>
76+
<groupId>org.eclipse.sisu</groupId>
77+
<artifactId>org.eclipse.sisu.inject</artifactId>
78+
<version>0.9.0.M2</version>
79+
<scope>provided</scope>
80+
</dependency>
81+
6482
<dependency>
6583
<groupId>org.junit.jupiter</groupId>
6684
<artifactId>junit-jupiter</artifactId>
@@ -69,33 +87,39 @@ limitations under the License.
6987
</dependency>
7088
<dependency>
7189
<groupId>org.slf4j</groupId>
72-
<artifactId>slf4j-api</artifactId>
90+
<artifactId>slf4j-simple</artifactId>
7391
<version>${slf4jVersion}</version>
7492
<scope>test</scope>
7593
</dependency>
7694
<dependency>
77-
<groupId>org.slf4j</groupId>
78-
<artifactId>slf4j-simple</artifactId>
79-
<version>${slf4jVersion}</version>
95+
<groupId>com.google.inject</groupId>
96+
<artifactId>guice</artifactId>
97+
<version>6.0.0</version>
8098
<scope>test</scope>
8199
</dependency>
82100
</dependencies>
83101

84102
<build>
85103
<plugins>
104+
<plugin>
105+
<groupId>org.eclipse.sisu</groupId>
106+
<artifactId>sisu-maven-plugin</artifactId>
107+
</plugin>
86108
<plugin>
87109
<groupId>org.apache.maven.plugins</groupId>
88110
<artifactId>maven-scm-publish-plugin</artifactId>
89111
<configuration>
90-
<content>${project.reporting.outputDirectory}</content><!-- mono-module doesn't require site:stage -->
112+
<content>${project.reporting.outputDirectory}</content>
113+
<!-- mono-module doesn't require site:stage -->
91114
</configuration>
92115
<executions>
93116
<execution>
94117
<id>scm-publish</id>
95-
<phase>site-deploy</phase><!-- deploy site with maven-scm-publish-plugin -->
118+
<!-- deploy site with maven-scm-publish-plugin -->
96119
<goals>
97120
<goal>publish-scm</goal>
98121
</goals>
122+
<phase>site-deploy</phase>
99123
</execution>
100124
</executions>
101125
</plugin>

src/main/java/org/codehaus/plexus/velocity/DefaultVelocityComponent.java

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/main/java/org/codehaus/plexus/velocity/VelocityComponent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
* The VelocityComponent API to access <a href="http://velocity.apache.org/engine/">Apache Velocity Engine</a>
2323
* configured through Plexus.
2424
*/
25-
public interface VelocityComponent
26-
{
25+
public interface VelocityComponent {
26+
@Deprecated
2727
String ROLE = VelocityComponent.class.getName();
2828

2929
VelocityEngine getEngine();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.codehaus.plexus.velocity;
2+
3+
/*
4+
* Copyright 2001-2016 Codehaus Foundation.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import java.util.Properties;
20+
21+
/**
22+
* The VelocityComponent configuration that may configure {@link java.util.Properties} prior having them used to init
23+
* Velocity Engine. This component is optional, is not needed if default are sufficient.
24+
*
25+
* @since TBD
26+
*/
27+
public interface VelocityComponentConfigurator {
28+
void configure(Properties properties);
29+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package org.codehaus.plexus.velocity.internal;
2+
3+
/*
4+
* Copyright 2001-2016 Codehaus Foundation.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import javax.inject.Inject;
20+
import javax.inject.Named;
21+
import javax.inject.Singleton;
22+
23+
import java.util.Properties;
24+
25+
import org.apache.velocity.app.VelocityEngine;
26+
import org.codehaus.plexus.velocity.VelocityComponent;
27+
import org.codehaus.plexus.velocity.VelocityComponentConfigurator;
28+
import org.eclipse.sisu.Nullable;
29+
30+
/**
31+
* Default component implementation. The presence of {@link VelocityComponentConfigurator} is optional.
32+
*/
33+
@Singleton
34+
@Named
35+
public class DefaultVelocityComponent implements VelocityComponent {
36+
private final VelocityEngine engine;
37+
38+
@Inject
39+
public DefaultVelocityComponent(@Nullable VelocityComponentConfigurator componentConfigurator) {
40+
Properties properties = new Properties();
41+
42+
// fill in defaults
43+
properties.setProperty("resource.loaders", "classpath,file");
44+
properties.setProperty(
45+
"resource.loader.classpath.class",
46+
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
47+
properties.setProperty(
48+
"resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
49+
properties.setProperty("resource.loader.file.path", "");
50+
properties.setProperty("runtime.log.log_invalid_references", "false");
51+
properties.setProperty("resource.manager.log_when_found", "false");
52+
properties.setProperty(
53+
"event_handler.include.class", "org.apache.velocity.app.event.implement.IncludeRelativePath");
54+
properties.setProperty("velocimacro.inline.replace_global", "true");
55+
properties.setProperty("parser.space_gobbling", "bc");
56+
57+
// customize if needed
58+
if (componentConfigurator != null) {
59+
componentConfigurator.configure(properties);
60+
}
61+
62+
VelocityEngine engine = new VelocityEngine();
63+
engine.setProperties(properties);
64+
engine.init();
65+
66+
this.engine = engine;
67+
}
68+
69+
@Override
70+
public VelocityEngine getEngine() {
71+
return engine;
72+
}
73+
}

src/main/resources/META-INF/plexus/components.xml

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)