Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Automatic-Module-Name manifest entry to Java jar files #2451

Open
dkkopp opened this issue Mar 18, 2021 · 4 comments
Open

Add Automatic-Module-Name manifest entry to Java jar files #2451

dkkopp opened this issue Mar 18, 2021 · 4 comments
Assignees
Labels
Bug Feature Request Missing Feature/Wrapper Lang: Java Java wrapper issue
Projects
Milestone

Comments

@dkkopp
Copy link

dkkopp commented Mar 18, 2021

What language and solver does this apply to?
Java

Describe the problem you are trying to solve.
The current Linux jar file cannot be used with the Java module system because it’s file name cannot be converted into an automatic module name. Adding this additional manifest entry will fix this.

Describe the solution you'd like
Add
Automatic-Module-Name: com.google.ortools
to the ortools-java-xxx.jar file

Add
Automatic-Module-Name: com.google.ortools.linux
to the ortools-linux-xxx-xxxx.jar file.

Similar automatic module names should be added to the other os specific jar files (i.e .windows, .mac)

@Mizux Mizux self-assigned this Mar 18, 2021
@Mizux Mizux added Bug Feature Request Missing Feature/Wrapper Lang: Java Java wrapper issue labels Mar 18, 2021
@Mizux Mizux added this to the v8.4 milestone Mar 18, 2021
@Mizux Mizux added this to To do in Feature Requests via automation Mar 18, 2021
@Mizux Mizux moved this from To do to In progress in Feature Requests Mar 18, 2021
@Mizux Mizux modified the milestones: v9.1, Backlog Aug 9, 2021
@Mizux
Copy link
Collaborator

Mizux commented Aug 9, 2021

Do you have sample and maven documentation related to this field ? since the jar is generated by our pom.xml ....

@dkkopp
Copy link
Author

dkkopp commented Aug 9, 2021

You can add it via the maven jar plugin:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>
          <archive>
            <manifestEntries>
              <Automatic-Module-Name>com.google.ortools</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
@Mizux Mizux removed this from In progress in Feature Requests Oct 15, 2021
@Mizux Mizux added this to To do in ToDo via automation Dec 8, 2021
@Mizux Mizux moved this from To do to In progress in ToDo Dec 8, 2021
@Mizux Mizux modified the milestones: Backlog, v9.2 Dec 8, 2021
@Mizux Mizux moved this from In progress to Stall in ToDo Dec 8, 2021
@Mizux
Copy link
Collaborator

Mizux commented Dec 10, 2021

Will postpone it after release since I need to change our pom.xml runtime template to add a new variable then adapt cmake and makefile to change it.

DevNote add

  1. to all pom.xml in https://github.com/google/or-tools/tree/stable/ortools/java add
 <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>
          <archive>
            <manifestEntries>
              <Automatic-Module-Name>@JAVA_PACKAGE@</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
  1. For pom-native.xml.in need to use:
              <Automatic-Module-Name>@JAVA_PACKAGE@.@JAVA_PLATFORM_OS@</Automatic-Module-Name>

rework:

if(APPLE)
set(NATIVE_IDENTIFIER darwin-x86-64)
elseif(UNIX)
set(NATIVE_IDENTIFIER linux-x86-64)
elseif(WIN32)
set(NATIVE_IDENTIFIER win32-x86-64)
else()
message(FATAL_ERROR "Unsupported system !")
endif()

to introduce
JAVA_PLATFORM_OS and JAVA_PLATFORM_ARCH
so NATIVE_IDENTIFIER become

set(NATIVE_IDENTIFIER "${JAVA_PLATFORM_OS}-${JAVA_PLATFORM_ARCH}")

todo(mizux): Add JAVA_ prefix to NATIVE_IDENTIFIER
todo(mizux): Rename NATIVE_IDENTIFIER to PLATFORM_IDENTIFIER ?

  1. also fix Makefile.java
    # Detect RuntimeIDentifier
    ifeq ($(OS),Windows)
    JAVA_NATIVE_IDENTIFIER=win32-x86-64
    else
    ifeq ($(OS),Linux)
    JAVA_NATIVE_IDENTIFIER=linux-x86-64
    else
    ifeq ($(OS),Darwin)
    JAVA_NATIVE_IDENTIFIER=darwin-x86-64
    else
    $(error OS unknown !)
    endif
    endif
    endif

    and
    $(TEMP_JAVA_DIR)/$(JAVA_ORTOOLS_NATIVE_PROJECT)/pom.xml: \
    ${SRC_DIR}/ortools/java/pom-native.xml.in \
    | $(TEMP_JAVA_DIR)/$(JAVA_ORTOOLS_NATIVE_PROJECT)
    $(SED) -e "s/@PROJECT_VERSION@/$(OR_TOOLS_VERSION)/" \
    ortools$Sjava$Spom-native.xml.in \
    > $(TEMP_JAVA_DIR)$S$(JAVA_ORTOOLS_NATIVE_PROJECT)$Spom.xml
    $(SED) -i -e 's/@JAVA_PACKAGE@/$(JAVA_ORTOOLS_PACKAGE)/' \
    $(TEMP_JAVA_DIR)$S$(JAVA_ORTOOLS_NATIVE_PROJECT)$Spom.xml
    $(SED) -i -e 's/@JAVA_NATIVE_PROJECT@/$(JAVA_ORTOOLS_NATIVE_PROJECT)/' \
    $(TEMP_JAVA_DIR)$S$(JAVA_ORTOOLS_NATIVE_PROJECT)$Spom.xml
    $(SED) -i -e 's;@GPG_ARGS@;$(GPG_ARGS);' \
    $(TEMP_JAVA_DIR)$S$(JAVA_ORTOOLS_NATIVE_PROJECT)$Spom.xml

    need to add
	$(SED) -i -e 's;@JAVA_PLATFORM_OS@;$(JAVA_PLATFORM_OS);' \
 $(TEMP_JAVA_DIR)$S$(JAVA_ORTOOLS_NATIVE_PROJECT)$Spom.xml

see:

private static final String RESOURCE_PATH = "ortools-" + Platform.RESOURCE_PREFIX + "/";

ref: http://java-native-access.github.io/jna/5.10.0/javadoc/com/sun/jna/Platform.html#RESOURCE_PREFIX

@Mizux Mizux modified the milestones: v9.2, v9.3 Dec 10, 2021
@Mizux Mizux modified the milestones: v9.3, v10.0 Feb 11, 2022
@Mizux Mizux moved this from Stall to To do in ToDo Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Feature Request Missing Feature/Wrapper Lang: Java Java wrapper issue
2 participants