Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.constructor.AbstractConstruct;
import org.yaml.snakeyaml.constructor.Construct;
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.constructor.CustomClassLoaderConstructor;
import org.yaml.snakeyaml.error.Mark;
import org.yaml.snakeyaml.nodes.MappingNode;
import org.yaml.snakeyaml.nodes.Node;
Expand All @@ -23,19 +23,10 @@
/**
* @author <a href="mailto:[email protected]">Nicolas De Loof</a>
*/
class ModelConstructor extends Constructor {

/*
* TODO remove loader field and getClassForName method and extend CustomClassLoaderConstructor instead after this
* plugin requires SnakeYAML 2.0
*/

private final ClassLoader loader;
class ModelConstructor extends CustomClassLoaderConstructor {

public ModelConstructor(LoaderOptions loadingConfig) {
super(Mapping.class, loadingConfig);

this.loader = ModelConstructor.class.getClassLoader();
super(Mapping.class, ModelConstructor.class.getClassLoader(), loadingConfig);

this.yamlConstructors.put(Tag.BOOL, ConstructScalar);
this.yamlConstructors.put(Tag.INT, ConstructScalar);
Expand Down Expand Up @@ -95,16 +86,4 @@ protected void constructSequenceStep2(SequenceNode node, Collection collection)
((Sequence) collection).setSource(getSource(node));
super.constructSequenceStep2(node, collection);
}

/**
* Load the class
*
* @param name - the name
* @return Class to create
* @throws ClassNotFoundException - when cannot load the class
*/
@Override
protected Class<?> getClassForName(String name) throws ClassNotFoundException {
return Class.forName(name, true, loader);
}
}
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@
<spotless.check.skip>false</spotless.check.skip>
</properties>

<dependencyManagement>
<dependencies>
<!-- TODO until in BOM -->
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>snakeyaml-api</artifactId>
<version>2.2-111.vc6598e30cc65</version>
</dependency>
</dependencies>
</dependencyManagement>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
Expand Down