@@ -33,10 +33,6 @@ import groovy.transform.CompileStatic
33
33
import org.apache.commons.lang.StringUtils
34
34
import org.gradle.api.Project
35
35
import org.gradle.api.tasks.SourceSet
36
- import org.gradle.plugins.ide.eclipse.model.Classpath
37
- import org.gradle.plugins.ide.eclipse.model.ClasspathEntry
38
- import org.gradle.plugins.ide.eclipse.model.EclipseModel
39
- import org.gradle.plugins.ide.eclipse.model.SourceFolder
40
36
import org.gradle.plugins.ide.idea.GenerateIdeaModule
41
37
import org.gradle.plugins.ide.idea.model.IdeaModel
42
38
import org.gradle.util.GUtil
@@ -133,78 +129,4 @@ class Utils {
133
129
}
134
130
}
135
131
}
136
-
137
- /**
138
- * Add the the folder of generated source to Eclipse .classpath file.
139
- */
140
- static void addToEclipseSources (Project project , boolean isTest , String sourceSetName , File f ) {
141
- project. plugins. withId(" eclipse" ) {
142
- File projectDir = project. getProjectDir()
143
-
144
- EclipseModel model = project. getExtensions(). findByType(EclipseModel )
145
- model. classpath. file. whenMerged { Classpath cp ->
146
- // buildship requires the folder exists on disk, otherwise
147
- // it will be ignored when updating classpath file, see:
148
- // https://github.com/eclipse/buildship/issues/1196
149
- f. mkdirs()
150
-
151
- String relativePath = projectDir. toURI(). relativize(f. toURI()). getPath()
152
- // remove trailing slash
153
- if (relativePath. endsWith(" /" )) {
154
- relativePath = relativePath[0 .. (relativePath. length() - 2 )]
155
- }
156
- SourceFolder entry = new SourceFolder (relativePath, getOutputPath(cp, sourceSetName))
157
- entry. entryAttributes. put(" optional" , " true" )
158
- entry. entryAttributes. put(" ignore_optional_problems" , " true" )
159
-
160
- // this attribute is optional, but it could be useful for IDEs to recognize that it is
161
- // generated source folder from protobuf, thus providing some support for that.
162
- // e.g. Hint user to run generate tasks if the folder is empty or does not exist.
163
- entry. entryAttributes. put(" protobuf_generated_source" , " true" )
164
-
165
- // check if output is not null here because test source folder
166
- // must have a separate output folder in Eclipse
167
- if (entry. output != null && isTest) {
168
- entry. entryAttributes. put(" test" , " true" )
169
- }
170
- cp. entries. add(entry)
171
- }
172
- }
173
- }
174
-
175
- /**
176
- * Get the output path according to the source set name, if no valid path can be
177
- * found, <code >null</code> will return.
178
- */
179
- private static String getOutputPath (Classpath classpath , String sourceSetName ) {
180
- String path = " bin/" + sourceSetName
181
- if (isValidOutput(classpath, path)) {
182
- return path
183
- }
184
- // fallback to default output
185
- return null
186
- }
187
-
188
- /**
189
- * Check if the output path is valid or not.
190
- * See: org.eclipse.jdt.internal.core.ClasspathEntry#validateClasspath()
191
- */
192
- private static boolean isValidOutput (Classpath classpath , String path ) {
193
- Set<String > outputs = []
194
- for (ClasspathEntry cpe : classpath. getEntries()) {
195
- if (cpe instanceof SourceFolder ) {
196
- outputs. add(((SourceFolder ) cpe). getOutput())
197
- }
198
- }
199
- for (String output : outputs) {
200
- if (Objects . equals(output, path)) {
201
- continue
202
- }
203
- // Eclipse does not allow nested output path
204
- if (output. startsWith(path) || path. startsWith(output)) {
205
- return false
206
- }
207
- }
208
- return true
209
- }
210
132
}
0 commit comments