stevedlawrence commented on a change in pull request #486:
URL: https://github.com/apache/incubator-daffodil/pull/486#discussion_r568748266



##########
File path: build.sbt
##########
@@ -177,7 +182,18 @@ lazy val usesMacros = Seq(
   // ignores files such a META-INFA/LICENSE and NOTICE that are duplicated and
   // would otherwise cause a conflict
   mappings in (Compile, packageBin) ++= mappings.in(macroLib, Compile, 
packageBin).value.filter { case (f, _) => f.isDirectory || 
f.getPath.endsWith(".class") },
-  mappings in (Compile, packageSrc) ++= mappings.in(macroLib, Compile, 
packageSrc).value
+  mappings in (Compile, packageSrc) ++= mappings.in(macroLib, Compile, 
packageSrc).value,
+
+  // The sbt eclipse plugin does not addd the macroLib project as a dependency
+  // in .classpath files because macroLib isn't actually an sbt dependncy.
+  // Instead, sbt does the above stuff to copy macro lib files into those
+  // projects that need it. Because this copy doesn't happen for eclipse,
+  // eclipse can't find the macroLib files and leads to compilation errors. To
+  // fix this, we add an sbt eclipse transformer that adds the missing macroLib
+  // dependency to .classpath files only for these projects that use the 
macroLib
+  EclipseKeys.classpathTransformerFactories ++= Seq(
+    transformNode("classpath", 
DefaultTransforms.Append(EclipseClasspathEntry.Project(macroLib.base.toString))),

Review comment:
       {code:scala}
   transformNode("classpath", 
DefaultTransforms.Append(EclipseClasspathEntry.Project(macroLib.base.toString)))
   {code}
   This line says to transform the "classpath" node. And the transformation it 
will apply is "Append" to children. And it will append a ClassPathEntry 
Project. So this line appends  new ``<classpathentry... >`` dependency for the 
macro lib project.
   
   As to how this doesn't apply this transformation for the macro-lib project 
itself, this setting is in the "usesMacros" group of settings. So any projects 
that uses macros need to add the compile-internal dependency to macro lib, and 
add the "usesMacros" settings. For example, daffodil-io looks like this:
   {code}
   lazy val io               = Project("daffodil-io", 
file("daffodil-io")).configs(IntegrationTest)
                                 .dependsOn(lib, macroLib % "compile-internal, 
test-internal")
                                 .settings(commonSettings, usesMacros)
   {code}
   So only projects that have usesMacros will get this transformation and will 
add the dependency to eclipse files. Since macro-lib doesn't have usesMacro, 
the depenceny isn't added. In fact, this now means only add this classpathentry 
to daffodil-lib, daffodil-io, and daffodil-runtime1 (the only things that has 
usesMacros) so most eclipse projects now won't have this depenency added. 
Probably not a big deal technically, but maybe has the potential to speed up 
compiling with one less depenency?
   {code}




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to