NPanday
  1. NPanday
  2. NPANDAY-486

Implement integrated XBuild/MSBuild lifecycle (superseeds current MSBuild integration)

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.4-incubating
    • Fix Version/s: Backlog
    • Component/s: Maven Plugins
    • Labels:
      None
    • Environment:

      Windows/.NET: MSBuild; Mono: Xbuild

      Description

      The current MSBuild integration is a hack initially implemented to support WPF projects (XAML code- and resources-generation)

      It was initially implemented as a dotnet-maven-plugin, but now also the Java binding has been forked from the originally generated source. Also, currently sources are compiled twice; once via MSBuild and then later through NPanday.

      Functional Requirements (high-level)

      • It must be possible to compile WPF-projects (with Xaml-files)
      • It must be extensible though custom MSBuild
      • any more?

      Conditions / Design Decisions

      • The Maven principle of reproducible builds must be met.
      • Dependencies from pom must override those specified in the build file
      • Correct versions of dependencies must be ensured
      • Project-references must be resolved inside the reactor, if possible.
      • Generated code or resource must automatically be added to the POM (in-memory?)
      • MSBuild targets should run in the most appropriate maven phase
      • MSBuild errors must be correctly reported
      • MSBuild-shadowing should be extensible (wildcard-include), means: {{ {target/msbuild/build.xml}

        }}, importing:

        • {{ {use-generated-assembly-info.targets}

          }}

        • {{ {override-output-paths.targets}

          }}

        • ...
      • We could suppress the actual C#/VB-compilation and all following steps; then run msbuild in process-sources
        • hence: {{ {skip-CoreCompile-and-following.targets}

          }}

      Two MSBuild Lifecycles

      Trying to figure out, how MSBuild can be integrated with the standard Maven lifecycle.

      red: changes to maven-compile-plugin lifecycle
      green: msbuild concern

      Integrated MSBuild Lifecycle Draft

      This would run MSBuild up until short before compilation (CSC/VBC). Generation of the final artifacts are then still left to NPanday.

      Means more control, but could mean less compatibility.

      validate

      • NPanday Plugins : maven-compile-plugin : initialize Necessary?: runs {assemblyResolver.resolveTransitivelyFor} and {assemblerContext.init}
      • NPanday Plugins : maven-resolver-plugin : resolve
      • NPanday Plugins : NPanday.Plugin.Settings.JavaBinding : generate-settings
      • NPanday Plugins : msbuild-maven-plugin : initialize (finds the MSBuild file and validates that msbuild is available?)

      on generate-sources

      • NPanday Plugins : msbuild-maven-plugin : shaddow (creates msbuild-file, figures out parametrization)
        • Should find 'integrated' contributors (through plexus) and execute all of them
        • Replace {CoreCompile} target and skip following targets
        • ??
      • NPanday Plugins : msbuild-maven-plugin : run-integrated
        • Runs all MSBuild targets up to CoreCompile
        • Includes dynamically added sources from @(Compile) to build/sources (apply excludes afterwards!)
        • Includes dynamically added resources from @(Compile) to build/resources (apply excludes afterwards!)
      • NPanday Plugins : maven-compile-plugin : generate-assembly-info

      on process-sources

      • NPanday Plugins : maven-compile-plugin : process-sources
      • NPanday Plugins : maven-compile-plugin : process-test-sources
      • NPanday Plugins : msbuild-maven-plugin : shadow-assembly-info (should share code with generate-assembly-info)

      on process-resources

      • NPanday Plugins : maven-resgen-plugin : copy-resources
      • NPanday Plugins : maven-resgen-plugin : generate
      • NPanday Plugins : maven-resgen-plugin : generate-existing-resx-to-resource

      on compile

      • NPanday Plugins : maven-compile-plugin : compile

      on test-compile

      • NPanday Plugins : maven-compile-plugin : testCompile

      on test

      • NPanday Plugins : maven-test-plugin : test

      on install

      • NPanday Plugins : maven-repository-plugin : convert-artifact
      • NPanday Plugins : maven-install-plugin : install
      • Maven Plugins : maven-install-plugin : install

      on deploy

      • Maven Plugins : maven-deploy-plugin : deploy

      Delegating MSBuild Lifecycle Draft

      This would use MSBuild to actually create the final artifact. Means more compatibility, but lesser control.

      validate

      • NPanday Plugins : maven-compile-plugin : initialize Necessary?: runs {assemblyResolver.resolveTransitivelyFor} and {assemblerContext.init}
      • NPanday Plugins : maven-resolver-plugin : resolve
      • NPanday Plugins : NPanday.Plugin.Settings.JavaBinding : generate-settings
      • NPanday Plugins : msbuild-maven-plugin : initialize (finds the MSBuild file and validates that msbuild is available?)

      on generate-sources

      • NPanday Plugins : maven-compile-plugin : generate-assembly-info
      • NPanday Plugins : msbuild-maven-plugin : shaddow (creates msbuild-file, figures out parametrization)
        • should find 'standalone' concerns (through plexus) and execute all of them
        • Replaces the previous AssemblyInfo with the new, generated, one
        • Applies source and resource includes/excludes from pom to MSBuild
        • override dependencies / project dependencies

      on process-sources

      • NPanday Plugins : maven-compile-plugin : process-sources
      • NPanday Plugins : maven-compile-plugin : process-test-sources

      on process-resources

      • NPanday Plugins : maven-resgen-plugin : copy-resources Should this still be supported?
      • NPanday Plugins : maven-resgen-plugin : generate
      • NPanday Plugins : maven-resgen-plugin : generate-existing-resx-to-resource

      on compile

      • NPanday Plugins : maven-compile-plugin : compile
      • NPanday Plugins : msbuild-maven-plugin : run-standalone

      on test-compile

      • NPanday Plugins : maven-compile-plugin : testCompile
      • NPanday Plugins : msbuild-maven-plugin : run-standalone-test

      on test

      • NPanday Plugins : maven-test-plugin : test

      verify

      • NPanday Plugins : msbuild-maven-plugin : verify (Make sure the main artifact was generated by msbuild)

      on install

      • NPanday Plugins : maven-repository-plugin : convert-artifact
      • NPanday Plugins : maven-install-plugin : install
      • Maven Plugins : maven-install-plugin : install

      on deploy

      • Maven Plugins : maven-deploy-plugin : deploy

      Just for reference: Current MSBuild integration

      In order to "activate" MSBuild, the plugin {{

      {NPanday.Plugin.Msbuild.JavaBinding}

      }} must be configured:

      <plugin>
      <groupId>org.apache.npanday.plugins</groupId>
      <artifactId>NPanday.Plugin.Msbuild.JavaBinding</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      

      Also currently, code generated by MSBuild seems to have to be included manually!

      from NPANDAY_328_VS2010WpfProjectSupportTest
      ...
      <includeSource>obj\x86\Debug\App.g.cs</includeSource>
      ...
      

      It registers MsbuildMojo.java to the validate-phase, which performs these steps:

      • preExecute: If {{ {copyDependencies}

        }} is {{

        {true}

        }} (is true by default), it will copy all dependencies of the current project to {{

        {basedir/bin/Debug}

        }}

      • preExecute: Then it adds all *.resource-files from {{ {obj/Debug}

        }} to project resources (using {{

        {project.addResource}

        }}

        • How can it even know theese, before having executed msbuild? Looks like this won't have any effect, before the second build runs.
      • Execute: Calls into {{ {MsbuildMojo.cs}

        }}

        • Searches for {{ {projectName.csproj/vbproj}

          }}

        • Runs with: {{ {/v:q /p:BuildProjectReferences=false /p:BuildingInsideVisualStudio=true}

          }}

        • Deletes

        Issue Links

          Activity

          Hide
          Brett Porter added a comment -

          regarding the resource addition - it doesn't need to know them in the Java mojo. It is establishing a pattern, that is run later by the Maven resources plugin to copy whatever was generated.

          Do you intend to support both lifecycles? If so, maybe a good idea to create separate issues.

          Show
          Brett Porter added a comment - regarding the resource addition - it doesn't need to know them in the Java mojo. It is establishing a pattern, that is run later by the Maven resources plugin to copy whatever was generated. Do you intend to support both lifecycles? If so, maybe a good idea to create separate issues.
          Hide
          Lars Corneliussen added a comment -

          > resources
          OK

          > both lifecycles
          I'd do that whenever we exactly know what to implement and when.

          Show
          Lars Corneliussen added a comment - > resources OK > both lifecycles I'd do that whenever we exactly know what to implement and when.

            People

            • Assignee:
              Lars Corneliussen
              Reporter:
              Lars Corneliussen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Development