Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
Default Eclipse to write to generated/java, not bin/generated/java
Browse files Browse the repository at this point in the history
Despite the sanity of outputting generated source into the "default output directory", apparently Eclipse refuses to compile with that setting. Output to generated/java instead.

We used to output to generated_src, same as gradle build, but there are adverse side-effects when the two processes share the same output location.
  • Loading branch information
alicederyn committed Feb 2, 2017
1 parent 54a1a04 commit 2558cc3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ProcessorsPlugin implements Plugin<Project> {
project.eclipse {
extensions.create('processors', EclipseProcessorsExtension)
processors.conventionMapping.outputDir = {
new File(project.eclipse.classpath.defaultOutputDir, 'generated/java')
project.file('generated/java')
}

classpath.plusConfigurations += [project.configurations.processor]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,48 +276,7 @@ public class ProcessorsPluginFunctionalTest {
def expected = """
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=bin/generated/java
org.eclipse.jdt.apt.reconcileEnabled=true
""".replaceFirst('\n','').stripIndent()
assertEquals(expected, prefsFile.text)
}

@Test
public void testEclipseAptPrefsUsesDefaultOutputDir() throws IOException {
buildFile << """
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.inferred.processors'
dependencies {
processor 'org.immutables:value:2.0.21'
}
eclipse.classpath.defaultOutputDir = file('something')
"""

new File(testProjectDir.newFolder('src', 'main', 'java'), 'MyClass.java') << """
import org.immutables.value.Value;
@Value.Immutable
public interface MyClass {
@Value.Parameter String getValue();
}
"""

File testProjectDirRoot = testProjectDir.getRoot()

GradleRunner.create()
.withProjectDir(testProjectDirRoot)
.withArguments("eclipseAptPrefs")
.build()

def prefsFile = new File(testProjectDirRoot, ".settings/org.eclipse.jdt.apt.core.prefs")

def expected = """
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=something/generated/java
org.eclipse.jdt.apt.genSrcDir=generated/java
org.eclipse.jdt.apt.reconcileEnabled=true
""".replaceFirst('\n','').stripIndent()
assertEquals(expected, prefsFile.text)
Expand Down

0 comments on commit 2558cc3

Please sign in to comment.