Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
531b21a
WIP: initial attempt.
perNyfelt Jul 23, 2025
a1547e9
adopt to java 8
Jul 23, 2025
a388f81
working version
Jul 25, 2025
2263a13
improve the publish artifacts retrieval.
Jul 25, 2025
09f641a
publish now works
Jul 28, 2025
e25db12
Integrate tighter with the DeployMojo. Add support for publishing a m…
Jul 31, 2025
b9a6dd6
modify deploy to central to include status check afterwards. Remove C…
Aug 1, 2025
bc28691
change default of useCentralPortalApi to false to not break any exist…
Aug 1, 2025
65f1927
WIP: adding integration tests for bundle and central deploy
Aug 2, 2025
bc853db
First integration test (central-zip-bundles) now works.
Aug 3, 2025
33cfe58
move setup logic to inside the build script to mock what the gpg plug…
perNyfelt Aug 4, 2025
a5b42cd
use variables when available. Improve support for invokation from dif…
perNyfelt Aug 4, 2025
5483453
Rename BundleService to Bundler. Integrate functionality into the Dep…
perNyfelt Aug 5, 2025
5ddb545
remove some overly verbose output.
perNyfelt Aug 5, 2025
aa7cc2b
improve error output. The IT test central-deploy-megabundle now works…
perNyfelt Aug 5, 2025
f4fef1b
add content check to central-deploy-megabundle
perNyfelt Aug 6, 2025
c1a14c1
central-deploy-bundles IT complete. Everything is now working. 'mvn -…
perNyfelt Aug 6, 2025
fd6f2fe
Add a unit test. Add an integration test for a simple project layout.
perNyfelt Aug 7, 2025
2fdde74
Cleanup unit test
perNyfelt Aug 7, 2025
8ca2821
create a subdir under target for each test method
perNyfelt Aug 7, 2025
c1eb0b6
move common config code to the setup method
perNyfelt Aug 8, 2025
feb5baf
add more unit tests
perNyfelt Aug 8, 2025
f85d7a6
fix documentation. add rainy day test for DeployMojo.
perNyfelt Aug 8, 2025
4908518
Reduce verbosity of output.
perNyfelt Aug 8, 2025
0e5a154
Use ChecksumUtils to generate checksum instead of rolling our own.
perNyfelt Aug 8, 2025
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
38 changes: 38 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,44 @@ under the License.
<goal>deploy</goal>
</goals>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.53.v20231009</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.4.53.v20231009</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.14.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
Expand Down
51 changes: 51 additions & 0 deletions src/it/central-deploy-bundles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
# central-deploy-bundles

This is a multimodule example showing deployment to maven central
using the new central publishing rest api.

The project consist of
- an aggregator
- a common sub module
- two sub modules that each depends on the common submodule

Each module (including the main aggregator) will be deployed separately.
I.e. when deploying the whole project, 4 zip files will be created and uploaded to central:
1. The aggregator pom (+ asc, md5 and sha1 files)
2. common, contains the pom, jar, javadoc and sources (all signed and with md5 and sha1 files)
3. subA, contains the pom, jar, javadoc and sources (all signed and with md5 and sha1 files)
4. subB, contains the pom, jar, javadoc and sources (all signed and with md5 and sha1 files)

## Running only this test
```shell
mvn -Prun-its verify -Dinvoker.test=central-deploy-bundles
```

## Running the test manually
```shell
# copy resources
mvn -Prun-its verify -Dinvoker.test=central-deploy-bundles
cd target/it/central-deploy-bundles
CLASSPATH=$(find "$MAVEN_HOME/lib" -name "*.jar" | tr '\n' ':' | sed 's/:$//')
CLASSPATH=$CLASSPATH:$(./addDependencies.groovy)
groovy -cp $CLASSPATH -Dbasedir=$PWD setup.groovy &
mvn --settings ../../../src/it/settings.xml deploy
groovy -cp $CLASSPATH -Dbasedir=$PWD verify.groovy
```
87 changes: 87 additions & 0 deletions src/it/central-deploy-bundles/addDependencies.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env groovy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// This script creates a classpath string based on the dependencies for the invoker plugin
// It is used when you want to change the groovy scripts and have more control from the command line
// i.e allows you to run each step manually. See readme.md for details.
import groovy.xml.XmlParser
import groovy.xml.XmlNodePrinter
import groovy.xml.StreamingMarkupBuilder

// Paths
def realPom = new File("../../../pom.xml")
def tmpDir = File.createTempFile("tmp", "")
tmpDir.delete()
tmpDir.mkdirs()
def tmpPom = new File(tmpDir, "pom.xml")
def depsDir = new File(tmpDir, "deps")
depsDir.mkdirs()

// Parse original POM without namespaces
def parser = new XmlParser(false, false) // disable namespaces
def pom = parser.parse(realPom)

// Locate dependencies inside maven-invoker-plugin / run-its profile
def runItsProfile = pom.profiles.profile.find { it.id.text() == "run-its" }
def rawDeps = []
if (runItsProfile) {
rawDeps = runItsProfile.depthFirst().findAll {
it.name() == "plugin" && it.artifactId.text() == "maven-invoker-plugin"
}*.dependencies*.dependency.flatten()
}

// Build minimal POM
def newPom = {
mkp.xmlDeclaration()
project(xmlns: "http://maven.apache.org/POM/4.0.0",
'xmlns:xsi': "http://www.w3.org/2001/XMLSchema-instance",
'xsi:schemaLocation': "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd") {
modelVersion("4.0.0")
groupId("temp")
artifactId("invoker-plugin-deps")
version("1.0-SNAPSHOT")
dependencies {
rawDeps.each { dep ->
dependency {
groupId(dep.groupId.text())
artifactId(dep.artifactId.text())
version(dep.version.text())
if (dep.scope) scope(dep.scope.text())
}
}
}
}
}

// Write temp POM
tmpPom.text = new StreamingMarkupBuilder().bind(newPom).toString()

//println "Downloading dependencies..."
def proc = ["mvn", "-q", "-f", tmpPom.absolutePath,
"dependency:copy-dependencies",
"-DoutputDirectory=${depsDir.absolutePath}",
"-DincludeScope=runtime"].execute()
proc.in.eachLine { println it }
proc.err.eachLine { System.err.println it }
proc.waitFor()

// Build classpath
def jars = depsDir.listFiles().findAll { it.name.endsWith(".jar") }
def classpath = jars.collect { it.absolutePath }.join(":")
println classpath
63 changes: 63 additions & 0 deletions src/it/central-deploy-bundles/common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>se.alipsa.maven.example</groupId>
<artifactId>publishing-example-parent</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>publishing-example-common</artifactId>
<name>Maven Central Publishing Example, Common</name>
<url>https://github.com/perNyfelt/maven-central-publishing-example</url>
<packaging>jar</packaging>

<description>Maven Central Publishing Example, Common</description>
<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<id>pnyfelt</id>
<name>Per Nyfelt</name>
</developer>
</developers>
<scm>
<url>https://github.com/perNyfelt/maven-central-publishing-example/tree/master</url>
<connection>scm:git:https://github.com/perNyfelt/maven-central-publishing-example.git</connection>
<developerConnection>scm:git:https://github.com/perNyfelt/maven-central-publishing-example.git</developerConnection>
</scm>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
19 changes: 19 additions & 0 deletions src/it/central-deploy-bundles/common/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
# This is the common module for the multimodule project
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package multimodule.common;

/**
* Common interface to define a greeting.
*/
public interface Greeting {

/**
* Hello {name}.
*
* @param name the name to greet
* @return Hello {name}
*/
String greet(String name);

/**
* Prints some info.
*/
default void info() {
System.out.println(this.getClass());
}
}
Loading