Skip to content
Permalink
Browse files
Merge pull request #43 from abayer/jenkins-37403
JENKINS-37403 - downstream change to use SymbolLookup.getSymbolValue(…)
  • Loading branch information
abayer committed Aug 26, 2016
2 parents f06a64f + 1792876 commit db985aa51f8787f080f2814996ba4c861a5e8ed0
@@ -100,7 +100,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.3</version>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -132,10 +132,7 @@ public Object invokeMethod(String name, Object args) {
try {
for (Class<?> e : Index.list(Symbol.class, Jenkins.getActiveInstance().pluginManager.uberClassLoader, Class.class)) {
if (Descriptor.class.isAssignableFrom(e)) {
Symbol s = e.getAnnotation(Symbol.class);
if (s != null) {
symbols.addAll(Arrays.asList(s.value()));
}
symbols.addAll(SymbolLookup.getSymbolValue(e));
}
}
} catch (IOException x) {
@@ -39,6 +39,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.logging.Level;
@@ -50,6 +51,7 @@
import jenkins.tasks.SimpleBuildStep;
import net.sf.json.JSONObject;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.structs.SymbolLookup;
import org.jenkinsci.plugins.structs.describable.DescribableModel;
import org.jenkinsci.plugins.structs.describable.DescribableParameter;
import org.jenkinsci.plugins.structs.describable.HeterogeneousObjectType;
@@ -369,8 +371,8 @@ private static boolean isSingleMap(Map<String, ?> args) {
for (DescribableModel<?> delegateOptionSchema : ((HeterogeneousObjectType) delegate.getType()).getTypes().values()) {
Class<?> delegateOptionType = delegateOptionSchema.getType();
Descriptor<?> delegateDescriptor = Jenkins.getActiveInstance().getDescriptorOrDie(delegateOptionType.asSubclass(Describable.class));
Symbol symbol = delegateDescriptor.getClass().getAnnotation(Symbol.class);
if (symbol != null && symbol.value().length > 0) {
Set<String> symbols = SymbolLookup.getSymbolValue(delegateDescriptor);
if (!symbols.isEmpty()) {
t.add(new QuasiDescriptor(delegateDescriptor));
}
}
@@ -402,7 +404,16 @@ private static boolean isSingleMap(Map<String, ?> args) {
}

public String getSymbol() {
return real instanceof StepDescriptor ? ((StepDescriptor) real).getFunctionName() : real.getClass().getAnnotation(Symbol.class).value()[0];
if (real instanceof StepDescriptor) {
return ((StepDescriptor) real).getFunctionName();
} else {
Set<String> symbolValues = SymbolLookup.getSymbolValue(real);
if (!symbolValues.isEmpty()) {
return symbolValues.iterator().next();
} else {
throw new AssertionError("Symbol present but no values defined.");
}
}
}

@Override public int compareTo(QuasiDescriptor o) {
@@ -4,6 +4,7 @@
import hudson.Extension;
import hudson.model.TaskListener;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.structs.SymbolLookup;
import org.jenkinsci.plugins.workflow.DSLTest;
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl;
@@ -45,7 +46,7 @@ public void setModerate(boolean m) {

@Override protected Void run() throws Exception {
if (step.moderate) {
listener.getLogger().println("Introducing "+step.state.getDescriptor().getClass().getAnnotation(Symbol.class).value()[0]);
listener.getLogger().println("Introducing "+ SymbolLookup.getSymbolValue(step.state).iterator().next());
}
step.state.sayHello(listener);
return null;

0 comments on commit db985aa

Please sign in to comment.