Skip to content

Commit

Permalink
plugin skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
president603 committed Apr 14, 2015
1 parent f68c516 commit 8e66be6
Show file tree
Hide file tree
Showing 18 changed files with 439 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Created by .ignore support plugin (hsz.mobi)
*.iml
target
.idea
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# teamcity-plugin-jmh
teamcity-plugin-jmh

TeamCity server-side plugin

This is an empty project to develop TeamCity plugin that operates on server-side only.

1. Implement
Put your implementing classes to "<artifactId>-server" module. Do not forget to update spring context file in 'main/resources/META-INF'. See TeamCity documentation for details.

2. Build
Issue 'mvn package' command from the root project to build your plugin. Resulting package <artifactId>.zip will be placed in 'target' directory.

3. Install
To install the plugin, put zip archive to 'plugins' dir under TeamCity data directory and restart the server.


33 changes: 33 additions & 0 deletions build/plugin-assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<assembly>
<id>plugin-assembly</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<files>
<file>
<source>target/teamcity-plugin.xml</source>
<outputDirectory>/</outputDirectory>
</file>
</files>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>com.presidentio:teamcity-plugin-jmh-server</include>
</includes>
<binaries>
<outputDirectory>server</outputDirectory>
<unpack>false</unpack>
<dependencySets>
<dependencySet>
<includes>
<include>*</include>
</includes>
</dependencySet>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
80 changes: 80 additions & 0 deletions build/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>teamcity-plugin-jmh</artifactId>
<groupId>com.presidentio</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>build</artifactId>
<packaging>pom</packaging>
<properties>
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
<teamcity.teamcity-plugin-jmh.plugin.version>snapshot-${maven.build.timestamp}</teamcity.teamcity-plugin-jmh.plugin.version>
<teamcity.teamcity-plugin-jmh.plugin.vendorName>Plugin vendor name</teamcity.teamcity-plugin-jmh.plugin.vendorName>
<teamcity.teamcity-plugin-jmh.plugin.vendorUrl>Plugin vendor URL</teamcity.teamcity-plugin-jmh.plugin.vendorUrl>
</properties>
<dependencies>
<dependency>
<groupId>com.presidentio</groupId>
<artifactId>teamcity-plugin-jmh-server</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${basedir}/../teamcity-plugin.xml</file>
<outputFile>${basedir}/target/teamcity-plugin.xml</outputFile>
<replacements>
<replacement>
<token>@Version@</token>
<value>${teamcity.teamcity-plugin-jmh.plugin.version}</value>
</replacement>
<replacement>
<token>@VendorName@</token>
<value>${teamcity.teamcity-plugin-jmh.plugin.vendorName}</value>
</replacement>
<replacement>
<token>@VendorURL@</token>
<value>${teamcity.teamcity-plugin-jmh.plugin.vendorUrl}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>teamcity-plugin-jmh</finalName>
<outputDirectory>${project.parent.build.directory}</outputDirectory>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>plugin-assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
35 changes: 35 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>com.presidentio</groupId>
<artifactId>teamcity-plugin-jmh</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<teamcity-version>9.0.1</teamcity-version>
</properties>
<repositories>
<repository>
<id>JetBrains</id>
<url>http://repository.jetbrains.com/all</url>
</repository>
</repositories>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<modules>
<module>teamcity-plugin-jmh-server</module>
<module>build</module>
</modules>
</project>
35 changes: 35 additions & 0 deletions teamcity-plugin-jmh-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>teamcity-plugin-jmh</artifactId>
<groupId>com.presidentio</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>teamcity-plugin-jmh-server</artifactId>
<packaging>jar</packaging>
<dependencies>

<dependency>
<groupId>org.jetbrains.teamcity</groupId>
<artifactId>server-api</artifactId>
<version>${teamcity-version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jetbrains.teamcity</groupId>
<artifactId>server-web-api</artifactId>
<version>${teamcity-version}</version>
<type>war</type>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jetbrains.teamcity</groupId>
<artifactId>tests-support</artifactId>
<version>${teamcity-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.presidentio;

import jetbrains.buildServer.controllers.BaseController;
import jetbrains.buildServer.web.openapi.PluginDescriptor;
import jetbrains.buildServer.web.openapi.WebControllerManager;
import org.jetbrains.annotations.Nullable;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AppServer extends BaseController {
private PluginDescriptor myDescriptor;

public AppServer(WebControllerManager manager, PluginDescriptor descriptor) {
manager.registerController("/demoPlugin.html", this);
myDescriptor = descriptor;
}

@Nullable
@Override
protected ModelAndView doHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
return new ModelAndView(myDescriptor.getPluginResourcesPath("hello.jsp"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.presidentio;

import jetbrains.buildServer.web.openapi.*;
import org.jetbrains.annotations.NotNull;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
* Created by Vitaliy on 09.04.2015.
*/
public class JmhBuildTab extends SimpleCustomTab {

public JmhBuildTab(@NotNull PagePlaces pagePlaces,
@NotNull PluginDescriptor descriptor) {
super(pagePlaces, PlaceId.BUILD_RESULTS_TAB, "jmh", descriptor.getPluginResourcesPath("jmh.jsp"), "Benchmark results");
register();
}

@Override
public boolean isAvailable(@NotNull HttpServletRequest request) {
return super.isAvailable(request);
}

@Override
public void fillModel(@NotNull Map<String, Object> model, @NotNull HttpServletRequest request) {
// fill model
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.presidentio.teamcity.jmh.runner;

import jetbrains.buildServer.serverSide.PropertiesProcessor;
import jetbrains.buildServer.serverSide.RunType;
import jetbrains.buildServer.serverSide.RunTypeRegistry;
import jetbrains.buildServer.web.openapi.PluginDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;

/**
* Created by Vitaliy on 14.04.2015.
*/
public class JmhRunType extends RunType {

private final PluginDescriptor pluginDescriptor;

public JmhRunType(final RunTypeRegistry runTypeRegistry, final PluginDescriptor pluginDescriptor) {
this.pluginDescriptor = pluginDescriptor;
runTypeRegistry.registerRunType(this);
}
@NotNull
@Override
public String getType() {
return JmhRunnerConst.RUNNER_TYPE;
}

@NotNull
@Override
public String getDisplayName() {
return JmhRunnerBundle.DISPLAY_NAME;
}

@NotNull
@Override
public String getDescription() {
return JmhRunnerBundle.DESCRIPTION;
}

@Nullable
@Override
public PropertiesProcessor getRunnerPropertiesProcessor() {
return new JmhRunTypePropertiesProcessor();
}

@Nullable
@Override
public String getEditRunnerParamsJspFilePath() {
return pluginDescriptor.getPluginResourcesPath("editJmhRunnerParams.jsp");
}

@Nullable
@Override
public String getViewRunnerParamsJspFilePath() {
return pluginDescriptor.getPluginResourcesPath("viewJmhRunnerParams.jsp");
}

@Nullable
@Override
public Map<String, String> getDefaultRunnerProperties() {
Map<String, String> defaultProperties = new HashMap<String, String>(1);
defaultProperties.put(JmhRunnerConst.PROP_JAR_PATH, "target/some.jar");
return defaultProperties;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.presidentio.teamcity.jmh.runner;

import jetbrains.buildServer.serverSide.InvalidProperty;
import jetbrains.buildServer.serverSide.PropertiesProcessor;
import jetbrains.buildServer.util.PropertiesUtil;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
* Created by Vitaliy on 14.04.2015.
*/
public class JmhRunTypePropertiesProcessor implements PropertiesProcessor {
public Collection<InvalidProperty> process(Map<String, String> map) {
List<InvalidProperty> result = new ArrayList<InvalidProperty>();

String jarPath = map.get(JmhRunnerConst.PROP_JAR_PATH);

if (PropertiesUtil.isEmptyOrNull(jarPath)) {
result.add(new InvalidProperty(JmhRunnerConst.PROP_JAR_PATH, "Jar path must be specified"));
}

return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.presidentio.teamcity.jmh.runner;

/**
* Created by Vitaliy on 14.04.2015.
*/
public class JmhRunnerBundle {

public static final String DISPLAY_NAME = "jmh";
public static final String DESCRIPTION = "jmh runner";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.presidentio.teamcity.jmh.runner;

/**
* Created by Vitaliy on 14.04.2015.
*/
public class JmhRunnerConst {

public static final String RUNNER_TYPE = "jmh-runner";

public static final String PROP_JAR_PATH = "jar_path";

public String getRUNNER_TYPE() {
return RUNNER_TYPE;
}

public String getPROP_JAR_PATH() {
return PROP_JAR_PATH;
}
}
Loading

0 comments on commit 8e66be6

Please sign in to comment.