Skip to content

Commit 89725d2

Browse files
committed
Adding the behaviour to migrate rules from spml to ./cursor/rules
1 parent e00f170 commit 89725d2

2 files changed

Lines changed: 76 additions & 65 deletions

File tree

spml/pom.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,33 @@
210210
</execution>
211211
</executions>
212212
</plugin>
213+
214+
<!-- Copy generated file to cursor rules directory -->
215+
<plugin>
216+
<groupId>org.apache.maven.plugins</groupId>
217+
<artifactId>maven-resources-plugin</artifactId>
218+
<version>3.3.1</version>
219+
<executions>
220+
<execution>
221+
<id>copy-cursor-rules</id>
222+
<phase>package</phase>
223+
<goals>
224+
<goal>copy-resources</goal>
225+
</goals>
226+
<configuration>
227+
<outputDirectory>${project.basedir}/../.cursor/rules</outputDirectory>
228+
<resources>
229+
<resource>
230+
<directory>${project.basedir}/src/test/resources</directory>
231+
<includes>
232+
<include>100-java-checklist-guide.mdc</include>
233+
</includes>
234+
</resource>
235+
</resources>
236+
</configuration>
237+
</execution>
238+
</executions>
239+
</plugin>
213240
</plugins>
214241
</build>
215242
</project>

spml/src/test/java/info/jab/xml/CursorRuleGeneratorTest.java

Lines changed: 49 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -137,59 +137,6 @@ void should_generateExactContentMatchingOriginalExpected_when_transformingJavaCh
137137
.isEqualTo(expectedContent);
138138
}
139139

140-
@Test
141-
@DisplayName("Should produce consistent content structure regardless of XML content type")
142-
void should_produceConsistentStructure_when_processingDifferentXmlTypes() throws IOException {
143-
// Given
144-
CursorRuleGenerator generator = new CursorRuleGenerator();
145-
146-
// When
147-
String bestPracticesResult = generator.generate("110-java-maven-best-practices.xml", "cursor-rule-generator.xsl");
148-
String documentationResult = generator.generate("112-java-maven-documentation.xml", "cursor-rule-generator.xsl");
149-
String checklistGuideResult = generator.generate("100-java-checklist-guide.xml", "cursor-rule-generator.xsl");
150-
String objectOrientedDesignResult = generator.generate("121-java-object-oriented-design.xml", "cursor-rule-generator.xsl");
151-
String typeDesignResult = generator.generate("122-java-type-design.xml", "cursor-rule-generator.xsl");
152-
String generalGuidelinesResult = generator.generate("123-java-general-guidelines.xml", "cursor-rule-generator.xsl");
153-
String secureCodingResult = generator.generate("124-java-secure-coding.xml", "cursor-rule-generator.xsl");
154-
String concurrencyResult = generator.generate("125-java-concurrency.xml", "cursor-rule-generator.xsl");
155-
String loggingResult = generator.generate("126-java-logging.xml", "cursor-rule-generator.xsl");
156-
String unitTestingResult = generator.generate("131-java-unit-testing.xml", "cursor-rule-generator.xsl");
157-
String refactoringWithModernFeaturesResult = generator.generate("141-java-refactoring-with-modern-features.xml", "cursor-rule-generator.xsl");
158-
String functionalProgrammingResult = generator.generate("142-java-functional-programming.xml", "cursor-rule-generator.xsl");
159-
String dataOrientedProgrammingResult = generator.generate("143-java-data-oriented-programming.xml", "cursor-rule-generator.xsl");
160-
161-
// Then - All should have consistent frontmatter and structure
162-
assertThat(bestPracticesResult)
163-
.startsWith("---\ndescription: Maven Best Practices")
164-
.contains("## System prompt characterization")
165-
.contains("Role definition: You are a Senior software engineer");
166-
167-
assertThat(documentationResult)
168-
.startsWith("---\ndescription: Create README-DEV.md")
169-
.contains("## System prompt characterization")
170-
.contains("Role definition: You are a Senior software engineer");
171-
172-
assertThat(checklistGuideResult)
173-
.startsWith("---\ndescription:")
174-
.contains("## System prompt characterization")
175-
.contains("Role definition: You are a Senior software engineer");
176-
177-
// Save all for comparison
178-
//saveGeneratedContentToTarget(bestPracticesResult, "unified-best-practices.mdc");
179-
//saveGeneratedContentToTarget(documentationResult, "unified-documentation.mdc");
180-
//saveGeneratedContentToTarget(checklistGuideResult, "unified-checklist-guide.mdc");
181-
//saveGeneratedContentToTarget(objectOrientedDesignResult, "unified-object-oriented-design.mdc");
182-
//saveGeneratedContentToTarget(typeDesignResult, "unified-type-design.mdc");
183-
//saveGeneratedContentToTarget(generalGuidelinesResult, "unified-general-guidelines.mdc");
184-
//saveGeneratedContentToTarget(secureCodingResult, "unified-secure-coding.mdc");
185-
//saveGeneratedContentToTarget(concurrencyResult, "unified-concurrency.mdc");
186-
//saveGeneratedContentToTarget(loggingResult, "unified-logging.mdc");
187-
//saveGeneratedContentToTarget(unitTestingResult, "unified-unit-testing.mdc");
188-
//saveGeneratedContentToTarget(refactoringWithModernFeaturesResult, "unified-refactoring-with-modern-features.mdc");
189-
//saveGeneratedContentToTarget(dataOrientedProgrammingResult, "unified-data-oriented-programming.mdc");
190-
saveGeneratedContentToTarget(functionalProgrammingResult, "unified-functional-programming.mdc");
191-
}
192-
193140
@Test
194141
@DisplayName("Should generate exact content matching original expected Java Object-Oriented Design document using unified XSLT")
195142
void should_generateExactContentMatchingOriginalExpected_when_transformingJavaObjectOrientedDesignWithUnifiedXslt() throws IOException {
@@ -375,19 +322,56 @@ private String loadExpectedContent(String filename) throws IOException {
375322
})
376323
.orElseThrow(() -> new IOException("Resource not found: " + filename));
377324
}
325+
}
378326

379-
/**
380-
* Pure function to save generated content to target directory.
381-
* Follows functional programming principles with clear input/output relationship.
382-
*/
383-
private void saveGeneratedContentToTarget(String content, String filename) throws IOException {
384-
Path targetDir = Paths.get("target");
385-
if (!Files.exists(targetDir)) {
386-
Files.createDirectories(targetDir);
387-
}
388-
Path outputPath = targetDir.resolve(filename);
389-
Files.writeString(outputPath, content);
390-
logger.info("Generated content saved to: {}", outputPath.toAbsolutePath());
327+
@Test
328+
@DisplayName("Should produce consistent content structure regardless of XML content type")
329+
void should_produceConsistentStructure_when_processingDifferentXmlTypes() throws IOException {
330+
// Given
331+
CursorRuleGenerator generator = new CursorRuleGenerator();
332+
333+
// When
334+
String checklistGuideResult = generator.generate("100-java-checklist-guide.xml", "cursor-rule-generator.xsl");
335+
String bestPracticesResult = generator.generate("110-java-maven-best-practices.xml", "cursor-rule-generator.xsl");
336+
String documentationResult = generator.generate("112-java-maven-documentation.xml", "cursor-rule-generator.xsl");
337+
String objectOrientedDesignResult = generator.generate("121-java-object-oriented-design.xml", "cursor-rule-generator.xsl");
338+
String typeDesignResult = generator.generate("122-java-type-design.xml", "cursor-rule-generator.xsl");
339+
String generalGuidelinesResult = generator.generate("123-java-general-guidelines.xml", "cursor-rule-generator.xsl");
340+
String secureCodingResult = generator.generate("124-java-secure-coding.xml", "cursor-rule-generator.xsl");
341+
String concurrencyResult = generator.generate("125-java-concurrency.xml", "cursor-rule-generator.xsl");
342+
String loggingResult = generator.generate("126-java-logging.xml", "cursor-rule-generator.xsl");
343+
String unitTestingResult = generator.generate("131-java-unit-testing.xml", "cursor-rule-generator.xsl");
344+
String refactoringWithModernFeaturesResult = generator.generate("141-java-refactoring-with-modern-features.xml", "cursor-rule-generator.xsl");
345+
String functionalProgrammingResult = generator.generate("142-java-functional-programming.xml", "cursor-rule-generator.xsl");
346+
String dataOrientedProgrammingResult = generator.generate("143-java-data-oriented-programming.xml", "cursor-rule-generator.xsl");
347+
348+
// Save all for comparison
349+
saveGeneratedContentToTarget(checklistGuideResult, "100-java-checklist-guide.mdc");
350+
//saveGeneratedContentToTarget(bestPracticesResult, "unified-best-practices.mdc");
351+
//saveGeneratedContentToTarget(documentationResult, "unified-documentation.mdc");
352+
//saveGeneratedContentToTarget(objectOrientedDesignResult, "unified-object-oriented-design.mdc");
353+
//saveGeneratedContentToTarget(typeDesignResult, "unified-type-design.mdc");
354+
//saveGeneratedContentToTarget(generalGuidelinesResult, "unified-general-guidelines.mdc");
355+
//saveGeneratedContentToTarget(secureCodingResult, "unified-secure-coding.mdc");
356+
//saveGeneratedContentToTarget(concurrencyResult, "unified-concurrency.mdc");
357+
//saveGeneratedContentToTarget(loggingResult, "unified-logging.mdc");
358+
//saveGeneratedContentToTarget(unitTestingResult, "unified-unit-testing.mdc");
359+
//saveGeneratedContentToTarget(refactoringWithModernFeaturesResult, "unified-refactoring-with-modern-features.mdc");
360+
//saveGeneratedContentToTarget(dataOrientedProgrammingResult, "unified-data-oriented-programming.mdc");
361+
//saveGeneratedContentToTarget(functionalProgrammingResult, "unified-functional-programming.mdc");
362+
}
363+
364+
/**
365+
* Pure function to save generated content to target directory.
366+
* Follows functional programming principles with clear input/output relationship.
367+
*/
368+
private void saveGeneratedContentToTarget(String content, String filename) throws IOException {
369+
Path targetDir = Paths.get("target");
370+
if (!Files.exists(targetDir)) {
371+
Files.createDirectories(targetDir);
391372
}
373+
Path outputPath = targetDir.resolve(filename);
374+
Files.writeString(outputPath, content);
375+
logger.info("Generated content saved to: {}", outputPath.toAbsolutePath());
392376
}
393377
}

0 commit comments

Comments
 (0)