Skip to content

Commit a21cf2c

Browse files
committed
Fix Snakeyaml
Move to 2.2, but cannot get past one error: seems Model is not imported??
1 parent c90d219 commit a21cf2c

File tree

5 files changed

+1732
-3
lines changed

5 files changed

+1732
-3
lines changed

modello-plugins/modello-plugin-snakeyaml/pom.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@
2424
<dependency>
2525
<groupId>org.yaml</groupId>
2626
<artifactId>snakeyaml</artifactId>
27-
<version>1.33</version>
27+
<version>2.2</version>
2828
</dependency>
2929
</dependencies>
30+
31+
<build>
32+
<plugins>
33+
<plugin>
34+
<artifactId>maven-dependency-plugin</artifactId>
35+
</plugin>
36+
</plugins>
37+
</build>
3038
</project>

modello-plugins/modello-plugin-snakeyaml/src/main/java/org/codehaus/modello/plugin/snakeyaml/SnakeYamlReaderGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,8 @@ private void writeNewLocation(String trackerVariable, JSourceCode sc) {
10401040
return;
10411041
}
10421042

1043-
String constr = "new " + locationTracker.getName() + "( parser.getLineNumber(), parser.getColumnNumber()";
1043+
String constr = "new " + locationTracker.getName()
1044+
+ "( parser.peekEvent().getStartMark().getLine(), parser.peekEvent().getStartMark().getColumn()";
10441045
constr += (sourceTracker != null) ? ", " + SOURCE_PARAM : "";
10451046
constr += " )";
10461047

modello-plugins/modello-plugin-snakeyaml/src/main/java/org/codehaus/modello/plugin/snakeyaml/SnakeYamlWriterGenerator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ private void generateSnakeYamlWriter() throws ModelloException, IOException {
7373

7474
JClass jClass = new JClass(packageName + '.' + marshallerName);
7575
initHeader(jClass);
76+
suppressAllWarnings(objectModel, jClass);
7677

7778
jClass.addImport("org.yaml.snakeyaml.DumperOptions");
7879
jClass.addImport("org.yaml.snakeyaml.DumperOptions.Version");
@@ -289,7 +290,8 @@ private void writeClass(ModelClass modelClass, JClass jClass) throws ModelloExce
289290
sc.indent();
290291

291292
writeScalarKey(sc, fieldTagName);
292-
sc.add("generator.emit( new SequenceStartEvent( null, null, true, null, null, false ) );");
293+
sc.add(
294+
"generator.emit( new SequenceStartEvent( null, null, true, null, null, FlowStyle.AUTO ) );");
293295

294296
sc.add("for ( " + toType + " o : " + value + " )");
295297

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package org.codehaus.modello.plugin.snakeyaml;
2+
3+
/*
4+
* Copyright (c) 2004, Codehaus.org
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
* this software and associated documentation files (the "Software"), to deal in
8+
* the Software without restriction, including without limitation the rights to
9+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10+
* of the Software, and to permit persons to whom the Software is furnished to do
11+
* so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
import java.util.Properties;
26+
27+
import org.codehaus.modello.AbstractModelloJavaGeneratorTest;
28+
import org.codehaus.modello.core.ModelloCore;
29+
import org.codehaus.modello.model.Model;
30+
31+
public class SnakeYamlGeneratorTest extends AbstractModelloJavaGeneratorTest {
32+
public SnakeYamlGeneratorTest() {
33+
super("snakeyaml");
34+
}
35+
36+
public void testYamlGenerator() throws Throwable {
37+
ModelloCore modello = (ModelloCore) lookup(ModelloCore.ROLE);
38+
39+
Model model = modello.loadModel(getXmlResourceReader("/models/maven.mdo"));
40+
41+
Properties parameters = getModelloParameters("4.0.0");
42+
43+
modello.generate(model, "java", parameters);
44+
modello.generate(model, "snakeyaml-writer", parameters);
45+
modello.generate(model, "snakeyaml-extended-reader", parameters);
46+
47+
addDependency("org.yaml", "snakeyaml");
48+
compileGeneratedSources();
49+
}
50+
}

0 commit comments

Comments
 (0)