Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9011303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:41:38+00:00 2026-06-16T02:41:38+00:00

I want to check in Maven if authentication data from property file is provided

  • 0

I want to check in Maven if authentication data from property file is provided by developer during application testing if call integration-test life-cycle.

As state common practice it is bad to commit authentication data to source tree. Standard maven approach described at settings such as username and password should not be distributed along with the pom.xml.

But I don’t like this approach (I want per checkout settings, not per dev-host!!) and want to provide src/text/resources/auth.properties.example in VCS (SVN/GIT/HG) as example and want to make code that check in Maven for existence of src/text/resources/auth.properties which is own per developer (or ever per project checkout!!) but only if integration-test phase was called (or any other after integration-test phase). If executed any previous phases (like compile or test) – this checks must be disabled.

Maven validate phase designed to check build consistency (refer to introduction-to-the-lifecycle). But there are no any checks for phases!! So I use pre-integration-test phase.

I write working code:

<?xml version="1.0" encoding="utf-8"?>
<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>

  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <packaging>jar</packaging>
  <version>1.0</version>
  <name>my-app</name>

  <profiles>

    <profile>
      <id>existent.properties</id>
      <activation>
        <file>
          <missing>auth.properties</missing>
        </file>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.6</version>
            <executions>
              <execution>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <target>
                    <echo>In order to run integration-text life-cycle:</echo>
                    <echo>  1) Rename 'auth.properties.example' into 'auth.properties'.</echo>
                    <echo>  2) Fill 'auth.properties' with your own authentification data.</echo>
                    <fail message="Can't find 'auth.properties'."/>
                  </target>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>

  <build>

    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.6</version>
        <executions>

          <execution>
            <id>test</id>
            <phase>test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <echo>JUnit tests!</echo>
              </target>
            </configuration>
          </execution>

          <execution>
            <id>integration-test</id>
            <phase>integration-test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <echo>Selenium tests!</echo>
              </target>
            </configuration>
          </execution>

        </executions>
      </plugin>

    </plugins>

  </build>

</project>

But as GNU Make guru I dislike above code. Am I right? Is it wrong use of Maven?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:41:40+00:00Added an answer on June 16, 2026 at 2:41 am

    Your approach is fine (if a little over-engineered IMHO – I’d just put that kind of thing in a README / project wiki; the build ought to fail without the file when an attempt is made to read it)

    You might also want to use the Enforcer goal instead of antrun: http://maven.apache.org/enforcer/enforcer-rules/requireFilesExist.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to check a particular file exist in Azure Blob Storage. Is it
I want to check whether any Zip file is present on a specified path.
I want to check in my application programmatically if user shutdown/restart/logoff the computer. I
I want to run maven-install-plugin before dependency check. How can I do that? The
Eclipse has a nice feature I'm using - check out maven projects from SCM
I am working on a maven project which generate war file. I want to
I want check uploading file type, tell please where way is reliable for this,
I want check that that provided Rss feed Link Is valid or not and
I want check how to know user is using my application facebook Example: One
I have a dynamic big File and I want check a Boolean value and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.