-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #450 from jtnord/plexus-cleanup-it
integration test for extra warResources
- Loading branch information
Showing
10 changed files
with
339 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
# | ||
|
||
invoker.goals=-ntp package -Pquick-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?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> | ||
<groupId>org.jenkins-ci.plugins</groupId> | ||
<artifactId>plugin</artifactId> | ||
<version>4.55</version> | ||
<relativePath /> | ||
</parent> | ||
|
||
<groupId>org.jenkins-ci.tools.hpi.its</groupId> | ||
<artifactId>war-resources-it</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<packaging>hpi</packaging> | ||
|
||
<name>MyNewPlugin</name> | ||
<description>My New Plugin</description> | ||
<url>https://github.com/jenkinsci/verify-it-plugin</url> | ||
|
||
<licenses> | ||
<license> | ||
<name>MIT License</name> | ||
<url>https://opensource.org/licenses/MIT</url> | ||
</license> | ||
</licenses> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jenkins-ci.tools</groupId> | ||
<artifactId>maven-hpi-plugin</artifactId> | ||
<configuration> | ||
<webResources> | ||
<resource> | ||
<directory>${project.basedir}/src/main/webResource-filtering</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</webResources> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
|
||
</build> | ||
<developers> | ||
<developer> | ||
<id>jblogs</id> | ||
<name>Jo Bloggs</name> | ||
<email>jblogs@example.com</email> | ||
</developer> | ||
</developers> | ||
|
||
<scm> | ||
<connection>scm:git:https://github.com/jenkinsci/verify-it-plugin.git</connection> | ||
<developerConnection>scm:git:git@github.com:jenkinsci/verify-it-plugin.git</developerConnection> | ||
<tag>HEAD</tag> | ||
<url>https://github.com/jenkinsci/verify-it-plugin</url> | ||
</scm> | ||
|
||
<properties> | ||
<jenkins.version>2.361.4</jenkins.version> | ||
<hpi-plugin.version>@project.version@</hpi-plugin.version> | ||
<!-- used for filtering --> | ||
<prop1>hello</prop1> | ||
<prop2>goodbye</prop2> | ||
|
||
</properties> | ||
</project> |
139 changes: 139 additions & 0 deletions
139
src/it/warResources/src/main/java/org/jenkinsci/tools/hpi/its/HelloWorldBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package org.jenkinsci.tools.hpi.its; | ||
import hudson.Launcher; | ||
import hudson.Extension; | ||
import hudson.util.FormValidation; | ||
import hudson.model.AbstractBuild; | ||
import hudson.model.BuildListener; | ||
import hudson.model.AbstractProject; | ||
import hudson.tasks.Builder; | ||
import hudson.tasks.BuildStepDescriptor; | ||
import net.sf.json.JSONObject; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
import org.kohsuke.stapler.QueryParameter; | ||
|
||
import javax.servlet.ServletException; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Sample {@link Builder}. | ||
* | ||
* <p> | ||
* When the user configures the project and enables this builder, | ||
* {@link org.jenkins.HelloWorldBuilder.DescriptorImpl#newInstance(StaplerRequest)} is invoked | ||
* and a new {@link org.jenkins.HelloWorldBuilder} is created. The created | ||
* instance is persisted to the project configuration XML by using | ||
* XStream, so this allows you to use instance fields (like {@link #name}) | ||
* to remember the configuration. | ||
* | ||
* <p> | ||
* When a build is performed, the {@link #perform(AbstractBuild, Launcher, BuildListener)} method | ||
* will be invoked. | ||
* | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
public class HelloWorldBuilder extends Builder { | ||
|
||
private final String name; | ||
|
||
// Fields in config.jelly must match the parameter names in the "DataBoundConstructor" | ||
@DataBoundConstructor | ||
public HelloWorldBuilder(String name) { | ||
this.name = name; | ||
} | ||
|
||
/** | ||
* We'll use this from the {@code config.jelly}. | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) { | ||
// this is where you 'build' the project | ||
// since this is a dummy, we just say 'hello world' and call that a build | ||
|
||
// this also shows how you can consult the global configuration of the builder | ||
if(getDescriptor().useFrench()) | ||
listener.getLogger().println("Bonjour, "+name+"!"); | ||
else | ||
listener.getLogger().println("Hello, "+name+"!"); | ||
return true; | ||
} | ||
|
||
// overrided for better type safety. | ||
// if your plugin doesn't really define any property on Descriptor, | ||
// you don't have to do this. | ||
@Override | ||
public DescriptorImpl getDescriptor() { | ||
return (DescriptorImpl)super.getDescriptor(); | ||
} | ||
|
||
/** | ||
* Descriptor for {@link org.jenkins.HelloWorldBuilder}. Used as a singleton. | ||
* The class is marked as public so that it can be accessed from views. | ||
* | ||
* <p> | ||
* See {@code views/hudson/plugins/hello_world/HelloWorldBuilder/*.jelly} | ||
* for the actual HTML fragment for the configuration screen. | ||
*/ | ||
@Extension // this marker indicates Hudson that this is an implementation of an extension point. | ||
public static final class DescriptorImpl extends BuildStepDescriptor<Builder> { | ||
/** | ||
* To persist global configuration information, | ||
* simply store it in a field and call save(). | ||
* | ||
* <p> | ||
* If you don't want fields to be persisted, use {@code transient}. | ||
*/ | ||
private boolean useFrench; | ||
|
||
/** | ||
* Performs on-the-fly validation of the form field 'name'. | ||
* | ||
* @param value | ||
* This parameter receives the value that the user has typed. | ||
* @return | ||
* Indicates the outcome of the validation. This is sent to the browser. | ||
*/ | ||
public FormValidation doCheckName(@QueryParameter String value) throws IOException, ServletException { | ||
if(value.length()==0) | ||
return FormValidation.error("Please set a name"); | ||
if(value.length()<4) | ||
return FormValidation.warning("Isn't the name too short?"); | ||
return FormValidation.ok(); | ||
} | ||
|
||
public boolean isApplicable(Class<? extends AbstractProject> aClass) { | ||
// indicates that this builder can be used with all kinds of project types | ||
return true; | ||
} | ||
|
||
/** | ||
* This human readable name is used in the configuration screen. | ||
*/ | ||
public String getDisplayName() { | ||
return "Say hello world"; | ||
} | ||
|
||
@Override | ||
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { | ||
// To persist global configuration information, | ||
// set that to properties and call save(). | ||
useFrench = formData.getBoolean("useFrench"); | ||
// ^Can also use req.bindJSON(this, formData); | ||
// (easier when there are many fields; need set* methods for this, like setUseFrench) | ||
save(); | ||
return super.configure(req,formData); | ||
} | ||
|
||
/** | ||
* This method returns true if the global configuration says we should speak French. | ||
*/ | ||
public boolean useFrench() { | ||
return useFrench; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!-- | ||
This view is used to render the plugin list page. | ||
Since we don't really have anything dynamic here, let's just use static HTML. | ||
--> | ||
<?jelly escape-by-default='true'?> | ||
<div> | ||
This plugin is a sample plugin to explain how to write a Jenkins plugin. | ||
</div> |
16 changes: 16 additions & 0 deletions
16
...arResources/src/main/resources/org/jenkinsci/tools/hpi/its/HelloWorldBuilder/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> | ||
<!-- | ||
This jelly script is used for per-project configuration. | ||
See global.jelly for a general discussion about jelly script. | ||
--> | ||
|
||
<!-- | ||
Creates a text field that shows the value of the "name" property. | ||
When submitted, it will be passed to the corresponding constructor parameter. | ||
--> | ||
<f:entry title="Name" field="name"> | ||
<f:textbox /> | ||
</f:entry> | ||
</j:jelly> |
33 changes: 33 additions & 0 deletions
33
...arResources/src/main/resources/org/jenkinsci/tools/hpi/its/HelloWorldBuilder/global.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> | ||
<!-- | ||
This Jelly script is used to produce the global configuration option. | ||
Hudson uses a set of tag libraries to provide uniformity in forms. | ||
To determine where this tag is defined, first check the namespace URI, | ||
and then look under $HUDSON/views/. For example, <f:section> is defined | ||
in $HUDSON/views/lib/form/section.jelly. | ||
It's also often useful to just check other similar scripts to see what | ||
tags they use. Views are always organized according to its owner class, | ||
so it should be straightforward to find them. | ||
--> | ||
<f:section title="Hello World Builder"> | ||
<!-- | ||
optional @help points to the help document HTML. /plugin/compile-its | ||
is mapped to our webapp/ directory, so this is a convenient way to serve | ||
static resources. | ||
--> | ||
<f:entry title="French" | ||
description="Check if we should say hello in French" | ||
help="/plugin/compile-its/help-globalConfig.html"> | ||
<!-- | ||
we'll have on input field. In HTML, single "namespace" is shared between | ||
all form components in one <form>, so we need to choose a name that doesn't | ||
collide with other plugins. The 'descriptor' variable represents our descriptor | ||
object, so we use that to determine the initial value for this form. | ||
--> | ||
<f:checkbox name="hello_world.useFrench" checked="${descriptor.useFrench()}" /> | ||
</f:entry> | ||
</f:section> | ||
</j:jelly> |
5 changes: 5 additions & 0 deletions
5
...Resources/src/main/resources/org/jenkinsci/tools/hpi/its/HelloWorldBuilder/help-name.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div> | ||
Help file for fields are discovered through a file name convention. This file is an line help for | ||
the "name" field. You can have <i>arbitrary</i> HTML here. You can write this file as a Jelly script | ||
if you need a dynamic content (but if you do so, change the extension to .jelly) | ||
</div> |
2 changes: 2 additions & 0 deletions
2
src/it/warResources/src/main/resources/org/jenkinsci/tools/hpi/its/Messages.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
it.msg=It rocks | ||
|
18 changes: 18 additions & 0 deletions
18
src/it/warResources/src/main/webResource-filtering/help-globalConfig.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div> | ||
<p> | ||
This HTML fragment will be injected into the configuration screen | ||
when the user clicks the 'help' icon. See global.jelly for how the | ||
form decides which page to load. | ||
You can have any HTML fragment here. | ||
</p> | ||
<p> | ||
You can also filter using interpolation like: | ||
\${prop1\} ${prop1} | ||
or | ||
\@prop2\@ @prop2@ | ||
and these will be replaced at build time | ||
it is even possible to use system properties | ||
\@java.class.version\@ ${java.class.version} | ||
</p> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
*/ | ||
globalConfigHelp = new File(basedir, 'target/war-resources-it/help-globalConfig.html').text; | ||
// code uses plexus not maven so escapes are not supported. | ||
assert globalConfigHelp.contains("\\\${prop1\\} hello"); | ||
assert globalConfigHelp.contains("\\@prop2\\@ goodbye"); | ||
// code claims to add System properties but this fails | ||
// assert globalConfigHelp.contains("\\@java.class.version\\@ 55.0"); | ||
|
||
|
||
return true; |