Skip to content

Commit

Permalink
Merge pull request #18 from wavesoftware/feature/9-maven-generator
Browse files Browse the repository at this point in the history
Feature: Generator for Plugs via Maven plugin
  • Loading branch information
cardil authored Sep 25, 2019
2 parents 7ae885a + a1ce24a commit dfd18ea
Show file tree
Hide file tree
Showing 172 changed files with 10,015 additions and 18 deletions.
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

0 comments on commit dfd18ea

Please sign in to comment.