-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from wavesoftware/feature/9-maven-generator
Feature: Generator for Plugs via Maven plugin
- Loading branch information
Showing
172 changed files
with
10,015 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
plug-api/src/main/java/pl/wavesoftware/plugs/api/PlugsVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
26
plug-api/src/main/java/pl/wavesoftware/plugs/api/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
41 changes: 41 additions & 0 deletions
41
plug-api/src/test/java/pl/wavesoftware/plugs/api/PlugsVersionIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
plug-api/src/test/java/pl/wavesoftware/plugs/api/PlugsVersionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.