Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support out of tree builds #23987

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*.iml
*.ipr
*.iws
target/
target
/var
/*/var/
/presto-product-tests/**/var/
Expand Down
83 changes: 83 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2671,5 +2671,88 @@
</plugins>
</build>
</profile>
<profile>
<id>out-of-tree-build</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>out-of-tree-build-root</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>unlink-out-of-tree-build-directory</id>
<goals><goal>exec</goal></goals>
<phase>pre-clean</phase>
<configuration>
<executable>rm</executable>
<arguments>
<argument>-rf</argument>
<argument>${project.build.directory}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>remove-out-of-tree-build-directory</id>
<goals><goal>exec</goal></goals>
<phase>pre-clean</phase>
<configuration>
<executable>rm</executable>
<arguments>
<argument>-rf</argument>
<argument>${out-of-tree-build-root}/${project.groupId}:${project.artifactId}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>create-out-of-tree-build-directory</id>
<goals><goal>exec</goal></goals>
<phase>validate</phase>
<configuration>
<executable>mkdir</executable>
<arguments>
<argument>-p</argument>
<argument>${out-of-tree-build-root}/${project.groupId}:${project.artifactId}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>link-out-of-tree-build-directory</id>
<goals><goal>exec</goal></goals>
<phase>validate</phase>
<configuration>
<executable>ln</executable>
<arguments>
<argument>-sT</argument>
<argument>${out-of-tree-build-root}/${project.groupId}:${project.artifactId}</argument>
<argument>${project.build.directory}</argument>
</arguments>
</configuration>
</execution>
</executions>
<configuration>
<longModulepath>false</longModulepath>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle</id>
<configuration>
<cacheFile>${out-of-tree-build-root}/${project.groupId}:${project.artifactId}/checkstyle-cachefile</cacheFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
10 changes: 5 additions & 5 deletions presto-docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
<artifactId>drift-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<phase>generate-sources</phase>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain the changes in this file (why did the phases change, and why did "thrift" get added to the directory path?) also, is there any noticeable difference after this change for a regular build?

Copy link
Member Author

@arhimondr arhimondr Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To support out of tree build the <module>/target directory has to be linked at the very beginning. The drift-maven-plugin is generating .thrift file definition into /target directory. To make sure the target directory is linked before the drift plugin invocation It has to be moved to a later build phase. Also generate-sources seems to be a more appropriate phase to run a plugin generating code.

Since PrestoThriftService.thrift been moved to a later phase I had to move the processing as well (to process-sources phase).

I had to move run-sphinx plugging to compile phase as keeping it in package phase introduces non determinism. Plugins in the same phase are invoked in order. But order of plugins in Maven is somehow obscure (for example what if a child module has plugins in different order than the parent module).

The reason why /thrift is needed is funny. Basically the thrift generator plugin tries to create parent directories automatically. And if a parent directory is a symbolic link - it fails.

<goals>
<goal>generate-thrift-idl</goal>
</goals>
<configuration>
<outputFile>${project.build.directory}/PrestoThriftService.thrift</outputFile>
<outputFile>${project.build.directory}/thrift/PrestoThriftService.thrift</outputFile>
<classes>
<class>com.facebook.presto.thrift.api.connector.PrestoThriftService</class>
</classes>
Expand Down Expand Up @@ -82,7 +82,7 @@
</execution>
<execution>
<id>validate-thrift-idl</id>
<phase>validate</phase>
<phase>process-sources</phase>
<goals>
<goal>exec</goal>
</goals>
Expand All @@ -92,13 +92,13 @@
<argument>-b</argument>
<argument>-c</argument>
<argument>${project.basedir}/src/main/sphinx/include/PrestoThriftService.thrift</argument>
<argument>${project.build.directory}/PrestoThriftService.thrift</argument>
<argument>${project.build.directory}/thrift/PrestoThriftService.thrift</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>run-sphinx</id>
<phase>package</phase>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
Expand Down
4 changes: 2 additions & 2 deletions presto-thrift-spec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<class>com.facebook.presto.execution.TaskStatus</class>
</classes>
<recursive>true</recursive>
<outputFile>target/presto-internal-${project.version}.thrift</outputFile>
<outputFile>target/thrift/presto-internal-${project.version}.thrift</outputFile>
</configuration>
</execution>
</executions>
Expand All @@ -70,7 +70,7 @@
<configuration>
<artifacts>
<artifact>
<file>target/presto-internal-${project.version}.thrift</file>
<file>target/thrift/presto-internal-${project.version}.thrift</file>
<type>thrift</type>
</artifact>
</artifacts>
Expand Down
Loading