You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logger.info('The bootRun task does not exist or is disabled, so this must not be a runnable grails application. Skipping finding main class.')
118
-
return
118
+
File cacheFile = mainClassCacheFile.get().asFile
119
+
if(cacheFile.exists()) {
120
+
// the only time this task should invoke is when gradle has deemed it necessary to run, always remove the
121
+
// the cache file to prevent invalid states when running tasks other than bootRun, bootJar, or bootWar
122
+
cacheFile.delete()
119
123
}
120
124
121
-
if (!enabledBootJarTask.get() &&!enabledBootWarTask.get()) {
122
-
logger.info('There is neither a {} or {} task that will run. Skipping finding main Application class.', SpringBootPlugin.BOOT_JAR_TASK_NAME, SpringBootPlugin.BOOT_WAR_TASK_NAME)
125
+
if (!enabledBootRunTask.get() &&!enabledBootJarTask.get() &&!enabledBootWarTask.get()) {
126
+
logger.info('No Spring Boot tasks were found that will run ({}, {}, or {}). Skipping finding main Application class.', 'bootRun', SpringBootPlugin.BOOT_JAR_TASK_NAME, SpringBootPlugin.BOOT_WAR_TASK_NAME)
123
127
return
124
128
}
125
129
126
130
if (mainClassName.isPresent()) {
127
131
def overrideClassName = mainClassName.get()
128
132
logger.info('Overriding main class with: {}', overrideClassName)
129
-
File cacheFile = mainClassCacheFile.get().asFile
130
133
cacheFile.parentFile.mkdirs()
131
134
cacheFile.text = overrideClassName
132
135
return
133
136
}
134
137
135
138
MainClassHolder mainClassHolder = findMainClass()
136
139
if (mainClassHolder) {
137
-
File cacheFile = mainClassCacheFile.get().asFile
138
140
cacheFile.parentFile.mkdirs()
139
141
cacheFile.text = mainClassHolder.className
142
+
logger.info('Found main class: {}', mainClassHolder.className)
140
143
} elseif (!isGrailsPlugin.get()) {
141
144
logger.warn('No main class found. Please set \'springBoot.mainClass\'.')
142
145
}
@@ -152,20 +155,22 @@ abstract class FindMainClassTask extends DefaultTask {
logger.debug("Searching for main class in: {}", classesDir.absolutePath)
159
+
mainClassHolder = mainClassFinder.findMainClass(classesDir, false) // do not cache inside of the finder since gradle is responsible for caching
156
160
if (mainClassHolder) {
161
+
logger.debug("Found main class: {} at {}", mainClassHolder.className, mainClassHolder.classFile.absolutePath)
157
162
break
158
163
}
159
164
}
160
165
161
166
if (!mainClassHolder) {
162
167
if (isGrailsPlugin.get()) {
163
168
// this is ok if the project is a plugin because it's likely not going to be a runnable grails app
164
-
logger.lifecycle('WARNING: this plugin project does not have an Application.class and thus the bootJar / bootRun will be invalid.')
169
+
logger.lifecycle('WARNING: this plugin project does not have an Application.class and thus the bootJar / bootWar / bootRun will be invalid.')
165
170
returnnull
166
171
}
167
172
168
-
thrownewRuntimeException('Could not find Application main class. Please set \'springBoot.mainClass\' or disable BootJar & BootArchive tasks.')
173
+
thrownewRuntimeException('Could not find Application main class. Please set \'springBoot.mainClass\' or disable bootRun & bootArchive (bootJar / bootWar) tasks.')
0 commit comments