Skip to content

Commit c4f34ca

Browse files
committed
Refactor GormTransformer
* Do not use `shouldInject(URL url)` anymore * Load GormTransformer from `grails.factories` Closes gh-63
1 parent 2f84812 commit c4f34ca

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

grace-datastore-gorm-support/src/main/groovy/org/grails/compiler/gorm/GormTransformer.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2011 SpringSource
2+
* Copyright 2011-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,7 +15,6 @@
1515
*/
1616
package org.grails.compiler.gorm;
1717

18-
import java.net.URL;
1918
import java.util.Collection;
2019

2120
import groovy.transform.Canonical;
@@ -29,12 +28,12 @@
2928
import org.grails.compiler.injection.GrailsASTUtils;
3029
import org.grails.core.artefact.DomainClassArtefactHandler;
3130
import org.grails.datastore.mapping.reflect.AstUtils;
32-
import org.grails.io.support.GrailsResourceUtils;
3331

3432
/**
3533
* Transforms GORM entities making the GORM API available to Java.
3634
*
3735
* @author Graeme Rocher
36+
* @author Michael Yan
3837
* @since 2.0
3938
*/
4039
@AstTransformer
@@ -45,15 +44,10 @@ public String[] getArtefactTypes() {
4544
return new String[] { DomainClassArtefactHandler.TYPE };
4645
}
4746

48-
public boolean shouldInject(URL url) {
49-
return GrailsResourceUtils.isDomainClass(url);
50-
}
51-
5247
public static Collection<String> getKnownEntityNames() {
5348
return AstUtils.getKnownEntityNames();
5449
}
5550

56-
5751
@Override
5852
public void performInjection(SourceUnit source, GeneratorContext context, ClassNode classNode) {
5953
if (GrailsASTUtils.hasAnnotation(classNode, Canonical.class)) {
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
grails.compiler.traits.TraitInjector=org.grails.compiler.gorm.EntityTraitInjector
1+
rails.compiler.traits.TraitInjector=\
2+
org.grails.compiler.gorm.EntityTraitInjector
3+
4+
grails.compiler.ast.ClassInjector=\
5+
org.grails.compiler.gorm.GormTransformer

0 commit comments

Comments
 (0)