Skip to content

Commit

Permalink
Merge pull request #8 from vpa1977/maven-plugin-basic
Browse files Browse the repository at this point in the history
feat: basic maven rock plugin
  • Loading branch information
vpa1977 authored Oct 7, 2024
2 parents b8d746b + 03f2550 commit e2d00c1
Show file tree
Hide file tree
Showing 18 changed files with 569 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@ jobs:
with:
channel: 5.21/candidate

- name: Build and verify project
- name: Setup rockcraft
run: |
sudo snap install rockcraft --classic
- name: Build and verify maven project
run: |
mvn install invoker:install invoker:run
- name: Build and verify gradle project
run: |
./gradlew clean build -i
- name: Publish Snapshots
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.vscode
# Ignore Gradle build output directory
build
target
38 changes: 38 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.canonical</groupId>
<artifactId>rockcraft-parent</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<properties>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.release>8</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<modules>
<module>rockcraft</module>
<module>rockcraft-maven</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.0</version>
</plugin>
</plugins>
</build>
</project>
151 changes: 151 additions & 0 deletions rockcraft-maven/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<project>
<parent>
<groupId>com.canonical</groupId>
<artifactId>rockcraft-parent</artifactId>
<version>0.0.1</version>
</parent>

<packaging>maven-plugin</packaging>
<properties>
<maven-invoker-plugin.version>3.8.0</maven-invoker-plugin.version>
<maven-plugin-tools.version>3.13.1</maven-plugin-tools.version>
<mavenVersion>3.9.9</mavenVersion>
<mavenPluginVersion>3.15.0</mavenPluginVersion>
<guiceVersion>6.0.0</guiceVersion>
<mockitoVersion>5.12.0</mockitoVersion>
<mavenPluginTestingHarnessVersion>4.0.0-beta-1</mavenPluginTestingHarnessVersion>
</properties>

<modelVersion>4.0.0</modelVersion>
<artifactId>rockcraft-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>${mavenPluginVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools-java</artifactId>
<version>${maven-plugin-tools.version}</version>
<scope>provided</scope>
</dependency>
<!-- Maven -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>3.4.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.canonical</groupId>
<artifactId>rockcraft</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.11.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>${maven-invoker-plugin.version}</version>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<settingsFile>src/it/settings.xml</settingsFile>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<!---
Don't use addTestClassPath as it interferes with the classpath -->
<postBuildHookScript>verify</postBuildHookScript>
<skipInvocation>${skipTests}</skipInvocation>
<streamLogs>true</streamLogs>
<!-- Silences repetitive "downloading" logs from the local repo.
Note: this also silences logs about integration test runs! -->
<mavenOpts>-Dorg.slf4j.simpleLogger.defaultLogLevel=WARN</mavenOpts>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>${maven-plugin-tools.version}</version>
<executions>
<execution>
<id>help-mojo</id>
<goals>
<goal>helpmojo</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<excludes>
<exclude>unit/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
8 changes: 8 additions & 0 deletions rockcraft-maven/src/it/basic-rock/foo/Foo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package foo;

public class Foo {
public Foo() {
System.out.println("Foo");
}

}
1 change: 1 addition & 0 deletions rockcraft-maven/src/it/basic-rock/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=--no-transfer-progress install -X
29 changes: 29 additions & 0 deletions rockcraft-maven/src/it/basic-rock/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<project>
<groupId>foo</groupId>
<artifactId>foo</artifactId>
<version>1</version>
<modelVersion>4.0.0</modelVersion>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>
<build>
<directory>${project.basedir}/target</directory>
<outputDirectory>${project.basedir}/target/classes</outputDirectory>
<testOutputDirectory>${project.basedir}/target/test-classes</testOutputDirectory>
<plugins>
<plugin>
<groupId>com.canonical</groupId>
<artifactId>rockcraft-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>create-rock</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

14 changes: 14 additions & 0 deletions rockcraft-maven/src/it/basic-rock/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.io.*;

File target = new File( basedir, "target" );

var files = target.listFiles(new FilenameFilter(){
public boolean accept(File dir, String name) {
return name.equals("rockcraft.yaml");
}
});

if ( files == null || files.length == 0 )
{
throw new FileNotFoundException( "Could not find generated rock file in " + rockOut );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=--no-transfer-progress install
47 changes: 47 additions & 0 deletions rockcraft-maven/src/it/manual-create-rock-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<project>
<groupId>foo</groupId>
<artifactId>foo</artifactId>
<version>1</version>
<modelVersion>4.0.0</modelVersion>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<build>
<directory>${project.basedir}/target</directory>
<outputDirectory>${project.basedir}/target/classes</outputDirectory>
<testOutputDirectory>${project.basedir}/target/test-classes</testOutputDirectory>
<plugins>
<plugin>
<groupId>com.canonical</groupId>
<artifactId>rockcraft-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>create-rock</goal>
<goal>build-rock</goal>
</goals>
</execution>
</executions>
<configuration>
<docker>true</docker>
<buildPackage>openjdk-17-jdk-headless</buildPackage>
<targetRelease>17</targetRelease>
<jlink>false</jlink>
<summary>foo</summary>
<description>readme.txt</description>
<source>https://github.com/vpa1977/chisel-releases</source>
<branch>24.04-openjdk-17</branch>
<architectures>
<architecture>amd64</architecture>
<architecture>arm64</architecture>
</architectures>
<slices>
<slice>busybox_bins</slice>
<slice>dash_bins</slice>
</slices>
</configuration>
</plugin>
</plugins>
</build>
</project>
1 change: 1 addition & 0 deletions rockcraft-maven/src/it/manual-create-rock-test/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package foo;

public class Foo {
public Foo() {
System.out.println("Foo");
}

}
34 changes: 34 additions & 0 deletions rockcraft-maven/src/it/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<settings>
<profiles>
<profile>
<id>it-repo</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>local.central</id>
<url>@localRepositoryUrl@</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>local.central</id>
<url>@localRepositoryUrl@</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
Loading

0 comments on commit e2d00c1

Please sign in to comment.