forked from grails/grails-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically discover and populate package names to scan at compile …
…time
- Loading branch information
1 parent
6f13c30
commit fad4047
Showing
4 changed files
with
90 additions
and
29 deletions.
There are no files selected for viewing
27 changes: 0 additions & 27 deletions
27
grails-bootstrap/src/main/groovy/grails/build/GrailsBuildListener.java
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
grails-bootstrap/src/main/groovy/grails/io/ResourceUtils.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2014 original authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package grails.io | ||
|
||
import grails.util.BuildSettings | ||
import groovy.transform.CompileStatic | ||
import org.grails.io.support.GrailsResourceUtils | ||
|
||
|
||
|
||
/** | ||
* Utility methods for interacting with resources | ||
* | ||
* @author Graeme Rocher | ||
* @since 3.0 | ||
*/ | ||
@CompileStatic | ||
class ResourceUtils extends GrailsResourceUtils { | ||
|
||
/** | ||
* Obtains the package names for the project. Works at development time only, do not use at runtime. | ||
* | ||
* @return The project package names | ||
*/ | ||
static Iterable<String> getProjectPackageNames() { | ||
Set<String> packageNames = [] | ||
def baseDir = BuildSettings.BASE_DIR | ||
if(baseDir) { | ||
def rootDir = new File(baseDir, "grails-app") | ||
rootDir.eachDir { File dir -> | ||
def dirName = dir.name | ||
if (!dir.hidden && !dirName.startsWith('.') && !['conf', 'i18n', 'assets', 'views'].contains(dirName)) { | ||
populatePackages(dir, packageNames, "") | ||
} | ||
} | ||
} | ||
return packageNames | ||
} | ||
|
||
protected static populatePackages(File rootDir, Collection<String> packageNames, String prefix) { | ||
rootDir.eachDir { File dir -> | ||
def dirName = dir.name | ||
if (!dir.hidden && !dirName.startsWith('.')) { | ||
packageNames << "${prefix}${dirName}".toString() | ||
|
||
populatePackages(dir, packageNames, "${dirName}.") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters