diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /jdisc_maven_archetype_component |
Publish
Diffstat (limited to 'jdisc_maven_archetype_component')
11 files changed, 200 insertions, 0 deletions
diff --git a/jdisc_maven_archetype_component/.gitignore b/jdisc_maven_archetype_component/.gitignore new file mode 100644 index 00000000000..12251442258 --- /dev/null +++ b/jdisc_maven_archetype_component/.gitignore @@ -0,0 +1,2 @@ +/target +/pom.xml.build diff --git a/jdisc_maven_archetype_component/OWNERS b/jdisc_maven_archetype_component/OWNERS new file mode 100644 index 00000000000..3b2ba1ede81 --- /dev/null +++ b/jdisc_maven_archetype_component/OWNERS @@ -0,0 +1 @@ +gjoranv diff --git a/jdisc_maven_archetype_component/pom.xml b/jdisc_maven_archetype_component/pom.xml new file mode 100644 index 00000000000..6e4d5221859 --- /dev/null +++ b/jdisc_maven_archetype_component/pom.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<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> + <groupId>com.yahoo.vespa</groupId> + <artifactId>parent</artifactId> + <version>6-SNAPSHOT</version> + <relativePath>../parent/pom.xml</relativePath> + </parent> + <!-- Package name must contain _maven_archetype --> + <artifactId>jdisc_maven_archetype_component</artifactId> + <version>6-SNAPSHOT</version> + <packaging>maven-archetype</packaging> + <build> + <extensions> + <extension> + <groupId>org.apache.maven.archetype</groupId> + <artifactId>archetype-packaging</artifactId> + </extension> + </extensions> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + <includes> + <include>archetype-resources/pom.xml</include> + </includes> + </resource> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + <excludes> + <exclude>archetype-resources/pom.xml</exclude> + </excludes> + </resource> + </resources> + </build> +</project> diff --git a/jdisc_maven_archetype_component/src/main/resources/META-INF/maven/archetype-metadata.xml b/jdisc_maven_archetype_component/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 00000000000..5733e99880d --- /dev/null +++ b/jdisc_maven_archetype_component/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="sample-container-plugin" + xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <fileSets> + <fileSet filtered="true" packaged="true" encoding="UTF-8"> + <directory>src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + <fileSet filtered="true" encoding="UTF-8"> + <directory>src/main/resources</directory> + <includes> + <include>**/*.def</include> + </includes> + </fileSet> + </fileSets> +</archetype-descriptor> diff --git a/jdisc_maven_archetype_component/src/main/resources/archetype-resources/pom.xml b/jdisc_maven_archetype_component/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 00000000000..77d7d8c6c39 --- /dev/null +++ b/jdisc_maven_archetype_component/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<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/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>\${groupId}</groupId> + <artifactId>\${artifactId}</artifactId> <!-- Also used as Bundle-SymbolicName --> + <version>\${version}</version> <!-- Also used as the Bundle-Version --> + <packaging>container-plugin</packaging> + <name>sample container plugin</name> + + <description>Starting point for creating a maven container plugin.</description> + + <build> + <plugins> + <plugin> + <groupId>com.yahoo.vespa</groupId> + <artifactId>bundle-plugin</artifactId> + <version>${vespa_version}</version> + <extensions>true</extensions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <showDeprecation>true</showDeprecation> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.9</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>com.yahoo.vespa</groupId> + <artifactId>container-dev</artifactId> + <version>${vespa_version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> +</project> diff --git a/jdisc_maven_archetype_component/src/main/resources/archetype-resources/src/main/java/ExampleProcessor.java b/jdisc_maven_archetype_component/src/main/resources/archetype-resources/src/main/java/ExampleProcessor.java new file mode 100644 index 00000000000..88ebe04bd20 --- /dev/null +++ b/jdisc_maven_archetype_component/src/main/resources/archetype-resources/src/main/java/ExampleProcessor.java @@ -0,0 +1,23 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package ${package}; + +import com.yahoo.processing.*; +import com.yahoo.processing.execution.Execution; + +public class ExampleProcessor extends Processor { + + @Override + public Response process(Request request, Execution execution) { + // Process the Request: + request.properties().set("foo","bar"); + + // Pass it down the chain to get a response + Response response=execution.process(request); + + // process the response + response.data().add(new StringData(request,"Hello, world!")); + + return response; + } + +}
\ No newline at end of file diff --git a/jdisc_maven_archetype_component/src/main/resources/archetype-resources/src/main/java/StringData.java b/jdisc_maven_archetype_component/src/main/resources/archetype-resources/src/main/java/StringData.java new file mode 100644 index 00000000000..d6363409dc8 --- /dev/null +++ b/jdisc_maven_archetype_component/src/main/resources/archetype-resources/src/main/java/StringData.java @@ -0,0 +1,26 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package ${package}; + +import com.yahoo.processing.Request; +import com.yahoo.processing.response.AbstractData; + +/** A simple response data type */ +public class StringData extends AbstractData { + + private String string; + + public StringData(Request request, String string) { + super(request); + this.string = string; + } + + public void setString(String string) { + this.string = string; + } + + @Override + public String toString() { + return string; + } + +}
\ No newline at end of file diff --git a/jdisc_maven_archetype_component/src/main/resources/archetype-resources/src/main/resources/configdefinitions/example.def b/jdisc_maven_archetype_component/src/main/resources/archetype-resources/src/main/resources/configdefinitions/example.def new file mode 100644 index 00000000000..471f6997ae1 --- /dev/null +++ b/jdisc_maven_archetype_component/src/main/resources/archetype-resources/src/main/resources/configdefinitions/example.def @@ -0,0 +1,4 @@ +# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +version=1 +namespace=example +message string default="Hello, World!" diff --git a/jdisc_maven_archetype_component/src/main/resources/archetype-resources/src/test/java/ExampleProcessorTest.java b/jdisc_maven_archetype_component/src/main/resources/archetype-resources/src/test/java/ExampleProcessorTest.java new file mode 100644 index 00000000000..1107cde6387 --- /dev/null +++ b/jdisc_maven_archetype_component/src/main/resources/archetype-resources/src/test/java/ExampleProcessorTest.java @@ -0,0 +1,25 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package ${package}; + +import com.yahoo.component.chain.Chain; +import com.yahoo.processing.Processor; +import com.yahoo.processing.Request; +import com.yahoo.processing.Response; +import com.yahoo.processing.execution.Execution; +import org.junit.Test; + +import static org.junit.Assert.assertThat; +import static org.junit.matchers.JUnitMatchers.containsString; + + +public class ExampleProcessorTest { + @Test + public void requireThatResultContainsHelloWorld() { + ExampleProcessor processor = new ExampleProcessor(); + Chain<Processor> chain = new Chain<Processor>(processor); + + Execution execution = Execution.createRoot(chain, 0, Execution.Environment.createEmpty()); + Response response = execution.process(new Request()); + assertThat(response.data().get(0).toString(), containsString("Hello, world!")); + } +} diff --git a/jdisc_maven_archetype_component/src/test/resources/projects/basic/archetype.properties b/jdisc_maven_archetype_component/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 00000000000..bada3a0669c --- /dev/null +++ b/jdisc_maven_archetype_component/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,3 @@ +version=6-SNAPSHOT +groupId=com.yahoo.vespa +artifactId=container-plugin diff --git a/jdisc_maven_archetype_component/src/test/resources/projects/basic/goal.txt b/jdisc_maven_archetype_component/src/test/resources/projects/basic/goal.txt new file mode 100644 index 00000000000..0ee40edb3f5 --- /dev/null +++ b/jdisc_maven_archetype_component/src/test/resources/projects/basic/goal.txt @@ -0,0 +1 @@ +Create plugins for vespa container(e.g. searcher, docproc, handler). |