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

Feature: Generator for Plugs via Maven plugin #18

Merged
merged 24 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0008717
Adding basic architecture of Maven plugin
cardil Jan 13, 2019
7ad3041
Adding most of basic packager logic
cardil Jan 15, 2019
87f000d
Adding AppVeyor
Mar 22, 2019
8179719
Fails nicely if can't create target directories
cardil Mar 24, 2019
3643265
Plugs maven plugin IT tests passes
cardil Mar 24, 2019
be8c902
Configure Jacoco reporting for Maven multi module project
Mar 25, 2019
d675ab5
Removing unpacks, adding code to properly handle Maven dependencies
Mar 28, 2019
78dc920
Adding Maven generator for Plugs
cardil Jan 10, 2019
9f7bb73
Move mojo extension to separate package
cardil Jan 13, 2019
4d61e8c
Main flow of Maven plugin
cardil Jan 17, 2019
ab27022
Rewrite to repackage main jar artifact
cardil Feb 1, 2019
ba37fdd
Adding Maven transport to be able to fetch artifacts via HTTP
Mar 22, 2019
46084d9
Configure Jacoco for multimodule project in SonarQube
Mar 25, 2019
a181508
Working IT cases with proper manifest basic entries
Mar 25, 2019
af99f43
Resolving Maven dependencies
Mar 29, 2019
4c93495
Adding plugs packager samples and testing modules
May 20, 2019
d6cd936
Merge 'develop' into feature/9-maven-generator
cardil Aug 29, 2019
3604767
Add tools to coverage
cardil Aug 29, 2019
20ddd78
Fixing Sonar issues
cardil Sep 4, 2019
66464ad
Adding test to assert filters
cardil Sep 22, 2019
2131218
Adding couple more tests to cover code
cardil Sep 24, 2019
0dd2699
Tests to check version and maven logger classes
cardil Sep 24, 2019
da213ed
Tests for LibrariesJarWriter and PackagePlugMojoIT
cardil Sep 24, 2019
a1ce24a
Remove CoodeCov in favor of SonarCloud
cardil Sep 25, 2019
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: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ matrix:
# Quality testing
- jdk: oraclejdk8
env: JACOCO=true RELEASE_CHECKS=true
after_success:
- bash <(curl -s https://codecov.io/bash)
- jdk: oraclejdk8
env: JACOCO=true SONAR=publish
# Performance testing
Expand Down
116 changes: 116 additions & 0 deletions boms-parent/maven-plugin-bom/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2019 Wave Software
~
~ Licensed 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>pl.wavesoftware.plugs.boms</groupId>
<artifactId>bom-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<artifactId>maven-plugin-bom</artifactId>
<packaging>pom</packaging>

<name>Plugs :: BOM :: Maven Plugin BOM</name>

<properties>
<!-- Minimum version of Maven -->
<maven-plugin.version>3.3.9</maven-plugin.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven-plugin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven-plugin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>${maven-plugin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-common-artifact-filters</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-connector-basic</artifactId>
<version>1.0.2.v20150114</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-transport-wagon</artifactId>
<version>1.0.2.v20150114</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http</artifactId>
<version>2.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings-builder</artifactId>
<version>${maven-plugin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.18</version>
</dependency>

<!-- Tests -->
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>${maven-plugin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
10 changes: 8 additions & 2 deletions plugs-maven-plugin/pom.xml → boms-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
<groupId>pl.wavesoftware.plugs</groupId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<groupId>pl.wavesoftware.plugs.boms</groupId>
<artifactId>bom-parent</artifactId>
<packaging>pom</packaging>

<artifactId>plugs-maven-plugin</artifactId>
<name>Plugs :: Plugs Maven Plugin</name>
<name>Plugs :: BOM Parent</name>

<modules>
<module>maven-plugin-bom</module>
</modules>
</project>
25 changes: 25 additions & 0 deletions plug-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,29 @@
<artifactId>plug-api</artifactId>

<name>Plugs :: Plug API</name>

<properties>
<unpack-manifestmf.skip>false</unpack-manifestmf.skip>
</properties>

<dependencies>
<dependency>
<groupId>pl.wavesoftware</groupId>
<artifactId>eid-exceptions</artifactId>
</dependency>

<!-- Tests -->
<dependency>
<groupId>pl.wavesoftware.testing</groupId>
<artifactId>junit5-starter</artifactId>
<version>1.0.0</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>semver4j</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
80 changes: 80 additions & 0 deletions plug-api/src/main/java/pl/wavesoftware/plugs/api/PlugsVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2019 Wave Software
*
* Licensed 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 pl.wavesoftware.plugs.api;

import pl.wavesoftware.eid.exceptions.EidIllegalArgumentException;

import java.io.InputStream;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.jar.Manifest;

import static pl.wavesoftware.eid.utils.EidExecutions.tryToExecute;
import static pl.wavesoftware.eid.utils.EidPreconditions.checkNotNull;

public final class PlugsVersion {

private final ClassLoader classLoader;

private PlugsVersion() {
this(Thread.currentThread().getContextClassLoader());
}

PlugsVersion(ClassLoader classLoader) {
this.classLoader = classLoader;
}

public static PlugsVersion get() {
return new PlugsVersion();
}

public String getVersion() {
Optional<String> maybeVersion =
Optional.ofNullable(
PlugsVersion.class.getPackage().getImplementationVersion()
);
return checkNotNull(
maybeVersion.orElseGet(this::manuallyRead),
"20190325:202509"
);
}

String manuallyRead() {
List<URL> urls = Collections.list(tryToExecute(
() -> classLoader
.getResources("META-INF/MANIFEST.MF"),
"20190325:205203"
));
URL location = PlugsVersion.class.getProtectionDomain().getCodeSource().getLocation();
URL resource = urls.stream()
.filter(url -> url.toString().contains(location.toString()))
.findFirst()
.orElseThrow(() -> new EidIllegalArgumentException("20190325:205648"));
InputStream inputStream = checkNotNull(
tryToExecute(resource::openStream, "20190325:205720"),
"20190325:204807"
);
Manifest manifest = tryToExecute(
() -> new Manifest(inputStream),
"20190325:204433"
);
return manifest.getMainAttributes()
.getValue("Implementation-Version");
}
}
26 changes: 26 additions & 0 deletions plug-api/src/main/java/pl/wavesoftware/plugs/api/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2019 Wave Software
*
* Licensed 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.
*/

/**
* @author <a href="mailto:[email protected]">Krzysztof Suszynski</a>
* @since 2019-01-03
*/
@ReturnTypesAreNonnullByDefault
@ParametersAreNonnullByDefault
package pl.wavesoftware.plugs.api;

import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2019 Wave Software
*
* Licensed 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 pl.wavesoftware.plugs.api;

import com.vdurmont.semver4j.Semver;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class PlugsVersionIT {

private static final Semver BASE = new Semver("0.0.0");

@Test
void getVersion() {
Semver version = new Semver(PlugsVersion.get().getVersion());

assertThat(version.isGreaterThanOrEqualTo(BASE)).isTrue();
}

@Test
void manually() {
Semver version = new Semver(PlugsVersion.get().manuallyRead());

assertThat(version.isGreaterThanOrEqualTo(BASE)).isTrue();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2019 Wave Software
*
* Licensed 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 pl.wavesoftware.plugs.api;

import org.junit.jupiter.api.Test;

import java.net.URL;
import java.net.URLClassLoader;

import static org.assertj.core.api.Assertions.assertThatCode;

/**
* @author <a href="mailto:[email protected]">Krzysztof Suszynski</a>
* @since 0.1.0
*/
final class PlugsVersionTest {
private ClassLoader classLoader = new URLClassLoader(new URL[0], null);

@Test
void getVersion() {
assertThatCode(() -> new PlugsVersion(classLoader).getVersion())
.hasMessageContaining("20190325:205648");
}
}
8 changes: 8 additions & 0 deletions plugs-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@

<name>Plugs :: Plugs Core</name>

<properties>
<unpack-manifestmf.skip>false</unpack-manifestmf.skip>
</properties>

<dependencies>
<dependency>
<groupId>org.apiguardian</groupId>
<artifactId>apiguardian-api</artifactId>
</dependency>
<dependency>
<groupId>pl.wavesoftware</groupId>
<artifactId>eid-exceptions</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
* @author <a href="mailto:[email protected]">Krzysztof Suszynski</a>
* @since 2019-01-03
*/
@ReturnTypesAreNonnullByDefault
@ParametersAreNonnullByDefault
package pl.wavesoftware.plugs.core;

import pl.wavesoftware.eid.api.ReturnTypesAreNonnullByDefault;
import javax.annotation.ParametersAreNonnullByDefault;
4 changes: 4 additions & 0 deletions plugs-felix/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
<artifactId>plugs-felix</artifactId>
<name>Plugs :: Felix</name>

<properties>
<unpack-manifestmf.skip>false</unpack-manifestmf.skip>
</properties>

<dependencies>
<dependency>
<groupId>pl.wavesoftware.plugs</groupId>
Expand Down
Loading