Skip to content

Commit

Permalink
Fixed #479 - The .mvn directory is not copied
Browse files Browse the repository at this point in the history
  • Loading branch information
khmarbaise committed Aug 23, 2024
1 parent 7535b25 commit 58dfdd4
Show file tree
Hide file tree
Showing 82 changed files with 1,453 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-m4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 4.0.0-alpha-13
maven-version: 4.0.0-beta-3
- name: Build with Maven
run: mvn verify -Prun-its -e -B -V --no-transfer-progress

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-issue-m4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ jobs:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 4.0.0-alpha-13
maven-version: 4.0.0-beta-3
- name: "Building with Maven."
run: mvn verify -e -B -V --no-transfer-progress
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
:issue-468: https://github.com/khmarbaise/maven-it-extension/issues/468[Fixed #468]
:issue-474: https://github.com/khmarbaise/maven-it-extension/issues/474[Fixed #474]
:issue-477: https://github.com/khmarbaise/maven-it-extension/issues/477[Fixed #477]
:issue-479: https://github.com/khmarbaise/maven-it-extension/issues/479[Fixed #479]
:issue-481: https://github.com/khmarbaise/maven-it-extension/issues/481[Fixed #481]
:issue-483: https://github.com/khmarbaise/maven-it-extension/issues/483[Fixed #483]
:pr-460: https://github.com/khmarbaise/maven-it-extension/pull/460[Pull request #460]
Expand All @@ -52,6 +53,8 @@

*Details*

* {issue-479} - The .mvn directory is not copied
- written IT's to prove it's working correct.
* {issue-???} - ?


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.soebes.itf.examples;

/*
* 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.
*/

import com.soebes.itf.jupiter.extension.MavenCLIOptions;
import com.soebes.itf.jupiter.extension.MavenJupiterExtension;
import com.soebes.itf.jupiter.extension.MavenOption;
import com.soebes.itf.jupiter.extension.MavenTest;
import com.soebes.itf.jupiter.maven.MavenExecutionResult;

import static com.soebes.itf.extension.assertj.MavenITAssertions.assertThat;

@MavenJupiterExtension
@MavenOption(MavenCLIOptions.NO_TRANSFER_PROGRESS)
@MavenOption(MavenCLIOptions.BATCH_MODE)
class MvnDirectoryIT {

@MavenTest
void non_hidden_files(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
.out()
.info()
.containsSubsequence(
"Scanning for projects...",
// This means .mvn/maven.config with -T 2 option has been read.
"Using the MultiThreadedBuilder implementation with a thread count of 2",
"--- enforcer:3.5.0:enforce (enforce-maven) @ kata-fraction ---",
"--- jacoco:0.8.12:prepare-agent (default) @ kata-fraction ---",
"--- resources:3.3.1:resources (default-resources) @ kata-fraction ---",
"--- compiler:3.13.0:compile (default-compile) @ kata-fraction ---",
"Tests run: 34, Failures: 0, Errors: 0, Skipped: 0"
);
assertThat(result)
.isSuccessful()
.out()
.warn().isEmpty();
}

@MavenTest
void hidden_files_only(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
.out()
.info()
.doesNotContain("Using the MultiThreadedBuilder implementation with a thread count of 2")
.containsSubsequence(
"Scanning for projects...",
"--- enforcer:3.5.0:enforce (enforce-maven) @ kata-fraction ---",
"--- jacoco:0.8.12:prepare-agent (default) @ kata-fraction ---",
"--- resources:3.3.1:resources (default-resources) @ kata-fraction ---",
"--- compiler:3.13.0:compile (default-compile) @ kata-fraction ---",
"Tests run: 34, Failures: 0, Errors: 0, Skipped: 0"
);
assertThat(result)
.isSuccessful()
.out()
.warn().isEmpty();
}

}
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.soebes.smpp</groupId>
<artifactId>smpp</artifactId>
<version>7.0.0</version>
<relativePath/>
</parent>

<groupId>com.soebes.katas</groupId>
<artifactId>kata-fraction</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<smpp.component>kata-fraction</smpp.component>
<maven.compiler.release>8</maven.compiler.release>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.1</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.15.5</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.25.0</version>
</dependency>
<dependency>
<groupId>org.apiguardian</groupId>
<artifactId>apiguardian-api</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apiguardian</groupId>
<artifactId>apiguardian-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs combine.self="append">
<arg>-Xlint:-options</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package com.soebes.kata.fraction;

/*
* 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.
*/

import org.apiguardian.api.API;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Objects;
import java.util.StringJoiner;

import static org.apiguardian.api.API.Status.EXPERIMENTAL;

/**
* @author Karl Heinz Marbaise
*/
@API(status = EXPERIMENTAL)
public class Fraction implements Comparable<Fraction> {
private final int numerator;
private final int denominator;

public Fraction(int numerator, int denominator) {
if (denominator == 0) {
throw new IllegalArgumentException("denominator is not allowed to be zero.");
}
int sign = Integer.signum(numerator) * Integer.signum(denominator);

int gcd = MathUtil.calculateGcd(numerator, denominator);
this.numerator = sign * Math.abs(numerator) / gcd;
this.denominator = Math.abs(denominator) / gcd;
}

public Fraction plus(Fraction add) {
if (this.denominator == add.denominator) {
return new Fraction(add.numerator + this.numerator, this.denominator);
} else {
return new Fraction(add.numerator * this.denominator + this.numerator * add.denominator, add.denominator * this.denominator);
}
}

public Fraction subtract(Fraction subtrahend) {
if (this.denominator == subtrahend.denominator) {
return new Fraction(this.numerator - subtrahend.numerator, this.denominator);
} else {
return new Fraction(this.numerator * subtrahend.denominator - this.denominator * subtrahend.numerator, subtrahend.denominator * this.denominator);
}
}

public Fraction multiply(Fraction factor) {
return new Fraction(this.numerator * factor.numerator, this.denominator * factor.denominator);
}

public Fraction divide(Fraction divisor) {
return new Fraction(this.numerator * divisor.denominator, this.denominator * divisor.numerator);
}

public Fraction pow(int power) {
return new Fraction(BigInteger.valueOf(this.numerator).pow(power).intValueExact(), BigInteger.valueOf(this.denominator).pow(power).intValueExact());
}

public int numerator() {
return numerator;
}

public int denominator() {
return denominator;
}

@Override
public int compareTo(Fraction compareTo) {
if (compareTo == null) {
throw new NullPointerException("compareTo is not allowed to be null.");
}
return this.subtract(compareTo).signum();
}

/**
* Returns the signum function of this {@code Fraction}.
*
* @return -1, 0, or 1 as the value of this {@code Fraction}
* is negative, zero, or positive.
*/
public int signum() {
return Integer.signum(numerator);
}

public Fraction negate() {
return new Fraction(Math.negateExact(this.numerator), this.denominator);
}

public double doubleValue() {
return (double) this.numerator / (double) this.denominator;
}

public BigDecimal bigDecimalValue() {
return BigDecimal.valueOf(this.numerator).divide(BigDecimal.valueOf(this.denominator));
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Fraction fraction = (Fraction) o;
return numerator == fraction.numerator &&
denominator == fraction.denominator;
}

@Override
public int hashCode() {
return Objects.hash(numerator, denominator);
}

@Override
public String toString() {
return new StringJoiner(", ", Fraction.class.getSimpleName() + "[", "]")
.add("numerator=" + numerator)
.add("denominator=" + denominator)
.toString();
}
}
Loading

0 comments on commit 58dfdd4

Please sign in to comment.