Skip to content

Commit

Permalink
Build external libs explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
pavetok committed Feb 25, 2024
1 parent 9bc3008 commit 35b251a
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 77 deletions.
2 changes: 0 additions & 2 deletions .github/Dockerfile

This file was deleted.

18 changes: 17 additions & 1 deletion baker/ansible/binaries.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
---
- name: Building and checking
hosts: lib
tasks:
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/lib/capture.yaml
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/java/check.yaml
vars:
maven_projects: "{{ product.libs|map(attribute='name') }}"
when: binary_status is changed
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/lib/build-check-publish.yaml
vars:
maven_phase: "{{ 'deploy' if repo_mode == 'rw' else 'install' }}"
when: binary_status is changed

- name: Building and checking
hosts: app
tasks:
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/java/check.yaml
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/app/build-and-check.yaml
file: tasks/app/build-check.yaml
vars:
maven_phase: package
20 changes: 9 additions & 11 deletions baker/ansible/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
vars:
image_keys: >-
{{ image_status.results
| select('changed')
| map(attribute='vendor')
| map('regex_replace', '^(.*)$', 'db/\1/' ~ devenv)
| select('changed')
| map(attribute='vendor')
| map('regex_replace', '^(.*)$', 'db/\1/' ~ devenv)
}}
when: image_status is changed
- ansible.builtin.import_tasks: # noqa: name[missing]
Expand All @@ -34,8 +34,8 @@
vars:
maven_projects: >-
{{ image_status.results
| select('changed')
| map(attribute='app')
| select('changed')
| map(attribute='app')
}}
when: image_status is changed
- ansible.builtin.import_role: # noqa: name[missing]
Expand All @@ -44,15 +44,13 @@
vars:
image_keys: >-
{{ image_status.results
| select('changed')
| map(attribute='app')
| map('regex_replace', '^(.*)$', 'app/\1/' ~ devenv)
| select('changed')
| map(attribute='app')
| map('regex_replace', '^(.*)$', 'app/\1/' ~ devenv)
}}
when: image_status is changed
- ansible.builtin.import_tasks: # noqa: name[missing]
file: tasks/app/build-and-check.yaml
vars:
maven_phase: "{{ 'deploy' if repo_mode == 'rw' else 'install' }}"
file: tasks/app/build-check.yaml
when: image_status is changed

- name: Publishing
Expand Down
3 changes: 3 additions & 0 deletions baker/ansible/inventory/aliases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ sources:
java:
ansible:
github:
binaries:
hosts:
lib:
images:
hosts:
db:
Expand Down
3 changes: 3 additions & 0 deletions baker/ansible/inventory/group_vars/all/stacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ product:
kotlin:
- service: sepuling
name: sepuling-kotlin
libs:
- name: abstraction-client
- name: messaging-client

config_exts:
lightbend_config: conf
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
- name: Build binaries
- name: Build
ansible.builtin.command:
cmd: >-
mvn {{ maven_phase|mandatory }}
mvn verify
--activate-profiles {{ devenv }}
--no-snapshot-updates
--batch-mode
Expand All @@ -21,7 +21,7 @@
--projects {{
product.apps.values()
| flatten
| map(attribute='binary')
| map(attribute='name')
| map('regex_replace', '^', ':')
| join(',')
}}
Expand Down
1 change: 1 addition & 0 deletions baker/ansible/tasks/java/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
--activate-profiles {{ devenv }}
--no-snapshot-updates
--batch-mode
--also-make
--threads 2
{% if maven_projects is defined %}
--projects {{
Expand Down
21 changes: 21 additions & 0 deletions baker/ansible/tasks/lib/build-check-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: Build
ansible.builtin.command:
cmd: >-
mvn {{ maven_phase|mandatory }}
--activate-profiles {{ devenv }}
--no-snapshot-updates
--batch-mode
--fail-fast
--also-make
--threads 2
--projects {{
product.libs
| map(attribute='name')
| map('regex_replace', '^', ':')
| join(',')
}}
--define revision={{ binary_tag }}
chdir: "{{ project.dir }}"
strip_empty_ends: false
changed_when: true
32 changes: 32 additions & 0 deletions baker/ansible/tasks/lib/capture.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
- name: Capture CID's
ansible.builtin.command:
cmd: git hash-object --stdin
stdin: |
{% for lib in product.libs %}
{{ lookup('ansible.builtin.pipe', 'git write-tree --prefix=lib/' ~ lib.name) }}
{% endfor %}
register: binary_cid
changed_when: false

- name: Declare tag
ansible.builtin.set_fact:
binary_tag: "{{ devenv }}-{{ binary_cid.stdout[:7] }}"
changed_when: false

- name: Capture status
ansible.builtin.command:
cmd: >-
mvn dependency:copy@capture
--projects :lib
{% if repo_mode == 'n/a' %}
--offline
{% else %}
--define remoteRepositories=github::::https://{{ binary_repo }}/{{ project.org }}/{{ project.name }}
{% endif %}
--define revision={{ binary_tag }}
chdir: "{{ project.dir }}"
register: binary_status
failed_when: false
changed_when:
- binary_status.rc != 0
52 changes: 22 additions & 30 deletions lib/abstraction-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,26 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>publish</id>
<activation>
<jdk>17</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
52 changes: 22 additions & 30 deletions lib/messaging-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,26 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>publish</id>
<activation>
<jdk>17</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
33 changes: 33 additions & 0 deletions lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,38 @@
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>capture</id>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>abstraction-client</artifactId>
<version>${project.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>messaging-client</artifactId>
<version>${project.version}</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

0 comments on commit 35b251a

Please sign in to comment.