|
20 | 20 | <project name="lucene-solr" default="-projecthelp" basedir=".">
|
21 | 21 | <import file="lucene/common-build.xml"/>
|
22 | 22 |
|
| 23 | + <property name="jgit-version" value="4.2.0.201601211800-r"/> |
| 24 | + |
23 | 25 | <property name="tests.heap-dump-dir" location="heapdumps"/>
|
24 | 26 |
|
25 | 27 | <property name="maven-build-dir" value="maven-build"/>
|
@@ -551,8 +553,71 @@ File | Project Structure | Platform Settings | SDKs):
|
551 | 553 | <delete dir="${smokeTestRelease.tmp}"/>
|
552 | 554 | </target>
|
553 | 555 |
|
554 |
| - <target name="check-working-copy"> |
555 |
| - <echo>This task is currently disabled due to migration to GIT</echo> |
| 556 | + <macrodef xmlns:ivy="antlib:org.apache.ivy.ant" name="wc-checker"> |
| 557 | + <attribute name="failonmodifications"/><!-- fail if modifications were found, otherwise it only fails on unversioned files --> |
| 558 | + <sequential> |
| 559 | + <local name="wc.unversioned.files"/> |
| 560 | + <local name="wc.modified.files"/> |
| 561 | + <ivy:cachepath xmlns:ivy="antlib:org.apache.ivy.ant" |
| 562 | + organisation="org.eclipse.jgit" module="org.eclipse.jgit" revision="${jgit-version}" |
| 563 | + inline="true" conf="default" transitive="true" pathid="jgit.classpath"/> |
| 564 | + <groovy taskname="wc-checker" classpathref="jgit.classpath"><![CDATA[ |
| 565 | + import org.apache.tools.ant.BuildException; |
| 566 | + import org.apache.tools.ant.Project; |
| 567 | + import org.eclipse.jgit.api.Git; |
| 568 | + import org.eclipse.jgit.api.Status; |
| 569 | + import org.eclipse.jgit.lib.Repository; |
| 570 | + import org.eclipse.jgit.storage.file.FileRepositoryBuilder; |
| 571 | + import org.eclipse.jgit.errors.*; |
| 572 | +
|
| 573 | + def setProjectPropertyFromSet(prop, set) { |
| 574 | + if (set) { |
| 575 | + properties[prop] = '* ' + set.join(properties['line.separator'] + '* '); |
| 576 | + } |
| 577 | + }; |
| 578 | +
|
| 579 | + try { |
| 580 | + task.log('Initializing working copy...', Project.MSG_INFO); |
| 581 | + final Repository repository = new FileRepositoryBuilder() |
| 582 | + .setWorkTree(project.getBaseDir()) |
| 583 | + .setMustExist(true) |
| 584 | + .build(); |
| 585 | +
|
| 586 | + task.log('Checking working copy status...', Project.MSG_INFO); |
| 587 | + final Status status = new Git(repository).status().call(); |
| 588 | + if (!status.isClean()) { |
| 589 | + final SortedSet unversioned = new TreeSet(), modified = new TreeSet(); |
| 590 | + status.properties.each{ prop, val -> |
| 591 | + if (val instanceof Set) { |
| 592 | + if (prop in ['untracked', 'untrackedFolders', 'missing']) { |
| 593 | + unversioned.addAll(val); |
| 594 | + } else if (prop != 'ignoredNotInIndex') { |
| 595 | + modified.addAll(val); |
| 596 | + } |
| 597 | + } |
| 598 | + }; |
| 599 | + setProjectPropertyFromSet('wc.unversioned.files', unversioned); |
| 600 | + setProjectPropertyFromSet('wc.modified.files', modified); |
| 601 | + } |
| 602 | + } catch (RepositoryNotFoundException | NoWorkTreeException | NotSupportedException e) { |
| 603 | + task.log('WARNING: Development directory is not a valid GIT checkout! Disabling checks...', Project.MSG_WARN); |
| 604 | + } |
| 605 | + ]]></groovy> |
| 606 | + <fail if="wc.unversioned.files" |
| 607 | + message="Source checkout is dirty (unversioned/missing files) after running tests!!! Offending files:${line.separator}${wc.unversioned.files}"/> |
| 608 | + <fail message="Source checkout is modified!!! Offending files:${line.separator}${wc.modified.files}"> |
| 609 | + <condition> |
| 610 | + <and> |
| 611 | + <istrue value="@{failonmodifications}"/> |
| 612 | + <isset property="wc.modified.files"/> |
| 613 | + </and> |
| 614 | + </condition> |
| 615 | + </fail> |
| 616 | + </sequential> |
| 617 | + </macrodef> |
| 618 | + |
| 619 | + <target name="check-working-copy" description="Checks working copy for unversioned changes" depends="resolve-groovy"> |
| 620 | + <wc-checker failonmodifications="${is.jenkins.build}"/> |
556 | 621 | </target>
|
557 | 622 |
|
558 | 623 | <target name="run-clover" description="Runs all tests to measure coverage and generates report (pass "ANT_OPTS=-Xmx1536M" as environment)" depends="clean">
|
@@ -645,13 +710,13 @@ File | Project Structure | Platform Settings | SDKs):
|
645 | 710 | </target>
|
646 | 711 |
|
647 | 712 | <!-- should only be called by jenkins, not precommit! -->
|
648 |
| - <target name="-check-after-regeneration"> |
649 |
| - <!-- TODO --> |
| 713 | + <target name="-check-after-regeneration" depends="resolve-groovy"> |
| 714 | + <wc-checker failonmodifications="true"/> |
650 | 715 | </target>
|
651 | 716 |
|
652 | 717 | <!-- TODO: remove me when jenkins works -->
|
653 | 718 | <target name="regenerateAndCheck" depends="regenerate,-check-after-regeneration"/>
|
654 |
| - |
| 719 | + |
655 | 720 | <target name="-append-all-modules-dependencies-properties">
|
656 | 721 | <delete file="lucene/build/module.dependencies.properties"/>
|
657 | 722 | <subant target="-append-module-dependencies-properties" inheritall="false" failonerror="true">
|
|
0 commit comments