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 /vespa_application_maven_archetype_plugin |
Publish
Diffstat (limited to 'vespa_application_maven_archetype_plugin')
14 files changed, 327 insertions, 0 deletions
diff --git a/vespa_application_maven_archetype_plugin/.gitignore b/vespa_application_maven_archetype_plugin/.gitignore new file mode 100644 index 00000000000..12251442258 --- /dev/null +++ b/vespa_application_maven_archetype_plugin/.gitignore @@ -0,0 +1,2 @@ +/target +/pom.xml.build diff --git a/vespa_application_maven_archetype_plugin/OWNERS b/vespa_application_maven_archetype_plugin/OWNERS new file mode 100644 index 00000000000..3b2ba1ede81 --- /dev/null +++ b/vespa_application_maven_archetype_plugin/OWNERS @@ -0,0 +1 @@ +gjoranv diff --git a/vespa_application_maven_archetype_plugin/pom.xml b/vespa_application_maven_archetype_plugin/pom.xml new file mode 100644 index 00000000000..e1c2fb8e89a --- /dev/null +++ b/vespa_application_maven_archetype_plugin/pom.xml @@ -0,0 +1,42 @@ +<?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>vespa_application_maven_archetype_plugin</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> + <include>archetype-resources/components/pom.xml</include> + </includes> + </resource> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + <excludes> + <exclude>archetype-resources/components/pom.xml</exclude> + <exclude>archetype-resources/pom.xml</exclude> + </excludes> + </resource> + </resources> + </build> +</project> diff --git a/vespa_application_maven_archetype_plugin/src/main/resources/META-INF/maven/archetype-metadata.xml b/vespa_application_maven_archetype_plugin/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 00000000000..6f1abc5ba22 --- /dev/null +++ b/vespa_application_maven_archetype_plugin/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,33 @@ +<?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>components/src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + <fileSet filtered="true" encoding="UTF-8"> + <directory>src/main/application</directory> + <includes> + <include>**/*.xml</include> + <include>**/*.json</include> + </includes> + </fileSet> + <fileSet filtered="true" encoding="UTF-8"> + <directory>components</directory> + <includes> + <include>**/*.xml</include> + </includes> + </fileSet> + <fileSet filtered="true" encoding="UTF-8"> + <directory>components/src/main/resources</directory> + <includes> + <include>**/*.def</include> + </includes> + </fileSet> + </fileSets> +</archetype-descriptor> diff --git a/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/components/pom.xml b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/components/pom.xml new file mode 100644 index 00000000000..ce5e0399434 --- /dev/null +++ b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/components/pom.xml @@ -0,0 +1,57 @@ +<?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> + + <!-- See vespa documentation container-components.html for help --> + + <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/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/components/src/main/java/ExampleDocumentProcessor.java b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/components/src/main/java/ExampleDocumentProcessor.java new file mode 100644 index 00000000000..bf18b53909d --- /dev/null +++ b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/components/src/main/java/ExampleDocumentProcessor.java @@ -0,0 +1,41 @@ +// 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.document.*; +import com.yahoo.docproc.*; + +import com.yahoo.example.ExampleConfig; +import com.yahoo.document.datatypes.StringFieldValue; + +/** + * An example document processor. + * + * @author Joe Developer + */ +public class ExampleDocumentProcessor extends DocumentProcessor { + private final String message; + private final String field = "message"; + + public ExampleDocumentProcessor(ExampleConfig config) { + message = config.message(); + } + + + public Progress process(Processing processing) { + for (DocumentOperation op : processing.getDocumentOperations()) { + if (op instanceof DocumentPut) { + DocumentPut put = (DocumentPut) op; + Document document = put.getDocument(); + document.setFieldValue(field, new StringFieldValue(message)); + } else if (base instanceof DocumentUpdate) { + DocumentUpdate update = (DocumentUpdate) base; + //TODO do something to 'update' here + } else if (base instanceof DocumentRemove) { + DocumentRemove remove = (DocumentRemove) base; + //TODO do something to 'remove' here + } + } + return Progress.DONE; + } + +} diff --git a/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/components/src/main/java/ExampleSearcher.java b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/components/src/main/java/ExampleSearcher.java new file mode 100644 index 00000000000..2eb27f6d4c9 --- /dev/null +++ b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/components/src/main/java/ExampleSearcher.java @@ -0,0 +1,31 @@ +// 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.search.Query; +import com.yahoo.search.Result; +import com.yahoo.search.Searcher; +import com.yahoo.search.result.Hit; +import com.yahoo.search.searchchain.Execution; +import com.yahoo.example.ExampleConfig; + +/** + * A searcher adding a new hit. + * + * @author Joe Developer + */ +public class ExampleSearcher extends Searcher { + private final String message; + + public ExampleSearcher(ExampleConfig config) { + message = config.message(); + } + + public Result search(Query query,Execution execution) { + Hit hit = new Hit("ExampleHit"); + hit.setField("message", message); + + Result result = execution.search(query); + result.hits().add(hit); + return result; + } +} diff --git a/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/components/src/main/resources/configdefinitions/example.def b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/components/src/main/resources/configdefinitions/example.def new file mode 100644 index 00000000000..471f6997ae1 --- /dev/null +++ b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/components/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/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/pom.xml b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 00000000000..214f52880cf --- /dev/null +++ b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,67 @@ +<?xml version="1.0"?> +<!-- 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> + <groupId>test</groupId> + <artifactId>test-application</artifactId> + <packaging>pom</packaging> + <version>${vespa_version}</version> + <name>application</name> + + <modules> + <module>components</module> + </modules> + <pluginRepositories> + <pluginRepository> + <id>maven2-repository.dev.java.net</id> + <url>http://download.java.net/maven/2</url> + <snapshots> + <enabled>false</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.9</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.1</version> + <configuration> + <source>1.8</source> + <target>1.8</target> + <showDeprecation>true</showDeprecation> + <showWarnings>true</showWarnings> + <optimize>true</optimize> + <compilerArgument>-Xlint:unchecked</compilerArgument> + </configuration> + </plugin> + <plugin> + <groupId>com.yahoo.vespa</groupId> + <artifactId>vespa-application-maven-plugin</artifactId> + <version>${vespa_version}</version> + <executions> + <execution> + <goals> + <goal>packageApplication</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <properties> + <test.hide>true</test.hide> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> +</project> diff --git a/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/src/main/application/hosts.xml b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/src/main/application/hosts.xml new file mode 100644 index 00000000000..3ab86a21aef --- /dev/null +++ b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/src/main/application/hosts.xml @@ -0,0 +1,7 @@ +<?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. --> +<hosts> + <host name="localhost"> + <alias>node1</alias> + </host> +</hosts> diff --git a/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/src/main/application/package.json b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/src/main/application/package.json new file mode 100755 index 00000000000..aab8330a58c --- /dev/null +++ b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/src/main/application/package.json @@ -0,0 +1,7 @@ +{ + "name": "${artifactId}", + "version": "${version}", + "dependencies": { + "connect": ">=0.2.4" + }, +} diff --git a/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/src/main/application/services.xml b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/src/main/application/services.xml new file mode 100644 index 00000000000..a7ffb4446d5 --- /dev/null +++ b/vespa_application_maven_archetype_plugin/src/main/resources/archetype-resources/src/main/application/services.xml @@ -0,0 +1,30 @@ +<?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. --> +<services version="1.0"> + + <admin version="2.0"> + <adminserver hostalias="node1"/> + </admin> + + <search version="2.0"> + <qrservers> + <cluster name="default"> + <nodes> + <node hostalias="node1" /> + </nodes> + + <searchchains> + <searchchain id="default"> + <searcher id="${package}.ExampleSearcher"> + <config name="example"> + <message>Hello, world</message> + </config> + </searcher> + </searchchain> + </searchchains> + + </cluster> + </qrservers> + </search> + +</services> diff --git a/vespa_application_maven_archetype_plugin/src/test/resources/projects/basic/archetype.properties b/vespa_application_maven_archetype_plugin/src/test/resources/projects/basic/archetype.properties new file mode 100644 index 00000000000..c4510cfb2cd --- /dev/null +++ b/vespa_application_maven_archetype_plugin/src/test/resources/projects/basic/archetype.properties @@ -0,0 +1,4 @@ +version=6-SNAPSHOT +groupId=com.yahoo.vespa +artifactId=vespa-application-plugin +package=archetype.test
\ No newline at end of file diff --git a/vespa_application_maven_archetype_plugin/src/test/resources/projects/basic/goal.txt b/vespa_application_maven_archetype_plugin/src/test/resources/projects/basic/goal.txt new file mode 100644 index 00000000000..1ab1a926ff0 --- /dev/null +++ b/vespa_application_maven_archetype_plugin/src/test/resources/projects/basic/goal.txt @@ -0,0 +1 @@ +Create vespa application along with plugins for vespa container(e.g. searcher, docproc, handler). |