diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index fe7a72f..652c4e1 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,32 +1,22 @@ -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven +name: Maven build and test -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - - -name: Java CI with Maven - -on: [push, pull_request] +on: + push: + pull_request: jobs: build: - permissions: write-all runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'zulu' - cache: maven + - uses: actions/checkout@v4 - - name: Build with Maven - run: mvn -B package --file pom.xml + - name: Configure JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven - - name: Run the Maven verify phase - run: mvn --batch-mode --update-snapshots verify + - name: Compile and run tests + run: mvn -B clean test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..434dfcf --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +target/ +.idea/ +*.iml +.classpath +.project +.settings/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..da42197 --- /dev/null +++ b/pom.xml @@ -0,0 +1,43 @@ + + + 4.0.0 + + com.mycompany.app + my-app + 1.0-SNAPSHOT + jar + + my-app + + + UTF-8 + 17 + 5.11.4 + + + + + org.junit.jupiter + junit-jupiter + ${junit.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + + org.apache.maven.plugins + maven-surefire-plugin + 3.5.2 + + + + diff --git a/src/main/java/com/mycompany/app/App.java b/src/main/java/com/mycompany/app/App.java new file mode 100644 index 0000000..a83b6da --- /dev/null +++ b/src/main/java/com/mycompany/app/App.java @@ -0,0 +1,12 @@ +package com.mycompany.app; + +public class App +{ + public static void main(String[] args) + { + double val=Double.parseDouble("2.0"); + Sqrt sqrt=new Sqrt(val); + double result=sqrt.calc(); + System.out.println("Sqrt of " + val + " = " + result); + } +} diff --git a/src/main/java/com/mycompany/app/Sqrt.java b/src/main/java/com/mycompany/app/Sqrt.java new file mode 100644 index 0000000..0c1f37a --- /dev/null +++ b/src/main/java/com/mycompany/app/Sqrt.java @@ -0,0 +1,29 @@ +package com.mycompany.app; + +public class Sqrt +{ + double delta=0.00000001; + double arg; + + public Sqrt(double arg) { + this.arg=arg; + } + public double average(double x,double y) { + return (x+y)/2.0; + } + public boolean good(double guess,double x) { + return Math.abs(guess*guess-x)